-
Notifications
You must be signed in to change notification settings - Fork 6
multisig-test-vectors #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| const blsHashSize = 16 | ||
|
|
||
| //"message to be signed or to be verified is nil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
| // KeyPair defines a pair of public key and private key | ||
| type KeyPair struct { | ||
| PublicKey string `json:"publicKey"` | ||
| PrivateKey string `json:"privateKey"` | ||
| } | ||
|
|
||
| // SignaturePair defines a pair of signature and public key | ||
| type SignaturePair struct { | ||
| Signature string `json:"signature"` | ||
| PublicKey string `json:"publicKey"` | ||
| } | ||
|
|
||
| // TestVectorElement defines the data for a test vector | ||
| type TestVectorElement struct { | ||
| Signatures []SignaturePair `json:"signatures"` | ||
| Message string `json:"message"` | ||
| AggregatedSignature string `json:"aggregatedSignature"` | ||
| ErrorMessage string `json:"errorMessage"` | ||
| TestName string `json:"testName"` | ||
| } | ||
|
|
||
| // JSONFileContent defines the data for generating the json file | ||
| type JSONFileContent struct { | ||
| Keys []KeyPair `json:"keys"` | ||
| TestVectors []TestVectorElement `json:"testVectors"` | ||
| } | ||
|
|
||
| // Key defines a tuple of public key and private key | ||
| type Key struct { | ||
| PubKey crypto.PublicKey | ||
| PrivateKey crypto.PrivateKey | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps extract all exported structs to a new file, data.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new file added
|
|
||
| func createKeyPairs(grSize uint16, suite crypto.Suite) []Key { | ||
| kg := signing.NewKeyGenerator(suite) | ||
| var keys []Key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var keys []Key | |
| keys := make([]Key, 0, grSize) |
small optimization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
|
||
| // generateJSONFileKOSKForAggregateSignaturesTests for KOSK AggregateSignaturesTests | ||
| func generateJSONFileKOSKForAggregateSignaturesTests(signer crypto.LowLevelSignerBLS) error { | ||
| return generateJSONFile(signer, predefinedKOSKAggregateSignaturesTests, "multisigKOSKAggSig.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json files should be generated and moved into a special directory, testData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a special directory named testData and moved the json file
| func generateJSONFile(lls crypto.LowLevelSignerBLS, predefinedTests []PredefinedTest, filename string) error { | ||
| suite := mcl.NewSuiteBLS12() | ||
|
|
||
| mapKeys := createKeyPairs(uint16(5), suite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps extract the number of keys as parameter as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| ) | ||
|
|
||
| // TestVector defines the data structure used to unmarshal the JSON file | ||
| type TestVector struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the already defined structure from jsonGenerator.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the one from jsonGenerator.go is a struct of strings, and I need all the data to be decoded
signing/mcl/multisig/vectors_test.go
Outdated
| testName := testVector.testName | ||
| signatures := testVector.signatures | ||
| pubKeys := testVector.publicKeys | ||
| expectedError := testVector.expectedError | ||
| aggregatedSig := testVector.aggregatedSig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new vars not necessarily needed
valid for all tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
signing/mcl/multisig/vectors_test.go
Outdated
| lls := &BlsMultiSigner{} | ||
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | ||
| require.Nil(t, err) | ||
| lls.Hasher = hasher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| lls := &BlsMultiSigner{} | |
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | |
| require.Nil(t, err) | |
| lls.Hasher = hasher | |
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | |
| require.Nil(t, err) | |
| lls := &BlsMultiSigner{ | |
| Hasher: hasher, | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
signing/mcl/multisig/vectors_test.go
Outdated
| lls := &BlsMultiSigner{} | ||
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | ||
| require.Nil(t, err) | ||
| lls.Hasher = hasher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| lls := &BlsMultiSigner{} | |
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | |
| require.Nil(t, err) | |
| lls.Hasher = hasher | |
| hasher, err := blake2b.NewBlake2bWithSize(blsHashSize) | |
| require.Nil(t, err) | |
| lls := &BlsMultiSigner{ | |
| Hasher: hasher, | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
signing/mcl/multisig/vectors_test.go
Outdated
| var pubKeys []crypto.PublicKey | ||
| var sigs [][]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var pubKeys []crypto.PublicKey | |
| var sigs [][]byte | |
| pubKeys := make([]crypto.PublicKey, 0, len(signatures)) | |
| sigs := make([][]byte, 0, len(signatures)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| } | ||
|
|
||
| // predefinedKOSKAggregateSignaturesTests defines the scenarios for testing the AggregateSignatures for KOSK | ||
| var predefinedKOSKAggregateSignaturesTests = []PredefinedTest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these structures at lines 15, 24, 33, 42 are very similar (duplicated). We can keep only one definition (rename it to something more generic) and use it for the different test vectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
signing/mcl/multisig/vectors_test.go
Outdated
|
|
||
| for _, testVector := range jsonContent.TestVectors { | ||
|
|
||
| testName := testVector.TestName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you extract the lines 149 -> 175 into a function that creates a TestVector instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
No description provided.