ed

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EDDSAStats = sig.SigStats{
	PubSize:       32,
	SigSize:       64,
	SigVerifyTime: 342579,
	SignTime:      105099,
}
View Source
var SchnorrStats = sig.SigStats{
	PubSize:          33,
	SigSize:          64,
	ThrshShareSize:   192,
	SigVerifyTime:    359155,
	SignTime:         199822,
	ShareVerifyTime:  1208729,
	ShareGenTime:     1038380,
	ShareCombineTime: 1814843 / 7,
	AllowsCoin:       true,
}

Functions

func NewEdPartPriv

func NewEdPartPriv(thrsh *EdCoinThresh) (sig.Priv, error)

NewEdPartialPriv creates a new partial priv given the thrsh structure.

func NewEdpriv

func NewEdpriv() (sig.Priv, error)

NewEcpriv creates a new random EDDSA private key object

func NewSchnorrpriv

func NewSchnorrpriv() (sig.Priv, error)

NewEcpriv creates a new random schnorr private key object

func NewSchnorrprivFrom

func NewSchnorrprivFrom(secret kyber.Scalar) sig.Priv

Types

type CoinShared

type CoinShared struct {
	NumParticipants  int
	NumThresh        int
	MemberScalars    []kyber.Scalar
	MemberPoints     []kyber.Point
	NonMemberScalars []kyber.Scalar
	NonMemberPoints  []kyber.Point
	SharePoint       kyber.Point
}

CoinShared represents precomputed information used to create threshold secrets for generating random coins.

func NewCoinShared

func NewCoinShared(numTotalNodes, numNonMembers, numThresh int) *CoinShared

NewCoinShared creates a CoinShared object for creating threshold coin keys. It generates private values centrally so is only for testing.

func (*CoinShared) PartialMarshal

func (ds *CoinShared) PartialMarshal() (ret CoinSharedMarshaled, err error)

PartialMartial partially martials a CoinShared object into a CoinSharedMarshaled object, which can then be mashaled into json for example.

type CoinSharedMarshaled

type CoinSharedMarshaled struct {
	NumParticipants  int
	NumThresh        int
	MemberScalars    [][]byte
	MemberPoints     [][]byte
	NonMemberScalars [][]byte
	NonMemberPoints  [][]byte
	SharePoint       []byte
}

CoinSharedMarshaled is a partially marshalled version of CoinShared. It can then be input to the go json marshaller for example. It doesn't include the PartSec field of CoinShared.

func (CoinSharedMarshaled) PartialUnMartial

func (dsm CoinSharedMarshaled) PartialUnMartial() (ret *CoinShared, err error)

PartialUnmartial takes a CoinSharedMarshaled object, unmarshals it, and returns a CoinShared object.

type EdCoinThresh

type EdCoinThresh struct {
	// contains filtered or unexported fields
}

EdCoinThresh keys threshold keys that should be generated using a distributed key generation protocol. They support normal EDDSA signatures, plus the use of threshold coin proofs for generating random coins.

func NewEdThresh

func NewEdThresh(index sig.PubKeyIndex, dSh *CoinShared) *EdCoinThresh

func (*EdCoinThresh) CheckCoinProof

func (et *EdCoinThresh) CheckCoinProof(msg sig.SignedMessage, prf sig.CoinProof) error

func (*EdCoinThresh) CombineProofs

func (et *EdCoinThresh) CombineProofs(_ sig.Priv, items []*sig.SigItem) (coinVal types.BinVal, err error)

CombineProofs combines the given proofs and returns the resulting coin values. The proofs are expected to have already been validated by CheckCoinProof.

func (*EdCoinThresh) GetN

func (et *EdCoinThresh) GetN() int

func (*EdCoinThresh) GetPartialPub

func (et *EdCoinThresh) GetPartialPub() sig.Pub

func (*EdCoinThresh) GetSharedPub

func (et *EdCoinThresh) GetSharedPub() sig.Pub

func (*EdCoinThresh) GetT

func (et *EdCoinThresh) GetT() int

func (*EdCoinThresh) ShallowCopy

func (et *EdCoinThresh) ShallowCopy() *EdCoinThresh

type Edpriv

type Edpriv struct {
	// contains filtered or unexported fields
}

EDpriv represents the EDDSA private key object

func (*Edpriv) Clean

func (priv *Edpriv) Clean()

Clean does nothing

