Skip to content

Conversation

@danielradu10
Copy link

No description provided.


const blsHashSize = 16

//"message to be signed or to be verified is nil"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment on lines 60 to 91
// 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
}
Copy link
Contributor

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

Copy link
Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var keys []Key
keys := make([]Key, 0, grSize)

small optimization

Copy link
Author

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")
Copy link
Contributor

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

Copy link
Author

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)
Copy link
Contributor

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

Copy link
Author

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 {
Copy link
Contributor

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?

Copy link
Author

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

Comment on lines 41 to 45
testName := testVector.testName
signatures := testVector.signatures
pubKeys := testVector.publicKeys
expectedError := testVector.expectedError
aggregatedSig := testVector.aggregatedSig
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 86 to 89
lls := &BlsMultiSigner{}
hasher, err := blake2b.NewBlake2bWithSize(blsHashSize)
require.Nil(t, err)
lls.Hasher = hasher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 116 to 119
lls := &BlsMultiSigner{}
hasher, err := blake2b.NewBlake2bWithSize(blsHashSize)
require.Nil(t, err)
lls.Hasher = hasher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 168 to 169
var pubKeys []crypto.PublicKey
var sigs [][]byte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var pubKeys []crypto.PublicKey
var sigs [][]byte
pubKeys := make([]crypto.PublicKey, 0, len(signatures))
sigs := make([][]byte, 0, len(signatures))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@AdoAdoAdo AdoAdoAdo changed the base branch from main to feat/test-vectors September 13, 2024 13:02
}

// predefinedKOSKAggregateSignaturesTests defines the scenarios for testing the AggregateSignatures for KOSK
var predefinedKOSKAggregateSignaturesTests = []PredefinedTest{
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


for _, testVector := range jsonContent.TestVectors {

testName := testVector.TestName
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@sstanculeanu sstanculeanu merged commit 0fecdb8 into feat/test-vectors Sep 20, 2024
@sstanculeanu sstanculeanu deleted the multisig-test-vectors branch September 20, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants