keys

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 10 Imported by: 4

Documentation

Overview

Package keys defines key material holding structures for secret sharing setups, like public key shares, private, and a registry to hold and manage a set of public key shares.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyShare

type KeyShare struct {
	Secret          *ecc.Scalar  `json:"secret"`
	VerificationKey *ecc.Element `json:"verificationKey"`
	PublicKeyShare
}

KeyShare holds the secret and public key share for a given participant.

func (*KeyShare) Decode

func (k *KeyShare) Decode(data []byte) error

Decode deserializes the compact encoding obtained from Encode(), or returns an error.

func (*KeyShare) DecodeHex

func (k *KeyShare) DecodeHex(h string) error

DecodeHex sets k to the decoding of the hex encoded representation returned by Hex().

func (*KeyShare) Encode

func (k *KeyShare) Encode() []byte

Encode serializes k into a compact byte string.

func (*KeyShare) Group

func (k *KeyShare) Group() ecc.Group

Group returns the elliptic curve group used for this key share.

func (*KeyShare) Hex

func (k *KeyShare) Hex() string

Hex returns the hexadecimal representation of the byte encoding returned by Encode().

func (*KeyShare) Identifier

func (k *KeyShare) Identifier() uint16

Identifier returns the identity for this share.

func (*KeyShare) Public

func (k *KeyShare) Public() *PublicKeyShare

Public returns the public key share and identifier corresponding to the secret key share.

func (*KeyShare) SecretKey

func (k *KeyShare) SecretKey() *ecc.Scalar

SecretKey returns the participant's secret share.

func (*KeyShare) UnmarshalJSON

func (k *KeyShare) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes data into k, or returns an error.

type PublicKeyShare

type PublicKeyShare struct {
	// The PublicKey of Secret belonging to the participant.
	PublicKey *ecc.Element `json:"publicKey"`

	// The VssCommitment to the polynomial the key was created with.
	VssCommitment []*ecc.Element `json:"vssCommitment,omitempty"`

	// ID of the participant.
	ID uint16 `json:"id"`

	// Group specifies the elliptic curve group the elements are part of.
	Group ecc.Group `json:"group"`
}

PublicKeyShare specifies the public key of a participant identified with ID. This can be useful to keep a registry of participants.

func (*PublicKeyShare) Decode

func (p *PublicKeyShare) Decode(data []byte) error

Decode deserializes the compact encoding obtained from Encode(), or returns an error.

func (*PublicKeyShare) DecodeHex

func (p *PublicKeyShare) DecodeHex(h string) error

DecodeHex sets p to the decoding of the hex encoded representation returned by Hex().

func (*PublicKeyShare) Encode

func (p *PublicKeyShare) Encode() []byte

Encode serializes p into a compact byte string.

func (*PublicKeyShare) Hex

func (p *PublicKeyShare) Hex() string

Hex returns the hexadecimal representation of the byte encoding returned by Encode().

func (*PublicKeyShare) UnmarshalJSON

func (p *PublicKeyShare) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes data into p, or returns an error.

type PublicKeyShareRegistry

type PublicKeyShareRegistry struct {
	VerificationKey *ecc.Element               `json:"verificationKey"`
	PublicKeyShares map[uint16]*PublicKeyShare `json:"publicKeyShares"`
	Total           uint16                     `json:"total"`
	Threshold       uint16                     `json:"threshold"`
	Group           ecc.Group                  `json:"group"`
}

PublicKeyShareRegistry regroups the final public information about key shares and participants, enabling a registry and public key verifications.

func NewPublicKeyShareRegistry

func NewPublicKeyShareRegistry(g ecc.Group, threshold, total uint16) *PublicKeyShareRegistry

NewPublicKeyShareRegistry returns a populated PublicKeyShareRegistry.

func (*PublicKeyShareRegistry) Add

Add adds the PublicKeyShare to the registry if it's not full or no key for the identifier is already set, in which case an error is returned.

func (*PublicKeyShareRegistry) Decode

func (k *PublicKeyShareRegistry) Decode(data []byte) error

Decode deserializes the input data into the registry, expecting the same encoding as used in Encode(). It doesn't modify the receiver when encountering an error.

func (*PublicKeyShareRegistry) DecodeHex

func (k *PublicKeyShareRegistry) DecodeHex(h string) error

DecodeHex sets k to the decoding of the hex encoded representation returned by Hex().

func (*PublicKeyShareRegistry) Encode

func (k *PublicKeyShareRegistry) Encode() []byte

Encode serializes the registry into a compact byte encoding of the registry, suitable for storage or transmissions.

func (*PublicKeyShareRegistry) Get

Get returns the registered public key for id, or nil.

func (*PublicKeyShareRegistry) Hex

func (k *PublicKeyShareRegistry) Hex() string

Hex returns the hexadecimal representation of the byte encoding returned by Encode().

func (*PublicKeyShareRegistry) UnmarshalJSON

func (k *PublicKeyShareRegistry) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the input data as JSON and deserializes it into the receiver. It doesn't modify the receiver when encountering an error.

func (*PublicKeyShareRegistry) VerifyPublicKey

func (k *PublicKeyShareRegistry) VerifyPublicKey(id uint16, pubKey *ecc.Element) error

VerifyPublicKey returns nil if the id / pubKey pair is registered, and an error otherwise.

type Share

type Share interface {
	// Group returns the elliptic curve group used for this key share.
	Group() ecc.Group

	// Identifier returns the identity for this share.
	Identifier() uint16

	// SecretKey returns the participant's secret share.
	SecretKey() *ecc.Scalar
}

The Share interface enables to use functions in this package with compatible key shares.

Jump to

Keyboard shortcuts

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