@@ -542,35 +542,37 @@ func verifyClusterValidators(t *testing.T, numVals int, nodeDirs []string) { //n
542542 }
543543
544544 data := []byte ("test data" )
545- allSigs := make ([][ ]tbls.Signature , numVals )
546- clusterPubKeys := make ([] []tbls.PublicKey , numVals )
545+ allSigs := make ([]map [ int ]tbls.Signature , numVals )
546+ validatorPubKeys := make ([]tbls.PublicKey , numVals )
547547
548548 for valIdx := range numVals {
549- sigs := make ([ ]tbls.Signature , numNodes )
549+ sigsByIdx := make (map [ int ]tbls.Signature )
550550
551551 for nodeIdx := range numNodes {
552552 sig , err := tbls .Sign (clusterSecrets [nodeIdx ][valIdx ], data )
553553 require .NoError (t , err )
554554
555- sigs [nodeIdx ] = sig
555+ // Use 1-based share indices as production does
556+ sigsByIdx [nodeIdx + 1 ] = sig
556557 }
557558
558- allSigs [valIdx ] = sigs
559- clusterPubKeys [valIdx ] = make ([]tbls.PublicKey , numNodes )
559+ allSigs [valIdx ] = sigsByIdx
560560
561- for nodeIdx := range numNodes {
562- pubKey , err := tbls .SecretToPublicKey (clusterSecrets [nodeIdx ][valIdx ])
563- require .NoError (t , err )
561+ // Get the validator's full public key for verification
562+ lockFilePath := path .Join (nodeDirs [0 ], clusterLockFile )
563+ lock , err := dkg .LoadAndVerifyClusterLock (t .Context (), lockFilePath , "" , false )
564+ require .NoError (t , err )
564565
565- clusterPubKeys [valIdx ][nodeIdx ] = pubKey
566- }
566+ validatorPubKeys [valIdx ] = tbls .PublicKey (lock .Validators [valIdx ].PubKey )
567567 }
568568
569569 for valIdx := range numVals {
570- aSig , err := tbls .Aggregate (allSigs [valIdx ])
570+ // Use ThresholdAggregate (Lagrange interpolation) instead of simple Aggregate
571+ // to ensure share indices are correct - this is what production uses.
572+ aSig , err := tbls .ThresholdAggregate (allSigs [valIdx ])
571573 require .NoError (t , err )
572574
573- err = tbls .VerifyAggregate ( clusterPubKeys [valIdx ], aSig , data )
575+ err = tbls .Verify ( validatorPubKeys [valIdx ], data , aSig )
574576 require .NoError (t , err )
575577 }
576578}
0 commit comments