sleep

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GetAllSigStatsNewPriv

func GetAllSigStatsNewPriv(onlyVrf, onlyMulti bool, newBitIDFunc []bitid.FromIntFunc) (ret []func() (sig.Priv, error), retStats []sig.SigStats)

func NewBLSPriv

func NewBLSPriv(i sig.PubKeyIndex, newBitIDFunc bitid.FromIntFunc) (sig.Priv, error)

func NewCoinDualPriv

func NewCoinDualPriv(i sig.PubKeyIndex, to types.TestOptions) (sig.Priv, error)

func NewCoinSleepPriv

func NewCoinSleepPriv(n, t int, i sig.PubKeyIndex, stats *sig.SigStats) sig.Priv

func NewECPriv

func NewECPriv(i sig.PubKeyIndex) (sig.Priv, error)

func NewEDCoinPriv

func NewEDCoinPriv(i sig.PubKeyIndex, to types.TestOptions) (sig.Priv, error)

func NewEDPriv

func NewEDPriv(i sig.PubKeyIndex) (sig.Priv, error)

func NewQsafePriv

func NewQsafePriv(i sig.PubKeyIndex) (sig.Priv, error)

func NewSchnorrPriv

func NewSchnorrPriv(i sig.PubKeyIndex) (sig.Priv, error)

func NewSleepMultiPriv

func NewSleepMultiPriv(priv sig.Priv, newBitIDFunc bitid.FromIntFunc, stats *sig.SigStats) (sig.Priv, error)

func NewSleepPriv

func NewSleepPriv(stats *sig.SigStats, i sig.PubKeyIndex) (sig.Priv, error)

NewSleepPriv creates a new random sleep private key object

func NewSleepThrshPriv

func NewSleepThrshPriv(n, t int, priv sig.Priv, stats *sig.SigStats) (sig.Priv, error)

func NewSleepVrfPriv

func NewSleepVrfPriv(priv sig.Priv, stats *sig.SigStats) (sig.Priv, error)

func NewTBLSDualPriv

func NewTBLSDualPriv(i sig.PubKeyIndex, to types.TestOptions) (sig.Priv, error)

func NewTBLSPriv

func NewTBLSPriv(n, t int, i sig.PubKeyIndex) (sig.Priv, error)

Types

type MultiPriv

type MultiPriv struct {
	VrfPriv
}

func (*MultiPriv) Evaluate

func (p *MultiPriv) Evaluate(m sig.SignedMessage) (index [32]byte, proof sig.VRFProof)

Evaluate generates a vrf. The index and thee first 32 bytes are the same. They are the hash of the key index and the message.

func (*MultiPriv) GetPrivForSignType

func (p *MultiPriv) GetPrivForSignType(types.SignType) (sig.Priv, error)

Returns key that is used for signing the sign type.

func (*MultiPriv) ShallowCopy

func (p *MultiPriv) ShallowCopy() sig.Priv

func (*MultiPriv) Sign

func (p *MultiPriv) Sign(msg sig.SignedMessage) (sig.Sig, error)

Sign signs a message and returns the signature.

type Priv

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

Priv represents the sleep private key object

func (*Priv) Clean

func (p *Priv) Clean()

Clean does nothing

func (*Priv) ComputeSharedSecret

func (p *Priv) ComputeSharedSecret(pub sig.Pub) (ret [32]byte)

ComputeSharedSecret returns the hash of Diffie-Hellman.

func (*Priv) GenerateSig

func (p *Priv) GenerateSig(header sig.SignedMessage, vrfProof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)

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

func (*Priv) GetBaseKey

func (p *Priv) GetBaseKey() sig.Priv

GetBaseKey returns the same key.

func (*Priv) GetPrivForSignType

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

Returns key that is used for signing the sign type.

func (*Priv) GetPub

func (p *Priv) GetPub() sig.Pub

GetPub returns the coreesponding sleep public key object

func (*Priv) IsSleepPriv

func (p *Priv) IsSleepPriv()

func (*Priv) NewSig

func (p *Priv) NewSig() sig.Sig

NewSig returns an empty sig object of the same type.

func (*Priv) SetIndex

func (p *Priv) SetIndex(index sig.PubKeyIndex)

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

func (*Priv) ShallowCopy

func (p *Priv) ShallowCopy() sig.Priv

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

func (*Priv) Sign

func (p *Priv) Sign(msg sig.SignedMessage) (sig.Sig, error)

Sign signs a message and returns the signature.

type Pub

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

func (*Pub) CheckSignature

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

CheckSignature will should check what kind of message and signature to verify. It will call CheckCoinProof or VerfiySig depending on the message type.

func (*Pub) Decode

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

func (*Pub) Deserialize

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

Deserialize deserialzes a header into the object, returning the number of bytes read

func (*Pub) DeserializeSig

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

DeserializeSig deserializes a public key and signature object from m, size is the number of bytes read

func (*Pub) Encode

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

func (*Pub) FromPubBytes

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

FromPubBytes creates a public key object from the public key bytes

func (*Pub) GetBytes

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

GetBytes returns the bytes that make up the header

func (*Pub) GetID

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

GetID returns the header id for this header

func (*Pub) GetIndex

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

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

func (*Pub) GetMsgID

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

GetMsgID returns the MsgID for this specific header (see MsgID definition for more details)

