Skip to content

Commit

Permalink
Do not normalize IDs of Shamir's Secret Sharing
Browse files Browse the repository at this point in the history
We need to ensure that:
- all indexes are non-zero,
- all indexes are non-zero modulo the curve order,
- all indexes are unique modulo the curve order.

The first two are guarded in `CheckIndexes` function by:

```
vMod := new(big.Int).Mod(v, ec.Params().N)
if vMod.Cmp(zero) == 0 {
return nil, errors.New("party index should not be 0")
}
```

The last one is guarded by:
```
vModStr := vMod.String()
if _, ok := visited[vModStr]; ok {
return nil, fmt.Errorf("duplicate indexes %s", vModStr)
}
visited[vModStr] = struct{}{}
```

`CheckIndexes` was additionally normalizing identifiers mod elliptic curve order.
This was not really needed and could cause problems during signing.
  • Loading branch information
pdyraga committed Dec 8, 2021
1 parent 681ebad commit 2718fca
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions crypto/vss/feldman_vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
// Check share ids of Shamir's Secret Sharing, return error if duplicate or 0 value found
func CheckIndexes(ec elliptic.Curve, indexes []*big.Int) ([]*big.Int, error) {
visited := make(map[string]struct{})
for i, v := range indexes {
for _, v := range indexes {
vMod := new(big.Int).Mod(v, ec.Params().N)
if vMod.Cmp(zero) == 0 {
return nil, errors.New("party index should not be 0")
Expand All @@ -52,7 +52,6 @@ func CheckIndexes(ec elliptic.Curve, indexes []*big.Int) ([]*big.Int, error) {
return nil, fmt.Errorf("duplicate indexes %s", vModStr)
}
visited[vModStr] = struct{}{}
indexes[i] = vMod
}
return indexes, nil
}
Expand Down

0 comments on commit 2718fca

Please sign in to comment.