Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypto/vss/feldman_vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (share *Share) Verify(ec elliptic.Curve, threshold int, vs Vs) bool {
}

func (shares Shares) ReConstruct(ec elliptic.Curve) (secret *big.Int, err error) {
if shares != nil && shares[0].Threshold > len(shares) {
if shares != nil && shares[0].Threshold+1 > len(shares) {
return nil, ErrNumSharesBelowThreshold
}
modN := common.ModInt(ec.Params().N)
Expand Down
6 changes: 4 additions & 2 deletions crypto/vss/feldman_vss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ func TestReconstruct(t *testing.T) {
_, shares, err := Create(tss.EC(), threshold, secret, ids, rand.Reader)
assert.NoError(t, err)

secret2, err2 := shares[:threshold-1].ReConstruct(tss.EC())
secret2, err2 := shares[:threshold].ReConstruct(tss.EC())
assert.Error(t, err2) // not enough shares to satisfy the threshold
assert.Nil(t, secret2)

secret3, err3 := shares[:threshold].ReConstruct(tss.EC())
secret3, err3 := shares[:threshold+1].ReConstruct(tss.EC())
assert.NoError(t, err3)
assert.NotZero(t, secret3)
assert.Zero(t, secret.Cmp(secret3))

secret4, err4 := shares[:num].ReConstruct(tss.EC())
assert.NoError(t, err4)
assert.NotZero(t, secret4)
assert.Zero(t, secret.Cmp(secret4))
}
4 changes: 2 additions & 2 deletions ecdsa/keygen/local_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ keygen:

// fails if threshold cannot be satisfied (bad share)
{
badShares := pShares[:threshold]
badShares := pShares[:threshold+1]
badShares[len(badShares)-1].Share.Set(big.NewInt(0))
uj, err := pShares[:threshold].ReConstruct(tss.S256())
uj, err := pShares[:threshold+1].ReConstruct(tss.S256())
assert.NoError(t, err)
assert.NotEqual(t, parties[j].temp.ui, uj)
BigXjX, BigXjY := tss.EC().ScalarBaseMult(uj.Bytes())
Expand Down
4 changes: 2 additions & 2 deletions eddsa/keygen/local_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ keygen:

// fails if threshold cannot be satisfied (bad share)
{
badShares := pShares[:threshold]
badShares := pShares[:threshold+1]
badShares[len(badShares)-1].Share.Set(big.NewInt(0))
uj, err := pShares[:threshold].ReConstruct(tss.Edwards())
uj, err := pShares[:threshold+1].ReConstruct(tss.Edwards())
assert.NoError(t, err)
assert.NotEqual(t, parties[j].temp.ui, uj)
BigXjX, BigXjY := tss.Edwards().ScalarBaseMult(uj.Bytes())
Expand Down
Loading