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

Method Equal

share/poly.go:117–131  ·  view source on GitHub ↗

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

(q *PriPoly)

Source from the content-addressed store, hash-verified

115// returns in variable time. Otherwise it runs in constant time regardless of whether it
116// eventually returns true or false.
117func (p *PriPoly) Equal(q *PriPoly) bool {
118 if p.g.String() != q.g.String() {
119 return false
120 }
121 if len(p.coeffs) != len(q.coeffs) {
122 return false
123 }
124 b := 1
125 for i := 0; i < p.Threshold(); i++ {
126 pb, _ := p.coeffs[i].MarshalBinary()
127 qb, _ := q.coeffs[i].MarshalBinary()
128 b &= subtle.ConstantTimeCompare(pb, qb)
129 }
130 return b == 1
131}
132
133// Commit creates a public commitment polynomial for the given base point b or
134// the standard base if b == nil.

Callers 15

CheckMethod · 0.45
TestSecretRecoveryFunction · 0.45
TestSecretRecoveryDeleteFunction · 0.45
TestSecretPolyEqualFunction · 0.45
TestPublicRecoveryFunction · 0.45
TestPublicRecoveryDeleteFunction · 0.45
TestPrivateAddFunction · 0.45
TestPublicAddFunction · 0.45
TestPublicPolyEqualFunction · 0.45
TestPriPolyMulFunction · 0.45
TestRecoverPriPolyFunction · 0.45
TestPriPolyCoefficientsFunction · 0.45

Calls 3

ThresholdMethod · 0.95
StringMethod · 0.45
MarshalBinaryMethod · 0.45

Tested by 15

TestSecretRecoveryFunction · 0.36
TestSecretRecoveryDeleteFunction · 0.36
TestSecretPolyEqualFunction · 0.36
TestPublicRecoveryFunction · 0.36
TestPublicRecoveryDeleteFunction · 0.36
TestPrivateAddFunction · 0.36
TestPublicAddFunction · 0.36
TestPublicPolyEqualFunction · 0.36
TestPriPolyMulFunction · 0.36
TestRecoverPriPolyFunction · 0.36
TestPriPolyCoefficientsFunction · 0.36
TestDKGDealFunction · 0.36