Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAggSigNotValid = errors.New("aggregate signature is invalid")
ErrAggSigNotValid is raised when an aggregate signature is invalid
var ErrBitmapMismatch = errors.New("multi signer reported a mismatch in used bitmap")
ErrBitmapMismatch is raised when an invalid bitmap is passed to the multisigner
var ErrBitmapNotSet = errors.New("bitmap is not set")
ErrBitmapNotSet is raised when a cleared bitmap is used
var ErrEmptyPubKeyString = errors.New("public key string is empty")
ErrEmptyPubKeyString is raised when an empty public key string is used
var ErrIndexNotSelected = errors.New("index is not selected")
ErrIndexNotSelected is raised when a not selected index is used for multi-signing
var ErrIndexOutOfBounds = errors.New("index is out of bounds")
ErrIndexOutOfBounds is raised when an out of bound index is used
var ErrInvalidParam = errors.New("parameter is invalid")
ErrInvalidParam is raised for invalid parameters
var ErrInvalidPrivateKey = errors.New("private key is invalid")
ErrInvalidPrivateKey is raised when an invalid private key is used
var ErrInvalidPublicKey = errors.New("public key is invalid")
ErrInvalidPublicKey is raised when an invalid public key is used
var ErrInvalidPublicKeyString = errors.New("invalid public key string")
ErrInvalidPublicKeyString is raised when an invalid serialization for a public key is used
var ErrInvalidScalar = errors.New("scalar is invalid")
ErrInvalidScalar is raised when an invalid scalar is used
var ErrInvalidSigner = errors.New("signer is invalid")
ErrInvalidSigner is raised when the signer is invalid
var ErrInvalidSuite = errors.New("crypto suite is invalid")
ErrInvalidSuite is raised when an invalid crypto suite is used
var ErrNilAggregatedCommitment = errors.New("aggregated commitment is nil")
ErrNilAggregatedCommitment is raised when nil aggregated commitment is used
var ErrNilBitmap = errors.New("bitmap is nil")
ErrNilBitmap is raised when a nil bitmap is used
var ErrNilCommitment = errors.New("commitment is nil")
ErrNilCommitment is raised when a nil commitment is used
var ErrNilCommitmentHash = errors.New("commitment hash is nil")
ErrNilCommitmentHash is raised when a nil commitment hash is used
var ErrNilCommitmentSecret = errors.New("commitment secret is nil")
ErrNilCommitmentSecret is raised when a nil commitment secret is used
var ErrNilElement = errors.New("element is nil")
ErrNilElement is raised when searching for a specific element but found nil
var ErrNilHasher = errors.New("hasher is nil")
ErrNilHasher is raised when a valid hasher is expected but used nil
var ErrNilKeyGenerator = errors.New("key generator is nil")
ErrNilKeyGenerator is raised when a valid key generator is expected but nil used
var ErrNilMessage = errors.New("message to be signed or to be verified is nil")
ErrNilMessage is raised when trying to verify a nil signed message or trying to sign a nil message
var ErrNilParam = errors.New("nil parameter")
ErrNilParam is raised for nil parameters
var ErrNilPrivateKey = errors.New("private key is nil")
ErrNilPrivateKey is raised when a private key was expected but received nil
var ErrNilPrivateKeyScalar = errors.New("private key holds a nil scalar")
ErrNilPrivateKeyScalar is raised when a private key with nil scalar is used
var ErrNilPublicKey = errors.New("public key is nil")
ErrNilPublicKey is raised when public key is expected but received nil
var ErrNilPublicKeyPoint = errors.New("public key holds a nil point")
ErrNilPublicKeyPoint is raised when a public key with nil point is used
var ErrNilPublicKeys = errors.New("public keys are nil")
ErrNilPublicKeys is raised when public keys are expected but received nil
var ErrNilSignature = errors.New("signature is nil")
ErrNilSignature is raised for a nil signature
var ErrNilSignaturesList = errors.New("signature list is nil")
ErrNilSignaturesList is raised when a nil list of signatures is provided
var ErrNilSingleSigner = errors.New("single signer is nil")
ErrNilSingleSigner is raised when using a nil single signer
var ErrNilSuite = errors.New("crypto suite is nil")
ErrNilSuite is raised when a nil crypto suite is used
var ErrNoPublicKeySet = errors.New("no public key was set")
ErrNoPublicKeySet is raised when no public key was set for a multisignature
var ErrSigNotValid = errors.New("signature is invalid")
ErrSigNotValid is raised when a signature verification fails due to invalid signature
var ErrWrongSizeHasher = errors.New("wrong size hasher")
ErrWrongSizeHasher is raised when a hasher with a wrong output size is used
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group interface {
// String returns the string for the group
String() string
// ScalarLen returns the maximum length of scalars in bytes
ScalarLen() int
// CreateScalar creates a new Scalar
CreateScalar() Scalar
// PointLen returns the max length of point in nb of bytes
PointLen() int
// CreatePoint creates a new point
CreatePoint() Point
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
Group defines a mathematical group used for Diffie-Hellmann operations adapted from kyber
type Key ¶
type Key interface {
// ToByteArray returns the byte array representation of the key
ToByteArray() ([]byte, error)
// Suite returns the suite used by this key
Suite() Suite
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
Key represents a crypto key - can be either private or public
type KeyGenerator ¶
type KeyGenerator interface {
// GeneratePair creates a (crypto.PrivateKey, crypto.PublicKey) pair to be used for asymmetric cryptography
GeneratePair() (PrivateKey, PublicKey)
// PrivateKeyFromByteArray creates a crypto.PrivateKey from a byte array
PrivateKeyFromByteArray(b []byte) (PrivateKey, error)
// PublicKeyFromByteArray creates a crypto.PublicKey from a byte array
PublicKeyFromByteArray(b []byte) (PublicKey, error)
// Suite returns the crypto.Suite used by the KeyGenerator
Suite() Suite
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
KeyGenerator is an interface for generating different types of cryptographic keys
type LowLevelSignerBLS ¶
type LowLevelSignerBLS interface {
VerifySigShare(pubKey PublicKey, message []byte, sig []byte) error
SignShare(privKey PrivateKey, message []byte) ([]byte, error)
// VerifySigBytes verifies if a byte array represents a BLS signature
VerifySigBytes(suite Suite, sig []byte) error
// AggregateSignatures aggregates BLS single signatures given as byte arrays
AggregateSignatures(suite Suite, sigs ...[]byte) ([]byte, error)
// VerifyAggregatedSig verifies the validity of an aggregated signature over a given message
VerifyAggregatedSig(suite Suite, aggPointsBytes []byte, aggSigBytes []byte, msg []byte) error
// AggregatePublicKeys aggregates a list of public key Points. Returns the byte array representation of the point
AggregatePublicKeys(suite Suite, pubKeys ...Point) ([]byte, error)
// ScalarMulSig provides the result of multiplying a scalar with a signature.
// This is used in the modified BLS multi-signature scheme
ScalarMulSig(suite Suite, scalar Scalar, sig []byte) ([]byte, error)
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
LowLevelSignerBLS provides functionality to sign and verify BLS single/multi-signatures Implementations act as a wrapper over a specific crypto library, such that changing the library requires only writing a new implementation of this LowLevelSigner
type MultiSigVerifier ¶
type MultiSigVerifier interface {
// Create resets the multisigner and initializes to the new params
Create(pubKeys []string, index uint16) (MultiSigner, error)
// SetAggregatedSig sets the aggregated signature
SetAggregatedSig([]byte) error
// Verify verifies the aggregated signature
Verify(msg []byte, bitmap []byte) error
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
MultiSigVerifier provides functionality for verifying a multi-signature
type MultiSigner ¶
type MultiSigner interface {
// MultiSigVerifier Provides functionality for verifying a multi-signature
MultiSigVerifier
// Reset resets the data holder inside the multiSigner
Reset(pubKeys []string, index uint16) error
CreateSignatureShare(msg []byte, bitmap []byte) ([]byte, error)
StoreSignatureShare(index uint16, sig []byte) error
SignatureShare(index uint16) ([]byte, error)
VerifySignatureShare(index uint16, sig []byte, msg []byte, bitmap []byte) error
// AggregateSigs aggregates all collected partial signatures
AggregateSigs(bitmap []byte) ([]byte, error)
}
MultiSigner provides functionality for multi-signing a message and verifying a multi-signed message
type Point ¶
type Point interface {
// MarshalBinary transforms the Point into a byte array
MarshalBinary() ([]byte, error)
// UnmarshalBinary recreates the Point from a byte array
UnmarshalBinary([]byte) error
// Equal tests if receiver is equal with the Point p given as parameter.
// Both Points need to be derived from the same Group
Equal(p Point) (bool, error)
// Null returns the neutral identity element.
Null() Point
// Base returns the Group's base point.
Base() Point
// Set sets the receiver equal to another Point p.
Set(p Point) error
// Clone returns a clone of the receiver.
Clone() Point
// Add returns the result of adding receiver with Point p given as parameter,
// so that their scalars add homomorphically
Add(p Point) (Point, error)
// Sub returns the result of subtracting from receiver the Point p given as parameter,
// so that their scalars subtract homomorphically
Sub(p Point) (Point, error)
// Neg returns the negation of receiver
Neg() Point
// Mul returns the result of multiplying receiver by the scalar s.
Mul(s Scalar) (Point, error)
// Pick returns a fresh random or pseudo-random Point.
Pick(rand cipher.Stream) (Point, error)
// GetUnderlyingObj returns the object the implementation wraps
GetUnderlyingObj() interface{}
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
Point represents an element of a public-key cryptographic Group. adapted from kyber
type PrivateKey ¶
type PrivateKey interface {
Key
// GeneratePublic builds a public key for the current private key
GeneratePublic() PublicKey
// Scalar returns the Scalar corresponding to this Private Key
Scalar() Scalar
}
PrivateKey represents a private key that can sign data or decrypt messages encrypted with a public key
type PublicKey ¶
type PublicKey interface {
Key
// Point returns the Point corresponding to this Public Key
Point() Point
}
PublicKey can be used to encrypt messages
type Random ¶
type Random interface {
// RandomStream returns a cipher.Stream that produces a
// cryptographically random key stream. The stream must
// tolerate being used in multiple goroutines.
RandomStream() cipher.Stream
}
Random is an interface that can be mixed in to local suite definitions. adapted from kyber
type Scalar ¶
type Scalar interface {
// MarshalBinary transforms the Scalar into a byte array
MarshalBinary() ([]byte, error)
// UnmarshalBinary recreates the Scalar from a byte array
UnmarshalBinary([]byte) error
// Equal tests if receiver is equal with the scalar s given as parameter.
// Both scalars need to be derived from the same Group
Equal(s Scalar) (bool, error)
// Set sets the receiver to Scalar s given as parameter
Set(s Scalar) error
// Clone creates a new Scalar with same value as receiver
Clone() Scalar
// SetInt64 sets the receiver to a small integer value v given as parameter
SetInt64(v int64)
// Zero returns the the additive identity (0)
Zero() Scalar
// Add returns the modular sum of receiver with scalar s given as parameter
Add(s Scalar) (Scalar, error)
// Sub returns the modular difference between receiver and scalar s given as parameter
Sub(s Scalar) (Scalar, error)
// Neg returns the modular negation of receiver
Neg() Scalar
// One returns the multiplicative identity (1)
One() Scalar
// Mul returns the modular product of receiver with scalar s given as parameter
Mul(s Scalar) (Scalar, error)
// Div returns the modular division between receiver and scalar s given as parameter
Div(s Scalar) (Scalar, error)
// Inv returns the modular inverse of scalar s given as parameter
Inv(s Scalar) (Scalar, error)
// Pick returns a fresh random or pseudo-random scalar
Pick(rand cipher.Stream) (Scalar, error)
// SetBytes sets the scalar from a byte-slice,
// reducing if necessary to the appropriate modulus.
SetBytes([]byte) (Scalar, error)
// GetUnderlyingObj returns the object the implementation wraps
GetUnderlyingObj() interface{}
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
A Scalar represents a scalar value by which a Point (group element) may be encrypted to produce another Point. adapted from kyber
type SingleSigner ¶
type SingleSigner interface {
// Sign is used to sign a message
Sign(private PrivateKey, msg []byte) ([]byte, error)
// Verify is used to verify a signed message
Verify(public PublicKey, msg []byte, sig []byte) error
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
}
SingleSigner provides functionality for signing a message and verifying a single signed message
type Suite ¶
type Suite interface {
Group
Random
// CreateKeyPair creates a scalar and a point pair that can be used in asymmetric cryptography
CreateKeyPair(cipher.Stream) (Scalar, Point)
// GetUnderlyingSuite returns the library suite that crypto.Suite wraps
GetUnderlyingSuite() interface{}
}
Suite represents the list of functionalities needed by this package. adapted from kyber