diff --git a/pkg/threshcrypto/pseudo.go b/pkg/threshcrypto/pseudo.go index 5bffaeafd..c9085d888 100644 --- a/pkg/threshcrypto/pseudo.go +++ b/pkg/threshcrypto/pseudo.go @@ -29,7 +29,7 @@ func pseudorandomStream(seed int64) cipher.Stream { // Intended for testing purposes and assuming a static membership known to all nodes, // NodePseudo can be invoked by each Node independently (specifying the same seed, e.g. DefaultPseudoSeed) // and generates the same set of keys for the whole system at each node, obviating the exchange of public keys. -func TBLSPseudo(nodes []t.NodeID, nByz, threshold int, ownID t.NodeID, seed int64) (ThreshCrypto, error) { +func TBLSPseudo(nodes []t.NodeID, threshold int, ownID t.NodeID, seed int64) (ThreshCrypto, error) { // Create a new pseudorandom source from the given seed. randomness := pseudorandomStream(seed) @@ -38,10 +38,7 @@ func TBLSPseudo(nodes []t.NodeID, nByz, threshold int, ownID t.NodeID, seed int6 return nil, fmt.Errorf("own node ID not in node list") } - tcInstances, err := TBLS12381Keygen(nByz, threshold, nodes, randomness) - if err != nil { - return nil, err - } + tcInstances := TBLS12381Keygen(threshold, nodes, randomness) return tcInstances[idx], nil } diff --git a/pkg/threshcrypto/tbls.go b/pkg/threshcrypto/tbls.go index 5ebc31dcf..19c06b15b 100644 --- a/pkg/threshcrypto/tbls.go +++ b/pkg/threshcrypto/tbls.go @@ -45,11 +45,8 @@ func tbls12381Scheme() (pairing.Suite, sign.ThresholdScheme, kyber.Group, kyber. // TBLS12381Keygen constructs a set TBLSInst for a given set of member nodes and threshold T // with nByz byzantine nodes, using the BLS12-381 pairing, with signatures being points on curve G1, // and keys points on curve G2. -func TBLS12381Keygen(nByz, T int, members []t.NodeID, randSource cipher.Stream) ([]*TBLSInst, error) { +func TBLS12381Keygen(T int, members []t.NodeID, randSource cipher.Stream) []*TBLSInst { N := len(members) - if !(nByz < (N+1)/2 && nByz >= 0 && T > nByz) { - return nil, fmt.Errorf("(T, N)-threshold BLS requires 0 <= nByz < N/2, and T > nByz, where nByz is the number of byzantine participants") - } pairing, scheme, sigGroup, keyGroup := tbls12381Scheme() @@ -74,7 +71,7 @@ func TBLS12381Keygen(nByz, T int, members []t.NodeID, randSource cipher.Stream) } } - return instances, nil + return instances } // MarshalTo writes the properties of a TBLSInst to an io.Writer. diff --git a/pkg/threshcrypto/tbls_test.go b/pkg/threshcrypto/tbls_test.go index 7887f88de..27a8389f4 100644 --- a/pkg/threshcrypto/tbls_test.go +++ b/pkg/threshcrypto/tbls_test.go @@ -15,8 +15,7 @@ func TestTBLSHappySmoke(t *testing.T) { N := 5 T := 3 - keys, err := keygen(T-1, T, N) - assert.NoError(t, err) + keys := keygen(T-1, T, N) data := [][]byte{{1, 2, 3, 4, 5}, {4, 2}} @@ -52,8 +51,7 @@ func TestTBLSSadSmoke(t *testing.T) { N := 5 T := 3 - keys, err := keygen(T-1, T, N) - require.NoError(t, err) + keys := keygen(T-1, T, N) data := [][]byte{{1, 2, 3, 4, 5}, {4, 2}} @@ -66,7 +64,7 @@ func TestTBLSSadSmoke(t *testing.T) { } // all of the same share is no good - _, err = keys[0].Recover(data, [][]byte{shares[0], shares[0], shares[0]}) + _, err := keys[0].Recover(data, [][]byte{shares[0], shares[0], shares[0]}) assert.Error(t, err) // too little shares is no good @@ -87,8 +85,7 @@ func TestTBLSMarshalling(t *testing.T) { T := N nByz := (N+1)/2 - 1 - keys, err := keygen(nByz, T, N) - require.NoError(t, err) + keys := keygen(nByz, T, N) keys2 := marshalUnmarshalKeys(t, keys) @@ -118,14 +115,14 @@ func TestTBLSMarshalling(t *testing.T) { } } -func keygen(nByz, T, N int) ([]*TBLSInst, error) { +func keygen(nByz, T, N int) []*TBLSInst { members := make([]types.NodeID, N) for i := range members { members[i] = types.NewNodeIDFromInt(i) } rand := pseudorandomStream(DefaultPseudoSeed) - return TBLS12381Keygen(nByz, T, members, rand) + return TBLS12381Keygen(T, members, rand) } func marshalUnmarshalKeys(t *testing.T, src []*TBLSInst) []*TBLSInst {