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

Method Mul

share/poly.go:148–163  ·  view source on GitHub ↗

Mul multiples p and q together. The result is a polynomial of the sum of the two degrees of p and q. NOTE: it does not check for null coefficients after the multiplication, so the degree of the polynomial is "always" as described above. This is only for use in secret sharing schemes. It is not a gen

(q *PriPoly)

Source from the content-addressed store, hash-verified

146// described above. This is only for use in secret sharing schemes. It is not
147// a general polynomial multiplication routine.
148func (p *PriPoly) Mul(q *PriPoly) *PriPoly {
149 d1 := len(p.coeffs) - 1
150 d2 := len(q.coeffs) - 1
151 newDegree := d1 + d2
152 coeffs := make([]kyber.Scalar, newDegree+1)
153 for i := range coeffs {
154 coeffs[i] = p.g.Scalar().Zero()
155 }
156 for i := range p.coeffs {
157 for j := range q.coeffs {
158 tmp := p.g.Scalar().Mul(p.coeffs[i], q.coeffs[j])
159 coeffs[i+j] = tmp.Add(coeffs[i+j], tmp)
160 }
161 }
162 return &PriPoly{p.g, coeffs}
163}
164
165// Coefficients return the list of coefficients representing p. This
166// information is generally PRIVATE and should not be revealed to a third party

Callers 15

TestPriPolyMulFunction · 0.95
EvalMethod · 0.45
CommitMethod · 0.45
RecoverSecretFunction · 0.45
RecoverPriPolyFunction · 0.45
EvalMethod · 0.45
CheckMethod · 0.45
RecoverCommitFunction · 0.45
TestDistKeyShareFunction · 0.45
TestTBLSFunction · 0.45
TestDistKeyShareReNewFunction · 0.45
TestReNewDistKeyShareFunction · 0.45

Calls 3

ZeroMethod · 0.45
ScalarMethod · 0.45
AddMethod · 0.45

Tested by 11

TestPriPolyMulFunction · 0.76
TestDistKeyShareFunction · 0.36
TestTBLSFunction · 0.36
TestDistKeyShareReNewFunction · 0.36
TestReNewDistKeyShareFunction · 0.36
genPairFunction · 0.36
TestVSSDHExchangeFunction · 0.36
genPairFunction · 0.36