MCPcopy Create free account
hub / github.com/DOSNetwork/core / Equal

Method Equal

share/poly.go:372–383  ·  view source on GitHub ↗

Equal checks equality of two public commitment polynomials p and q. If p and q are trivially unequal (e.g., due to mismatching cryptographic groups), this routine returns in variable time. Otherwise it runs in constant time regardless of whether it eventually returns true or false.

(q *PubPoly)

Source from the content-addressed store, hash-verified

370// this routine returns in variable time. Otherwise it runs in constant time
371// regardless of whether it eventually returns true or false.
372func (p *PubPoly) Equal(q *PubPoly) bool {
373 if p.g.String() != q.g.String() {
374 return false
375 }
376 b := 1
377 for i := 0; i < p.Threshold(); i++ {
378 pb, _ := p.commits[i].MarshalBinary()
379 qb, _ := q.commits[i].MarshalBinary()
380 b &= subtle.ConstantTimeCompare(pb, qb)
381 }
382 return b == 1
383}
384
385// Check a private share against a public commitment polynomial.
386func (p *PubPoly) Check(s *PriShare) bool {

Callers

nothing calls this directly

Calls 3

ThresholdMethod · 0.95
StringMethod · 0.45
MarshalBinaryMethod · 0.45

Tested by

no test coverage detected