types

package
v0.7.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeECDSASecp256k1Signature

func DeserializeECDSASecp256k1Signature(sigBytes []byte) (*curves.EcdsaSignature, error)

func GetEncryptionKeyFromSecp256k1

func GetEncryptionKeyFromSecp256k1(publicKey PubKey) ([]byte, error)

func GetSecretFromSecp256k1

func GetSecretFromSecp256k1(publicKey PubKey) (*accumulator.SecretKey, error)

func RunIteratedProtocol

func RunIteratedProtocol(firstParty pv1.Iterator, secondParty pv1.Iterator) (error, error)

For DKG bob starts first. For refresh and sign, Alice starts first.

func SerializeECDSASecp256k1Signature

func SerializeECDSASecp256k1Signature(sig *curves.EcdsaSignature) ([]byte, error)

func StringListToZkElements

func StringListToZkElements(strs ...string) []accumulator.Element

func StringToZkElement

func StringToZkElement(str string) accumulator.Element

Types

type EncKeyshareSet

type EncKeyshareSet struct {
	Public    *Keyshare `json:"public"`
	Encrypted []byte    `json:"user"`
}

func (*EncKeyshareSet) DecryptUserKeyshare

func (kss *EncKeyshareSet) DecryptUserKeyshare(key crypto.EncryptionKey) (KeyshareSet, error)

func (*EncKeyshareSet) FormatDID

func (kss *EncKeyshareSet) FormatDID(ct crypto.CoinType) string

FormatDID returns the DID of the account based on the coin type

func (*EncKeyshareSet) GetAccountData

func (kss *EncKeyshareSet) GetAccountData(ct crypto.CoinType) *crypto.AccountData

GetAccountData returns the proto representation of the account

func (*EncKeyshareSet) Marshal

func (kss *EncKeyshareSet) Marshal() ([]byte, error)

Marshal returns the JSON encoding of the EncKeyshareSet.

func (*EncKeyshareSet) PublicKey

func (kss *EncKeyshareSet) PublicKey() *secp256k1.PubKey

The `PublicKey()` function is a method of the `KeyshareSet` type. It returns the public key corresponding to Alice's keyshare in the keyshare set. It does this by calling the `PubKey()` method of the `Keyshare` object corresponding to Alice's keyshare. If the keyshare set is not valid or if there is an error in retrieving the public key, it returns an error.

func (*EncKeyshareSet) Unmarshal

func (kss *EncKeyshareSet) Unmarshal(bz []byte) error

Unmarshal parses the JSON-encoded data and stores the result in the EncKeyshareSet.

type Keyshare

type Keyshare struct {
	// The `dkgResultMessage` field is a pointer to a `protocol.Message` object that contains the DKG result message.
	Output *protocol.Message `json:"output"`

	// The `role` field is a `KeyshareRole` object that indicates the role of the keyshare.
	Role KeyshareRole `json:"role"`
}

func NewAliceKeyshare

func NewAliceKeyshare(dkgResultMsg *protocol.Message) *Keyshare

func NewBobKeyshare

func NewBobKeyshare(dkgResultMsg *protocol.Message) *Keyshare

func (*Keyshare) FormatAddress

func (ks *Keyshare) FormatAddress(ct sonrcrypto.CoinType) (string, error)

func (*Keyshare) FormatDID

func (ks *Keyshare) FormatDID(ct sonrcrypto.CoinType) (string, error)

func (*Keyshare) GetAliceDKGResult

func (ks *Keyshare) GetAliceDKGResult() (*dkg.AliceOutput, error)

func (*Keyshare) GetBobDKGResult

func (ks *Keyshare) GetBobDKGResult() (*dkg.BobOutput, error)

func (*Keyshare) MarshalPrivate

func (ks *Keyshare) MarshalPrivate() ([]byte, error)

func (*Keyshare) MarshalPublic

func (ks *Keyshare) MarshalPublic() ([]byte, error)

func (*Keyshare) PubKey

func (ks *Keyshare) PubKey() (*secp256k1.PubKey, error)

PubKey returns the public key of the keyshare as a secp256k1.PubKey

func (*Keyshare) PublicPoint

func (ks *Keyshare) PublicPoint() (*curves.EcPoint, error)

PublicPoint returns the public key of the keyshare as a *curves.EcPoint

func (*Keyshare) UnmarshalPrivate

func (ks *Keyshare) UnmarshalPrivate(bz []byte) error

func (*Keyshare) UnmarshalPublic

func (ks *Keyshare) UnmarshalPublic(bz []byte) error

func (*Keyshare) Verify

func (ks *Keyshare) Verify(msg []byte, sigBz []byte) (bool, error)

Verify returns true if the signature is valid for the keyshare

type KeyshareRole

type KeyshareRole string
const (
	// KeyshareRolePublic is the default role for the alice dkg
	KeyshareRolePublic KeyshareRole = "alice"

	// KeyshareRoleUser is the role for an encrypted keyshare for a user
	KeyshareRoleUser KeyshareRole = "bob"
)

type KeyshareSet

type KeyshareSet [2]*Keyshare

func EmptyKeyshareSet

func EmptyKeyshareSet() KeyshareSet

The function returns an empty KeyshareSet.

func NewKSS