func (*Edpriv) ComputeSharedSecret

func (priv *Edpriv) ComputeSharedSecret(pub sig.Pub) [32]byte

ComputeSharedSecret returns the hash of Diffie-Hellman.

func (*Edpriv) GenerateSig

func (priv *Edpriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)

GenerateSig signs a message and returns the SigItem object containing the signature

func (*Edpriv) GetBaseKey

func (priv *Edpriv) GetBaseKey() sig.Priv

GetBaseKey returns the same key.

func (*Edpriv) GetPrivForSignType

func (priv *Edpriv) GetPrivForSignType(signType types.SignType) (sig.Priv, error)

Returns key that is used for signing the sign type.

func (*Edpriv) GetPub

func (priv *Edpriv) GetPub() sig.Pub

GetPub returns the coreesponding EDDSA public key object

func (*Edpriv) New

func (priv *Edpriv) New() sig.Priv

New creates an empty EDDSA private key object

func (*Edpriv) NewSig

func (priv *Edpriv) NewSig() sig.Sig

NewSig returns an empty sig object of the same type.

func (*Edpriv) SetIndex

func (priv *Edpriv) SetIndex(index sig.PubKeyIndex)

SetIndex sets the index of the node represented by this key in the consensus participants

func (*Edpriv) ShallowCopy

func (priv *Edpriv) ShallowCopy() sig.Priv

Shallow copy makes a copy of the object without following pointers.

func (*Edpriv) Sign

func (priv *Edpriv) Sign(msg sig.SignedMessage) (sig.Sig, error)

Sign signs a message and returns the signature.

type Edpub

type Edpub struct {
	// contains filtered or unexported fields
}

Edpub represents an EDDSA public key

func NewEdThresholdPub

func NewEdThresholdPub(pub kyber.Point, memberNumber int) (*Edpub, error)

NewEdThresholdPub creates a new threshold type EDDSA public key the only different for threshold pubs is that they are given index -1

func NewEdpub

func NewEdpub(pub kyber.Point) (*Edpub, error)

// NewSchnorrThresholdPub creates a new threshold type schnorr public key // the only different for threshold pubs is that they are given index -1

func NewSchnorrThresholdPub(pub kyber.Point, memberNumber int) (*Edpub, error) {
	ed := &Edpub{pub: pub, pubEdtype: schnorrType, useIndex: true, index: -1}
	ed.memberNumber = memberNumber
	_, err := ed.GetPubBytes()
	if err != nil {
		return ed, err
	}
	_, err = ed.GetPubID() // to populate values
	return ed, err
}

NewEdpub creates a new a new EDDSA type public key

func NewSchnorrpub

func NewSchnorrpub(pub kyber.Point) (*Edpub, error)

NewEdpub creates a new a new Schnorr type public key

func (*Edpub) CheckSignature

