Skip to content

Commit

Permalink
Remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed Jun 2, 2024
1 parent 736ac67 commit 2f7e39e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion proof/deniable.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (dp *deniableProver) run(suite Suite, self uint32, prv Prover,
dp.prirand = sc.Random()

nnodes := uint32(len(vrf))
if self < 0 || self >= nnodes {
if self >= nnodes {
return []error{errors.New("out-of-range self node")}
}

Expand Down
6 changes: 2 additions & 4 deletions share/poly.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type PriShare struct {
func (p *PriShare) Hash(s kyber.HashFactory) []byte {
h := s.Hash()
_, _ = p.V.MarshalTo(h)
//nolint:staticcheck // TODO: SA1003 fixed with https://github.com/dedis/kyber/issues/492
_ = binary.Write(h, binary.LittleEndian, p.I)
return h.Sum(nil)
}
Expand Down Expand Up @@ -230,7 +229,7 @@ func xyScalar(g kyber.Group, shares []*PriShare, t, n uint32) (map[uint32]kyber.
x := make(map[uint32]kyber.Scalar)
y := make(map[uint32]kyber.Scalar)
for _, s := range sorted {
if s == nil || s.V == nil || s.I < 0 {
if s == nil || s.V == nil {
continue
}
idx := s.I
Expand Down Expand Up @@ -304,7 +303,6 @@ type PubShare struct {
func (p *PubShare) Hash(s kyber.HashFactory) []byte {
h := s.Hash()
_, _ = p.V.MarshalTo(h)
//nolint:staticcheck // TODO: SA1003 fixed with https://github.com/dedis/kyber/issues/492
_ = binary.Write(h, binary.LittleEndian, p.I)
return h.Sum(nil)
}
Expand Down Expand Up @@ -431,7 +429,7 @@ func xyCommit(g kyber.Group, shares []*PubShare, t, n uint32) (map[uint32]kyber.
y := make(map[uint32]kyber.Point)

for _, s := range sorted {
if s == nil || s.V == nil || s.I < 0 {
if s == nil || s.V == nil {
continue
}
idx := s.I
Expand Down
2 changes: 1 addition & 1 deletion share/vss/pedersen/vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func (a *Aggregator) VerifyDeal(d *Deal, inclusion bool) error {
}

fi := d.SecShare
if fi.I < 0 || fi.I >= uint32(len(a.verifiers)) {
if fi.I >= uint32(len(a.verifiers)) {
return errors.New("vss: index out of bounds in Deal")
}
// compute fi * G
Expand Down
2 changes: 1 addition & 1 deletion share/vss/rabin/vss.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (a *aggregator) VerifyDeal(d *Deal, inclusion bool) error {
if fi.I != gi.I {
return errors.New("vss: not the same index for f and g share in Deal")
}
if fi.I < 0 || fi.I >= uint32(len(a.verifiers)) {
if fi.I >= uint32(len(a.verifiers)) {
return errors.New("vss: index out of bounds in Deal")
}
// compute fi * G + gi * H
Expand Down

0 comments on commit 2f7e39e

Please sign in to comment.