func (*Pub) GetPubBytes

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

GetPubBytes returns the key we use to sign/verify

func (*Pub) GetPubID

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

GetPubID returns the id of the public key (see type definition for PubKeyID).

func (*Pub) GetPubString

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

GetPubString is the same as GetPubBytes, except returns a string, this is used to sort the keys

func (*Pub) GetRealPubBytes

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

GetRealPubBytes is the same as GetPubBytes

func (*Pub) GetSigMemberNumber

func (pub *Pub) GetSigMemberNumber() int

GetSigMemberNumber returns the number of members this sig counts for (can be > 1 for multisigs and threshold sigs)

func (*Pub) New

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

New creates a new public key object of the same type

func (*Pub) PeekHeaders

func (pub *Pub) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)

PeekHeaders returns nil

func (*Pub) Serialize

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

Serialize appends a serialized header to the message m, and returns the size of bytes written

func (*Pub) SetIndex

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

SetIndex should be called after sorting all if the benchmark is using the index as the key id (see SetUsePubIndex)

func (*Pub) ShallowCopy

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

func (*Pub) VerifySig

func (pub *Pub) VerifySig(msg sig.SignedMessage, aSig sig.Sig) (bool, error)

VerifySig verifies a signature, returns (true, nil) if valid, (false, nil) if invalid, or (false, error) if there was an error verifying the signature

type Sig

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

func (*Sig) Decode

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

func (*Sig) Deserialize

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

Derserialize updates the fields of the ECDSA signature object from m, and returns the number of bytes read

func (*Sig) Encode

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

func (*Sig) GetBytes

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

GetBytes returns the bytes of the signature from the message

func (*Sig) GetID

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

GetID returns the header id for ECDSA signatures

func (*Sig) GetMsgID

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

GetMsgID returns the message ID for ECDSA sig header

func (*Sig) GetRand

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

GetRand returns a random binary from the signature if supported.

func (*Sig) New

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

New creates a new empty signature object

func (*Sig) PeekHeaders

func (*Sig) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)

PeekHeader returns the indices related to the messages without impacting m.

func (*Sig) Serialize

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

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

type SleepPriv

type SleepPriv interface {
	sig.Priv
	IsSleepPriv()
	// contains filtered or unexported methods
}

type Thrsh

type Thrsh struct {
	SleepPriv // the partial public key for this node
	// contains filtered or unexported fields
}

func (*Thrsh) CombinePartialSigs

func (bt *Thrsh) CombinePartialSigs(ps []sig.Sig) (*sig.SigItem, error)

CombinePartialSigs generates a shared signature from the list of partial signatures.

func (*Thrsh) GetN

func (bt *Thrsh) GetN() int

func (*Thrsh) GetPartialPub

func (bt *Thrsh) GetPartialPub() sig.Pub

func (*Thrsh) GetPrivForSignType

func (bt *Thrsh) GetPrivForSignType(signType types.SignType) (sig.Priv, error)

Returns key that is used for signing the sign type.

func (*Thrsh) GetSharedPub

func (bt *Thrsh) GetSharedPub() sig.Pub

func (*Thrsh) GetT

func (bt *Thrsh) GetT() int

func (*Thrsh) PartialSign

func (bt *Thrsh) PartialSign(msg sig.SignedMessage) (sig.Sig, error)

PartialSign creates a signature on the message that can also be used to create a shared signature.

func (*Thrsh) ShallowCopy

func (bt *Thrsh) ShallowCopy() sig.Priv

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

type VRFProof

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

func (*VRFProof) Decode

func (prf *VRFProof) Decode(reader io.Reader) (n int, err error)

func (*VRFProof) Encode

func (prf *VRFProof) Encode(writer io.Writer) (n int, err error)

func (*VRFProof) New

func (prf *VRFProof) New() sig.VRFProof

type VrfPriv

type VrfPriv struct {
	SleepPriv
	// contains filtered or unexported fields
}

func (*VrfPriv) Evaluate

func (p *VrfPriv) Evaluate(m sig.SignedMessage) (index [32]byte, proof sig.VRFProof)

Evaluate generates a vrf. The index and thee first 32 bytes are the same. They are the hash of the key index and the message.

func (*VrfPriv) GetPrivForSignType

func (p *VrfPriv) GetPrivForSignType(types.SignType) (sig.Priv, error)

Returns key that is used for signing the sign type.

func (*VrfPriv) ShallowCopy

func (p *VrfPriv) ShallowCopy() sig.Priv

type VrfPub

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

func (*VrfPub) DeserializeSig

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

DeserializeSig deserializes a public key and signature object from m, size is the number of bytes read

func (*VrfPub) FromPubBytes

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

FromPubBytes creates a public key object from the public key bytes

func (*VrfPub) New

func (p *VrfPub) New() sig.Pub

New creates an empty sleep private key object

func (*VrfPub) NewVRFProof

func (vrfPub *VrfPub) NewVRFProof() sig.VRFProof

NewVRFProof returns an empty VRFProof object

func (*VrfPub) ProofToHash

func (pub *VrfPub) ProofToHash(msg sig.SignedMessage, proof sig.VRFProof) (index [32]byte, err error)

ProofToHash checks the VRF for the message and returns the random bytes if valid

func (*VrfPub) ShallowCopy

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

Jump to

Keyboard shortcuts

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