Documentation ¶
Overview ¶
Package bgls implements bls signatures, as described by Short Signatures from the Weil Pairing. In this library, an aggregate signature refers to an aggregation of signatures on different messages into a single signature. A multi signature refers to an aggregation of signatures on the same message into the same signature. The difference is that a multi signature can be verified quite quickly, using 2 pairing operations regardless of the number of signers, whereas an aggregate signature requires n+1 pairing operations.
There are three different methods to protect against the rogue public key attack. The three methods are proving knowledge of secret key (kosk), enforcing that all messages are distinct (Distinct Message), and using a hash of the public keys to create exponents that are used in aggregation (Hashed Aggregation Exponents - HAE). These are all described in https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html, where HAE is Dan Boneh's new method introduced in that article.
Proof of knowledge of the secret key is done in this library through doing a BLS signature on the public key itself as a message. See blsKosk.go for more details. Note that this Kosk method is not interoperable with 'plain' bls due to design choices explained in blsKosk.go
BLS with distinct messages is done in this library by prepending the public key to each message, before signing, to ensure that it each message is unique. (thereby circumventing rogue public key attacks). See blsDistinctMessage.go for more details. Note that BLS with distinct messages does not offer multi sigs in their efficiently computable form where only 2 pairings are required.
The third method for preventing the rogue public key attack is explained in in blsHAE.go, and in Boneh's paper. The method for hashing public keys to the exponents is to write them to blake2x, and then to squeeze the corresponding amount of output from the XOF.
Index ¶
- func AggregateKeys(keys []Point) Point
- func AggregateSignatures(sigs []Point) Point
- func AggregateSignaturesWithHAE(sigs []Point, pubkeys []Point) Point
- func Authenticate(curve CurveSystem, sk *big.Int) Point
- func AuthenticateCustHash(curve CurveSystem, sk *big.Int, hash func([]byte) Point) Point
- func CheckAuthentication(curve CurveSystem, pubkey Point, authentication Point) bool
- func CheckAuthenticationCustHash(curve CurveSystem, pubkey Point, authentication Point, hash func([]byte) Point) bool
- func DistinctMsgSign(curve CurveSystem, sk *big.Int, m []byte) Point
- func DistinctMsgSignCustHash(curve CurveSystem, sk *big.Int, msg []byte, hash func([]byte) Point) Point
- func DistinctMsgVerifyAggregateSignature(curve CurveSystem, aggsig Point, keys []Point, msgs [][]byte) bool
- func DistinctMsgVerifySingleSignature(curve CurveSystem, sig Point, pubkey Point, m []byte) bool
- func KeyGen(curve CurveSystem) (*big.Int, Point, error)
- func KoskSign(curve CurveSystem, sk *big.Int, msg []byte) Point
- func KoskSignCustHash(curve CurveSystem, sk *big.Int, msg []byte, hash func([]byte) Point) Point
- func KoskVerifyAggregateSignature(curve CurveSystem, aggsig Point, keys []Point, msgs [][]byte) bool
- func KoskVerifyMultiSignature(curve CurveSystem, aggsig Point, keys []Point, msg []byte) bool
- func KoskVerifyMultiSignatureWithMultiplicity(curve CurveSystem, aggsig Point, keys []Point, multiplicity []int64, ...) bool
- func KoskVerifySingleSignature(curve CurveSystem, sig Point, pubKey Point, msg []byte) bool
- func KoskVerifySingleSignatureCustHash(curve CurveSystem, pubKey Point, msg []byte, sig Point, ...) bool
- func LoadPublicKey(curve CurveSystem, sk *big.Int) Point
- func Sign(curve CurveSystem, sk *big.Int, msg []byte) Point
- func SignCustHash(sk *big.Int, msg []byte, hash func([]byte) Point) Point
- func VerifyAggregateSignature(curve CurveSystem, aggsig Point, keys []Point, msgs [][]byte) bool
- func VerifyAggregateSignatureWithHAE(curve CurveSystem, aggsig Point, pubkeys []Point, msgs [][]byte) bool
- func VerifyMultiSignatureWithHAE(curve CurveSystem, aggsig Point, pubkeys []Point, msg []byte) bool
- func VerifySingleSignature(curve CurveSystem, sig Point, pubKey Point, msg []byte) bool
- func VerifySingleSignatureCustHash(curve CurveSystem, sig Point, pubkey Point, msg []byte, ...) bool
- type AggSig
- type MultiSig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregateKeys ¶
func AggregateKeys(keys []Point) Point
AggregateKeys sums an array of public keys into one key. This wrapper only exists so end-users don't have to use the method from curve
func AggregateSignatures ¶
func AggregateSignatures(sigs []Point) Point
AggregateSignatures aggregates an array of signatures into one aggsig. This wrapper only exists so end-users don't have to use the method from curves
func AggregateSignaturesWithHAE ¶
func AggregateSignaturesWithHAE(sigs []Point, pubkeys []Point) Point
AggregateSignaturesWithHAE aggregates the signatures, using the hashed exponents derived from the pubkeys to protect against the rogue public key attack.
func Authenticate ¶
Authenticate generates an Aggregatable Authentication for a given secret key. It signs the public key generated from sk, with a 0x01 byte prepended to it.
func AuthenticateCustHash ¶
AuthenticateCustHash generates an Aggregatable Authentication for a given secret key. It signs the public key generated from sk, with a null byte prepended to it. This runs with the specified hash function.
func CheckAuthentication ¶
func CheckAuthentication(curve CurveSystem, pubkey Point, authentication Point) bool
CheckAuthentication verifies that the provided signature is in fact authentication for this public key.
func CheckAuthenticationCustHash ¶
func CheckAuthenticationCustHash(curve CurveSystem, pubkey Point, authentication Point, hash func([]byte) Point) bool
CheckAuthenticationCustHash verifies that the provided signature is in fact authentication for this public key.
func DistinctMsgSign ¶
DistinctMsgSign creates a signature on a message with a private key, with prepending the public key to the message.
func DistinctMsgSignCustHash ¶
func DistinctMsgSignCustHash(curve CurveSystem, sk *big.Int, msg []byte, hash func([]byte) Point) Point
DistinctMsgSignCustHash creates a signature on a message with a private key, using a supplied function to hash to g1.
func DistinctMsgVerifyAggregateSignature ¶
func DistinctMsgVerifyAggregateSignature(curve CurveSystem, aggsig Point, keys []Point, msgs [][]byte) bool
DistinctMsgVerifyAggregateSignature checks that an aggsig was generated from the the provided set of public key / msg pairs, when the messages are signed using the 'Distinct Message' method.
func DistinctMsgVerifySingleSignature ¶
DistinctMsgVerifySingleSignature checks that a single 'Distinct Message' signature is valid
func KoskSign ¶
KoskSign creates a kosk signature on a message with a private key. A kosk signature prepends a 0x01 byte to the message before signing.
func KoskSignCustHash ¶
KoskSignCustHash creates a kosk signature on a message with a private key, using a supplied function to hash to point. A kosk signature prepends a 0x01 byte to the message before signing.
func KoskVerifyAggregateSignature ¶
func KoskVerifyAggregateSignature(curve CurveSystem, aggsig Point, keys []Point, msgs [][]byte) bool
KoskVerifyAggregateSignature verifies that the aggregated signature proves that all messages were signed by the associated keys.
func KoskVerifyMultiSignature ¶
KoskVerifyMultiSignature checks that the aggregate signature correctly proves that a single message has been signed by a set of keys, vulnerable against chosen key attack, if keys have not been authenticated
func KoskVerifyMultiSignatureWithMultiplicity ¶
func KoskVerifyMultiSignatureWithMultiplicity(curve CurveSystem, aggsig Point, keys []Point, multiplicity []int64, msg []byte) bool
KoskVerifyMultiSignatureWithMultiplicity verifies a BLS multi signature where multiple copies of each signature may have been included in the aggregation
func KoskVerifySingleSignature ¶
KoskVerifySingleSignature checks that a single kosk signature is valid.
func KoskVerifySingleSignatureCustHash ¶
func KoskVerifySingleSignatureCustHash(curve CurveSystem, pubKey Point, msg []byte, sig Point, hash func([]byte) Point) bool
KoskVerifySingleSignatureCustHash checks that a single kosk signature is valid, with the supplied hash function.
func LoadPublicKey ¶
LoadPublicKey turns secret key into a public key of type Point2
func SignCustHash ¶
SignCustHash creates a standard BLS signature on a message with a private key, using a supplied function to hash onto the curve where signatures lie.
func VerifyAggregateSignature ¶
VerifyAggregateSignature verifies that the aggregated signature proves that all messages were signed by the associated keys. This will fail if there are duplicate messages, due to the possibility of the rogue public-key attack. If duplicate messages should be allowed, one of the protections against the rogue public-key attack should be used. See doc.go for more details.
func VerifyAggregateSignatureWithHAE ¶
func VerifyAggregateSignatureWithHAE(curve CurveSystem, aggsig Point, pubkeys []Point, msgs [][]byte) bool
VerifyAggregateSignatureWithHAE verifies signatures of different messages aggregated with HAE.
func VerifyMultiSignatureWithHAE ¶
VerifyMultiSignatureWithHAE verifies signatures of the same message aggregated with HAE.
func VerifySingleSignature ¶
VerifySingleSignature checks that a single standard BLS signature is valid
func VerifySingleSignatureCustHash ¶
func VerifySingleSignatureCustHash(curve CurveSystem, sig Point, pubkey Point, msg []byte, hash func([]byte) Point) bool
VerifySingleSignatureCustHash checks that a single standard BLS signature is valid, using the supplied hash function to hash onto the curve where signatures lie.
Types ¶
type AggSig ¶
type AggSig struct {
// contains filtered or unexported fields
}
AggSig holds paired sequences of keys and messages, and one signature