func (pub *Edpub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error

CheckSignature validates the signature with the public key, it returns an error if a coin proof is included.

func (*Edpub) Decode

func (pub *Edpub) Decode(reader io.Reader) (n int, err error)

func (*Edpub) Deserialize

func (pub *Edpub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)

Deserialize updates the fields of the pub key object from m, and returns the number of bytes read

func (*Edpub) DeserializeCoinProof

func (pub *Edpub) DeserializeCoinProof(m *messages.Message) (coinProof *coinproof.CoinProof, size int, err error)

func (*Edpub) DeserializeSig

func (pub *Edpub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)

DeserializeSig takes a message and returns an EDDSA public key object and signature as well as the number of bytes read

func (*Edpub) Encode

func (pub *Edpub) Encode(writer io.Writer) (n int, err error)

func (*Edpub) FromPubBytes

func (pub *Edpub) FromPubBytes(b sig.PubKeyBytes) (sig.Pub, error)

FromPubBytes generates an EDDSA public key object from the bytes of a public key

func (*Edpub) GetBytes

func (pub *Edpub) GetBytes(m *messages.Message) ([]byte, error)

GetBytes returns the bytes of the EDDSA public key from the message

func (*Edpub) GetID

func (pub *Edpub) GetID() messages.HeaderID

GetID returns the header id for EDDSA pub objects

func (*Edpub) GetIndex

func (pub *Edpub) GetIndex() sig.PubKeyIndex

GetIndex gets the index of the node represented by this key in the consensus participants

func (*Edpub) GetMsgID

func (pub *Edpub) GetMsgID() messages.MsgID

GetMsgID returns the message id for an EDDSA public key

func (*Edpub) GetPubBytes

func (pub *Edpub) GetPubBytes() (sig.PubKeyBytes, error)

GetPubBytes returns the EDDSA pub key as bytes (same as GetRealPubBytes for ECDSA keys)

func (*Edpub) GetPubID

func (pub *Edpub) GetPubID() (sig.PubKeyID, error)

GetPubID returns the unique id for this pubkey (given some consensus instance), it could be the encoded bitid, or just the pub key depending on how SetUsePubIndex was set

func (*Edpub) GetPubString

func (pub *Edpub) GetPubString() (sig.PubKeyStr, error)

GetPubString is the same as GetPubBytes, except returns a string

func (*Edpub) GetRealPubBytes

func (pub *Edpub) GetRealPubBytes() (sig.PubKeyBytes, error)

GetRealPubBytes returns the EDDSA pub key as bytes (same as GetPubBytes for EDDSA keys)

func (*Edpub) GetSigMemberNumber

func (pub *Edpub) GetSigMemberNumber() int

GetSigMemberNumber returns the number of signers this signature represents this can be more than one as once combined, threshold signatures are EDDSA signatures

func (*Edpub) New

func (pub *Edpub) New() sig.Pub

New returns a blank EDDSA public key object

func (Edpub) PeekHeaders

PeekHeader returns nil.

func (*Edpub) Serialize

func (pub *Edpub) Serialize(m *messages.Message) (int, error)

Serialize the pub key into the message, return the number of bytes written

func (*Edpub) SetIndex

func (pub *Edpub) SetIndex(index sig.PubKeyIndex)

SetIndex sets the index of the node represented by this key in the consensus participants

func (*Edpub) ShallowCopy

func (pub *Edpub) ShallowCopy() sig.Pub

Shallow copy makes a copy of the object without following pointers.

func (*Edpub) VerifySig

func (pub *Edpub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)

VerifySig verifies that sig is a valid signature for msg by EDDSA public key pub

type Edsig

type Edsig struct {
	// contains filtered or unexported fields
}

Edsig is the object representing an EDDSA signature

func NewEdSig

func NewEdSig() *Edsig

NewEdSig returns an empty EDDSA signature object

func NewSchnorrSig

func NewSchnorrSig() *Edsig

NewEdSig returns an empty schnorr signature object

func (*Edsig) Corrupt

func (sig *Edsig) Corrupt()

Corrupt invalidates the signature

func (*Edsig) Decode

func (sig *Edsig) Decode(reader io.Reader) (n int, err error)

func (*Edsig) Deserialize

func (sig *Edsig) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)

GetBytes returns the bytes of the signature from the message

func (*Edsig) Encode

func (sig *Edsig) Encode(writer io.Writer) (n int, err error)

func (*Edsig) GetBytes

func (sig *Edsig) GetBytes(m *messages.Message) ([]byte, error)

func (*Edsig) GetID

func (sig *Edsig) GetID() messages.HeaderID

GetID returns the header id for the EDDSA signature object type

func (*Edsig) GetMsgID

func (sig *Edsig) GetMsgID() messages.MsgID

GetMsgID returns the message ID for EDDSA sig header

func (*Edsig) GetRand

func (sig *Edsig) GetRand() types.BinVal

GetRand returns a random binary from the signature if supported.

func (*Edsig) New

func (sig *Edsig) New() sig.Sig

New returns a empty EDDSA signature object of the same type as sig

func (Edsig) PeekHeaders

PeekHeader returns nil.

func (*Edsig) Serialize

func (sig *Edsig) Serialize(m *messages.Message) (int, error)

Serialize the signature into the message, and return the nuber of bytes written

type PartPub

type PartPub struct {
	*EdCoinThresh
	// contains filtered or unexported fields
}

func NewEdPartPub

func NewEdPartPub(index sig.PubKeyIndex, point kyber.Point, edThresh *EdCoinThresh) *PartPub

func (*PartPub) CheckSignature

func (pub *PartPub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error

CheckSignature validates the signature with the public key. If the message type is a coin message, it is verified using CoinProof

func (*PartPub) Decode

func (pub *PartPub) Decode(r io.Reader) (n int, err error)

func (*PartPub) Deserialize

func (pub *PartPub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)

func (*PartPub) DeserializeCoinProof

func (pub *PartPub) DeserializeCoinProof(m *messages.Message) (coinProof sig.CoinProof, size int, err error)

func (*PartPub) DeserializeSig

func (pub *PartPub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)

func (*PartPub) Encode

func (pub *PartPub) Encode(w io.Writer) (n int, err error)

func (*PartPub) FromPubBytes

func (pub *PartPub) FromPubBytes(b sig.PubKeyBytes) (sig.Pub, error)

func (*PartPub) GetBytes

func (pub *PartPub) GetBytes(*messages.Message) ([]byte, error)

func (*PartPub) GetID

func (pub *PartPub) GetID() messages.HeaderID

func (*PartPub) GetIndex

func (pub *PartPub) GetIndex() sig.PubKeyIndex

GetIndex gets the index of the node represented by this key in the consensus participants

func (*PartPub) GetMsgID

func (pub *PartPub) GetMsgID() messages.MsgID

func (*PartPub) GetPubBytes

func (pub *PartPub) GetPubBytes() (sig.PubKeyBytes, error)

func (*PartPub) GetPubID

func (pub *PartPub) GetPubID() (sig.PubKeyID, error)

func (*PartPub) GetPubString

func (pub *PartPub) GetPubString() (sig.PubKeyStr, error)

func (*PartPub) GetRealPubBytes

func (pub *PartPub) GetRealPubBytes() (sig.PubKeyBytes, error)

func (*PartPub) GetSigMemberNumber

func (pub *PartPub) GetSigMemberNumber() int

func (*PartPub) New

func (pub *PartPub) New() sig.Pub

func (*PartPub) NewCoinProof

func (pub *PartPub) NewCoinProof() sig.CoinProof

func (PartPub) PeekHeaders

PeekHeader returns nil.

func (*PartPub) Serialize

func (pub *PartPub) Serialize(m *messages.Message) (int, error)

func (*PartPub) SetIndex

func (pub *PartPub) SetIndex(index sig.PubKeyIndex)

func (*PartPub) ShallowCopy

func (pub *PartPub) ShallowCopy() sig.Pub

Shallow copy makes a copy of the object without following pointers.

func (*PartPub) VerifySig

func (pub *PartPub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)

type PartialPriv

type PartialPriv struct {
	*EdCoinThresh
	// contains filtered or unexported fields
}

EdPartialPriv represents the ECDSA private key object.

func (*PartialPriv) Clean

func (priv *PartialPriv) Clean()

Clean does nothing

func (*PartialPriv) ComputeSharedSecret

func (priv *PartialPriv) ComputeSharedSecret(pub sig.Pub) [32]byte

ComputeSharedSecret returns the hash of Diffie-Hellman.

func (*PartialPriv) GenerateSig

func (priv *PartialPriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof,
	signType types.SignType) (*sig.SigItem, error)

GenerateSig signs a message and returns the SigItem object containing the signature.

func (*PartialPriv) GetBaseKey

func (priv *PartialPriv) GetBaseKey() sig.Priv

GetBaseKey returns the key as a normal Schnorr private key.

func (*PartialPriv) GetEdThresh

func (priv *PartialPriv) GetEdThresh() *EdCoinThresh

GetEdThresh returns the EdCoinThresh object.

func (*PartialPriv) GetPrivForSignType

func (priv *PartialPriv) GetPrivForSignType(signType types.SignType) (sig.Priv, error)

Returns key that is used for signing the sign type.

func (*PartialPriv) GetPub

func (priv *PartialPriv) GetPub() sig.Pub

GetPub returns the coreesponding ECDSA public key object.

func (*PartialPriv) New

func (priv *PartialPriv) New() sig.Priv

New creates an empty ECDSA private key object.

func (*PartialPriv) NewSig

func (priv *PartialPriv) NewSig() sig.Sig

NewSig returns an empty sig object of the same type.

func (*PartialPriv) SetIndex

func (priv *PartialPriv) SetIndex(index sig.PubKeyIndex)

SetIndex sets the index of the node represented by this key in the consensus participants.

func (*PartialPriv) ShallowCopy

func (priv *PartialPriv) ShallowCopy() sig.Priv

Shallow copy makes a copy of the object without following pointers.

func (*PartialPriv) Sign

func (priv *PartialPriv) Sign(msg sig.SignedMessage) (sig.Sig, error)

Sign signs a message and returns the signature.

Jump to

Keyboard shortcuts

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