func NewKSS(a *Keyshare, b *Keyshare) KeyshareSet

The function creates a new KeyshareSet object using the provided Alice and Bob DKG result messages.

func NewKeyshareSet

func NewKeyshareSet(aliceDkgResultMsg *protocol.Message, bobDkgResultMsg *protocol.Message) KeyshareSet

The function creates a new KeyshareSet object using the provided Alice and Bob DKG result messages.

func (KeyshareSet) Alice

func (kss KeyshareSet) Alice() *Keyshare

The `Alice()` function is a method of the `KeyshareSet` type. It returns the `Keyshare` object corresponding to Alice's keyshare in the keyshare set.

func (KeyshareSet) Bob

func (kss KeyshareSet) Bob() *Keyshare

The `Bob()` function is a method of the `KeyshareSet` type. It returns the `Keyshare` object corresponding to Bob's keyshare in the keyshare set.

func (KeyshareSet) DKGAtIndex

func (kss KeyshareSet) DKGAtIndex(i int) *protocol.Message

The `DKGAtIndex` function is a method of the `KeyshareSet` type. It takes an integer `i` as input and returns the DKG (Distributed Key Generation) result message at the specified index.

func (KeyshareSet) EncryptUserKeyshare

func (kss KeyshareSet) EncryptUserKeyshare(c crypto.EncryptionKey) (*EncKeyshareSet, error)

func (KeyshareSet) FormatAddress

func (kss KeyshareSet) FormatAddress(ct crypto.CoinType) string

FormatAddress returns the address of the account based on the coin type

func (KeyshareSet) FormatDID

func (kss KeyshareSet) FormatDID(ct crypto.CoinType) string

FormatDID returns the DID of the account based on the coin type

func (KeyshareSet) GetAccountData

func (wa KeyshareSet) GetAccountData(ct crypto.CoinType) *crypto.AccountData

GetAccountData returns the proto representation of the account

func (KeyshareSet) IsValid

func (kss KeyshareSet) IsValid() error

The `IsValid()` function is a method of the `KeyshareSet` type. It checks if the `KeyshareSet` object is valid by performing the following checks:

func (KeyshareSet) PublicKey

func (kss KeyshareSet) PublicKey() *secp256k1.PubKey

The `PublicKey()` function is a method of the `KeyshareSet` type. It returns the public key corresponding to Alice's keyshare in the keyshare set. It does this by calling the `PubKey()` method of the `Keyshare` object corresponding to Alice's keyshare. If the keyshare set is not valid or if there is an error in retrieving the public key, it returns an error.

func (KeyshareSet) Sign

func (kss KeyshareSet) Sign(msg []byte) ([]byte, error)

The `Sign` function is a method of the `KeyshareSet` type. It takes a byte slice `msg` as input and returns a byte slice and an error.

func (KeyshareSet) Verify

func (kss KeyshareSet) Verify(msg []byte, sigBz []byte) (bool, error)

The `Verify` function is a method of the `KeyshareSet` type. It takes a byte slice `msg` and a byte slice `sigBz` as input and returns a boolean value and an error.

type PubKey

type PubKey = cryptotypes.PubKey

type Secp256k1PublicKey

type Secp256k1PublicKey = *secp256k1.PubKey

type ZKAccumulator

type ZKAccumulator = accumulator.Accumulator

type ZKEphemeralKey

type ZKEphemeralKey []byte

func GetEphemeralFromSecp256k1

func GetEphemeralFromSecp256k1(publicKey PubKey) (ZKEphemeralKey, error)

func (ZKEphemeralKey) String

func (zk ZKEphemeralKey) String() string

type ZKSet

type ZKSet string

func CreateZkSet

func CreateZkSet(publicKey PubKey, initialIds ...string) (ZKSet, error)

CreateZkSet creates a new ZKSet from a public key and a list of initial ids

func OpenZkSet

func OpenZkSet(str string) (ZKSet, error)

OpenZkSet takes a plain string and returns a ZkSet on success

func (ZKSet) AddElement

func (c ZKSet) AddElement(pk PubKey, elem string) error

AddElement adds an element to the accumulator

func (ZKSet) Decrypt

func (c ZKSet) Decrypt(key PubKey, ciphertext []byte) ([]byte, error)

Decrypt decrypts a ciphertext using the public key

func (ZKSet) Encrypt

func (c ZKSet) Encrypt(key PubKey, bz []byte) ([]byte, error)

Encrypt encrypts a message with the ZKSet

func (ZKSet) GetAccumulator

func (s ZKSet) GetAccumulator() *ZKAccumulator

GetAccumulator returns the accumulator for the ZKSet

func (ZKSet) RemoveElement

func (c ZKSet) RemoveElement(pk PubKey, elem string) error

RemoveElement removes an element from the accumulator

func (ZKSet) SetAccumulator

func (s ZKSet) SetAccumulator(a *ZKAccumulator) error

SetAccumulator sets the accumulator for the ZKSet

func (ZKSet) String

func (s ZKSet) String() string

String returns the string representation of the ZKSet

func (ZKSet) ValidateMembership

func (c ZKSet) ValidateMembership(spk PubKey, elem string) bool

ValidateMembership validates that an element is a member of the set

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL