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)
| 370 | // this routine returns in variable time. Otherwise it runs in constant time |
| 371 | // regardless of whether it eventually returns true or false. |
| 372 | func (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. |
| 386 | func (p *PubPoly) Check(s *PriShare) bool { |
nothing calls this directly
no test coverage detected