prysm-pulse/crypto/bls/signature_set_test.go
terence tsao ee5d75732d
Add pkg crypto (#9603)
* Add pkg crypto

* Update go.yml

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-09-15 22:55:11 +00:00

47 lines
1.1 KiB
Go

package bls
import (
"testing"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
)
func TestCopySignatureSet(t *testing.T) {
t.Run("blst", func(t *testing.T) {
key, err := RandKey()
assert.NoError(t, err)
key2, err := RandKey()
assert.NoError(t, err)
key3, err := RandKey()
assert.NoError(t, err)
message := [32]byte{'C', 'D'}
message2 := [32]byte{'E', 'F'}
message3 := [32]byte{'H', 'I'}
sig := key.Sign(message[:])
sig2 := key2.Sign(message2[:])
sig3 := key3.Sign(message3[:])
set := &SignatureSet{
Signatures: [][]byte{sig.Marshal()},
PublicKeys: []PublicKey{key.PublicKey()},
Messages: [][32]byte{message},
}
set2 := &SignatureSet{
Signatures: [][]byte{sig2.Marshal()},
PublicKeys: []PublicKey{key.PublicKey()},
Messages: [][32]byte{message},
}
set3 := &SignatureSet{
Signatures: [][]byte{sig3.Marshal()},
PublicKeys: []PublicKey{key.PublicKey()},
Messages: [][32]byte{message},
}
aggSet := set.Join(set2).Join(set3)
aggSet2 := aggSet.Copy()
assert.DeepEqual(t, aggSet, aggSet2)
})
}