sign

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// One is used to initialize the Lagrange coefficient
	One = append([]byte{0x01}, make([]byte, 31)...)
)

Functions

func C

func C(msg []byte, r, groupKey *ristretto255.Element) ristretto255.Scalar

C = H(R || Y || msg)

func Lambda

func Lambda(id peer.ID, peers []peer.ID) (*ristretto255.Scalar, error)

Lambda evaluates the ith Lagrange basis polynomial at `x = 0`

`P_i(0) = \prod_{j = 1, j\ne i}^n\frac{x_j}{x_j - x_i}`

`\lambda` is used to convert between additive secret shares and polynomial (Shamir) secret shares

Types

type Messages

type Messages struct {
	NoncePairs  map[peer.ID]NonceMsg
	PartialSigs map[peer.ID]PartialSigMsg
}

Messages holds peer messages exchanged during message signing

func InitMessages

func InitMessages(n int) *Messages

InitMessages initializes message buffers

type Nonce

type Nonce struct {
	N *ristretto255.Scalar  // single-use nonce
	C *ristretto255.Element // derived commitment share
}

Nonce holds a single-use nonce generated during the preprocessing stage

func (*Nonce) Decode

func (n *Nonce) Decode(buf []byte) error

Decode the 32 byte commitment portion of a nonce

func (*Nonce) Encode

func (n *Nonce) Encode() (buf []byte)

Encode the 32 byte commitment portion of a nonce

func (*Nonce) New

func (n *Nonce) New() (err error)

New generates a new single-use nonce

func (*Nonce) Zero

func (n *Nonce) Zero()

Zero clears the nonce to prevent reuse

type NonceMsg

type NonceMsg struct {
	ID peer.ID
	D  ristretto255.Element
	E  ristretto255.Element
	M  []byte
}

NonceMsg is used to broadcast the nonce pair generated for key signing

func (*NonceMsg) Decode

func (n *NonceMsg) Decode(buf []byte) error

Decode a nonce message

func (NonceMsg) Encode

func (n NonceMsg) Encode() []byte

Encode a nonce message

type NoncePairs

type NoncePairs map[peer.ID]NonceMsg

NoncePairs holds peer generated single-use nonce pairs

type PartialSigMsg

type PartialSigMsg struct {
	ID peer.ID
	Z  ristretto255.Scalar
}

PartialSigMsg is used to broadcast the partial signature `z_i`

func (*PartialSigMsg) Decode

func (p *PartialSigMsg) Decode(buf []byte) error

Decode a response message

func (PartialSigMsg) Encode

func (p PartialSigMsg) Encode() []byte

Encode a response message

type PartialSigs

type PartialSigs map[peer.ID]PartialSigMsg

PartialSigs holds the partial signature `z_i` for each peer

type Sign

type Sign struct {
	ID        peer.ID                          // signer's ID
	Peers     []peer.ID                        // set of t <= peers >= n
	Msg       []byte                           // the message to be signed
	D         Nonce                            // (d_i, D_i)
	E         Nonce                            // (e_i, E_i)
	Rho       ristretto255.Scalar              // binding value ρ
	Ri        map[peer.ID]ristretto255.Element // set of all peer commitments R_i
	C         ristretto255.Scalar              // challenge value
	Signature                                  // aggregated multisignature
}

Sign holds information necessary for a group sign operation

func InitSign

func InitSign(id peer.ID, peers []peer.ID, msg []byte) (*Sign, error)

InitSign initiates a group signing operation

func (*Sign) Aggregate

func (s *Sign) Aggregate(resp PartialSigs)

Aggregate partial signatures into a multisignature

func (*Sign) GroupCommitment

func (s *Sign) GroupCommitment(np NoncePairs)

GroupCommitment derives the group commitment R from the set of all nonce pairs

func (Sign) NonceMsg

func (s Sign) NonceMsg() *NonceMsg

NonceMsg extracts a nonce pair from a signature run

func (Sign) PartialSig

func (s Sign) PartialSig() *PartialSigMsg

PartialSig extracts the partial signature `z_i` from a signature run

func (*Sign) PartialSign

func (s *Sign) PartialSign(key *dkg.Keys) error

PartialSign calculates a partial signature z over a challenge value and a secret share

func (*Sign) Preprocess

func (s *Sign) Preprocess() error

Preprocess filters the peer list and generates a nonce pair

func (Sign) Valid

func (s Sign) Valid(z ristretto255.Scalar, id peer.ID, share ristretto255.Element) bool

Valid ensures a partial signature was derived correctly

type Signature

type Signature struct {
	R ristretto255.Element
	Z ristretto255.Scalar
}

Signature holds a Schnorr multisignature generated using >= t secret shares <= n and verified using the group public key

func (*Signature) Decode

func (s *Signature) Decode(buf []byte) error

Decode a multisignature

func (Signature) Encode

func (s Signature) Encode() []byte

Encode a multisignature

func (Signature) Verify

func (s Signature) Verify(msg []byte, pubkey *ristretto255.Element) bool

Verify a multisignature

Jump to

Keyboard shortcuts

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