ec

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

View Source
var Stats = sig.SigStats{
	PubSize:       65,
	SigSize:       73,
	VRFSize:       129,
	SigVerifyTime: 86693,
	SignTime:      34126,
	VRFGenTime:    256468,
	VRFVerifyTime: 324876,
	AllowsVRF:     true,
}

Functions

func NewEcpriv

func NewEcpriv() (sig.Priv, error)

NewEcpriv creates a new random ECDSA private key object

Types

type Ecpriv

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

Ecpriv represents the ECDSA private key object

func (*Ecpriv) Clean

func (priv *Ecpriv) Clean()

Clean does nothing

func (*Ecpriv) ComputeSharedSecret

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

ComputeSharedSecret returns the hash of Diffie-Hellman.

func (*Ecpriv) Deserialize

func (priv *Ecpriv) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)

func (*Ecpriv) Evaluate

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

Evaluate is for generating VRFs.

func (*Ecpriv) GenerateSig

func (priv *Ecpriv) 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 (*Ecpriv) GetBaseKey

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

GetBaseKey returns the same key.

func (*Ecpriv) GetBytes

func (priv *Ecpriv) GetBytes(m *messages.Message) ([]byte, error)

func (*Ecpriv) GetID

func (priv *Ecpriv) GetID() messages.HeaderID

func (*Ecpriv) GetMsgID

func (priv *Ecpriv) GetMsgID() messages.MsgID

func (*Ecpriv) GetPrivForSignType

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

Returns key that is used for signing the sign type.

func (*Ecpriv) GetPub

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

GetPub returns the coreesponding ECDSA public key object

func (*Ecpriv) New

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

New creates an empty ECDSA private key object

func (*Ecpriv) NewSig

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

NewSig returns an empty sig object of the same type.

func (Ecpriv) PeekHeaders

PeekHeader returns nil.

func (*Ecpriv) Serialize

func (priv *Ecpriv) Serialize(m *messages.Message) (int, error)

func (*Ecpriv) SetIndex

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

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

func (*Ecpriv) ShallowCopy

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

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

func (*Ecpriv) Sign

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

Sign signs a message and returns the signature.

type Ecpub

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

Ecpub represents an ECDSA public key

func (*Ecpub) CheckSignature

func (pub *Ecpub) 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 (*Ecpub) Decode

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

func (*Ecpub) Deserialize

func (pub *Ecpub) 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 (*Ecpub) DeserializeSig

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

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

func (*Ecpub) Encode

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

func (*Ecpub) FromPubBytes

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

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

func (*Ecpub) GetBytes

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

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

func (*Ecpub) GetID

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

GetID returns the header id for ECDSA pub objects

func (*Ecpub) GetIndex

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

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

func (*Ecpub) GetMsgID

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

GetMsgID returns the message id for an ECDSA public key

func (*Ecpub) GetPubBytes

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

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

func (*Ecpub) GetPubID

func (pub *Ecpub) 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 (*Ecpub) GetPubString

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

GetPubString is the same as GetPubBytes, except returns a string

func (*Ecpub) GetRealPubBytes

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

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

func (*Ecpub) GetSigMemberNumber

func (pub *Ecpub) GetSigMemberNumber() int

GetSigMemberNumber always returns one since ECDSA signautres can only represent a single signer

func (*Ecpub) New

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

New returns a blank ECDSA public key object

func (*Ecpub) NewVRFProof

func (pub *Ecpub) NewVRFProof() sig.VRFProof

NewVRFProof returns an empty VRFProof object, and is not supported for ed.

func (*Ecpub) PeekHeaders

PeekHeader returns nil.

func (*Ecpub) ProofToHash

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

ProofToHash is for validating VRFs.

func (*Ecpub) Serialize

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

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

func (*Ecpub) SetIndex

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

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

func (*Ecpub) ShallowCopy

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

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

func (*Ecpub) VerifySig

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

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

type Ecsig

type Ecsig struct {
	R *big.Int
	S *big.Int
}

Ecsig is the object representing an ECDSA signature

func (*Ecsig) Corrupt

func (sig *Ecsig) Corrupt()

Corrupt invlidates an ECDSA signature object

func (*Ecsig) Decode

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

func (*Ecsig) Deserialize

func (sig *Ecsig) 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 (*Ecsig) Encode

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

func (*Ecsig) GetBytes

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

GetBytes returns the bytes of the signature from the message

func (*Ecsig) GetID

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

GetID returns the header id for ECDSA signatures

func (*Ecsig) GetMsgID

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

GetMsgID returns the message ID for ECDSA sig header

func (*Ecsig) New

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

New creates a new blank ECDSA signature object

func (*Ecsig) PeekHeaders

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

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

func (*Ecsig) Serialize

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

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

type VRFProof

type VRFProof []byte

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

Jump to

Keyboard shortcuts

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