Documentation
¶
Index ¶
- Variables
- func CalcThreshold(n int) int
- func GetAccount(pubk []byte) []byte
- func Hasher(data ...[]byte) []byte
- type BNGroupSigner
- func (bns *BNGroupSigner) Aggregate(sigs [][]byte, groupShares [][]byte) ([]byte, error)
- func (bns *BNGroupSigner) PubkeyGroup() ([]byte, error)
- func (bns *BNGroupSigner) PubkeyShare() ([]byte, error)
- func (bns *BNGroupSigner) SetGroupPubk(groupPubk []byte) error
- func (bns *BNGroupSigner) SetPrivk(privk []byte)
- func (bns *BNGroupSigner) Sign(msg []byte) ([]byte, error)
- func (bns *BNGroupSigner) VerifyGroupShares(groupShares [][]byte) error
- type BNGroupValidator
- type BNSigner
- type BNValidator
- type Secp256k1Signer
- type Secp256k1Validator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPubkeyGroupNotSet occurs when the group public key // (master public key [mpk]) has not been set ErrPubkeyGroupNotSet = errors.New("groupPubk not set") // ErrPrivkNotSet occurs when the private key has not been set ErrPrivkNotSet = errors.New("privk not set") // ErrInvalidSignature occurs when signature validation fails ErrInvalidSignature = errors.New("signature validation failed") // key are contained when attempting to set GroupShares. ErrInvalidPubkeyShares = errors.New("groupShares contains repeated public keys") )
Functions ¶
func CalcThreshold ¶
CalcThreshold returns the correct definition of threshold. With this definition, t+1 participants form a BFT subset. This ensures
t <= 2/3*n and t + 1 > 2/3*n
func GetAccount ¶
GetAccount returns the account, which corresponds to the rightmost 20 bytes of the hash of the public key.
Types ¶
type BNGroupSigner ¶
type BNGroupSigner struct {
// contains filtered or unexported fields
}
BNGroupSigner creates cryptographic signatures using the bn256 curve.
func (*BNGroupSigner) Aggregate ¶
func (bns *BNGroupSigner) Aggregate(sigs [][]byte, groupShares [][]byte) ([]byte, error)
Aggregate attempts to combine the slice of signatures in sigs into a group signature.
func (*BNGroupSigner) PubkeyGroup ¶
func (bns *BNGroupSigner) PubkeyGroup() ([]byte, error)
PubkeyGroup returns the marshalled public key of the group (master public key).
func (*BNGroupSigner) PubkeyShare ¶
func (bns *BNGroupSigner) PubkeyShare() ([]byte, error)
PubkeyShare returns the marshalled public key of the BNGroupSigner
func (*BNGroupSigner) SetGroupPubk ¶
func (bns *BNGroupSigner) SetGroupPubk(groupPubk []byte) error
SetGroupPubk will set the public key of the entire group; this is also called the master public key.
func (*BNGroupSigner) SetPrivk ¶
func (bns *BNGroupSigner) SetPrivk(privk []byte)
SetPrivk sets the private key of the BNGroupSigner.
func (*BNGroupSigner) Sign ¶
func (bns *BNGroupSigner) Sign(msg []byte) ([]byte, error)
Sign will generate a signature for msg using the private key of the BNGroupSigner; this signature can be aggregated to form a valid group signature.
func (*BNGroupSigner) VerifyGroupShares ¶
func (bns *BNGroupSigner) VerifyGroupShares(groupShares [][]byte) error
VerifyGroupShares checks groupShares to ensure that it can be used as a valid ordering of the validators to correctly compute valid group signatures.
We first check to make sure that each public key is a valid element of bn256.G2. From there, we also check to make sure that the byte slice did not appear in a previous position; to do this, we use a hash map.
type BNGroupValidator ¶
type BNGroupValidator struct { }
BNGroupValidator is the object that performs cryptographic validation of BNGroupSigner signatures.
func (*BNGroupValidator) PubkeyFromSig ¶
func (bnv *BNGroupValidator) PubkeyFromSig(sig []byte) ([]byte, error)
PubkeyFromSig returns the public key of the signer from the signature.
type BNSigner ¶
type BNSigner struct {
// contains filtered or unexported fields
}
BNSigner creates cryptographic signatures using the bn256 curve.
type BNValidator ¶
type BNValidator struct { }
BNValidator is the object that performs cryptographic validation of BNSigner signatures.
func (*BNValidator) PubkeyFromSig ¶
func (bnv *BNValidator) PubkeyFromSig(sig []byte) ([]byte, error)
PubkeyFromSig returns the public key of the signer from the signature.
type Secp256k1Signer ¶
type Secp256k1Signer struct {
// contains filtered or unexported fields
}
Secp256k1Signer creates cryptographic signatures using the secp256k1 curve.
func (*Secp256k1Signer) Pubkey ¶
func (secps *Secp256k1Signer) Pubkey() ([]byte, error)
Pubkey returns the marshalled public key of the Secp256k1Signer (uncompressed format).
func (*Secp256k1Signer) SetPrivk ¶
func (secps *Secp256k1Signer) SetPrivk(privk []byte) error
SetPrivk sets the private key of the Secp256k1Signer; privk is required to be 32 bytes!
type Secp256k1Validator ¶
type Secp256k1Validator struct { }
Secp256k1Validator is a struct which allows for validation of cryptographic signatures from Secp256k1Signer.
func (*Secp256k1Validator) PubkeyFromSig ¶
func (secpv *Secp256k1Validator) PubkeyFromSig(msg []byte, sig []byte) ([]byte, error)
PubkeyFromSig returns the public key of the signer from the signature and message.