2020-07-03 07:38:13 +00:00
|
|
|
package bls
|
|
|
|
|
|
|
|
// SignatureSet refers to the defined set of
|
|
|
|
// signatures and its respective public keys and
|
|
|
|
// messages required to verify it.
|
|
|
|
type SignatureSet struct {
|
2020-09-16 13:28:28 +00:00
|
|
|
Signatures [][]byte
|
2020-07-03 07:38:13 +00:00
|
|
|
PublicKeys []PublicKey
|
|
|
|
Messages [][32]byte
|
|
|
|
}
|
|
|
|
|
2020-07-06 03:09:29 +00:00
|
|
|
// NewSet constructs an empty signature set object.
|
|
|
|
func NewSet() *SignatureSet {
|
|
|
|
return &SignatureSet{
|
2020-09-16 13:28:28 +00:00
|
|
|
Signatures: [][]byte{},
|
2020-07-06 03:09:29 +00:00
|
|
|
PublicKeys: []PublicKey{},
|
|
|
|
Messages: [][32]byte{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-03 07:38:13 +00:00
|
|
|
// Join merges the provided signature set to out current one.
|
2020-07-06 03:09:29 +00:00
|
|
|
func (s *SignatureSet) Join(set *SignatureSet) *SignatureSet {
|
2020-07-03 07:38:13 +00:00
|
|
|
s.Signatures = append(s.Signatures, set.Signatures...)
|
|
|
|
s.PublicKeys = append(s.PublicKeys, set.PublicKeys...)
|
|
|
|
s.Messages = append(s.Messages, set.Messages...)
|
2020-07-06 03:09:29 +00:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify the current signature set using the batch verify algorithm.
|
|
|
|
func (s *SignatureSet) Verify() (bool, error) {
|
|
|
|
return VerifyMultipleSignatures(s.Signatures, s.Messages, s.PublicKeys)
|
2020-07-03 07:38:13 +00:00
|
|
|
}
|