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

Method Add

share/poly.go:99–111  ·  view source on GitHub ↗

Add computes the component-wise sum of the polynomials p and q and returns it as a new polynomial.

(q *PriPoly)

Source from the content-addressed store, hash-verified

97// Add computes the component-wise sum of the polynomials p and q and returns it
98// as a new polynomial.
99func (p *PriPoly) Add(q *PriPoly) (*PriPoly, error) {
100 if p.g.String() != q.g.String() {
101 return nil, errorGroups
102 }
103 if p.Threshold() != q.Threshold() {
104 return nil, errorCoeffs
105 }
106 coeffs := make([]kyber.Scalar, p.Threshold())
107 for i := range coeffs {
108 coeffs[i] = p.g.Scalar().Add(p.coeffs[i], q.coeffs[i])
109 }
110 return &PriPoly{p.g, coeffs}, nil
111}
112
113// Equal checks equality of two secret sharing polynomials p and q. If p and q are trivially
114// unequal (e.g., due to mismatching cryptographic groups or polynomial size), this routine

Callers 15

RecoverPriPolyFunction · 0.95
TestSecretPolyEqualFunction · 0.95
TestPrivateAddFunction · 0.95
TestDistKeyShareFunction · 0.95
TestTBLSFunction · 0.95
EvalMethod · 0.45
MulMethod · 0.45
RecoverSecretFunction · 0.45
EvalMethod · 0.45
AddMethod · 0.45
RecoverCommitFunction · 0.45
TestPublicAddFunction · 0.45

Calls 3

ThresholdMethod · 0.95
StringMethod · 0.45
ScalarMethod · 0.45

Tested by 8

TestSecretPolyEqualFunction · 0.76
TestPrivateAddFunction · 0.76
TestDistKeyShareFunction · 0.76
TestTBLSFunction · 0.76
TestPublicAddFunction · 0.36
TestPublicPolyEqualFunction · 0.36
TestPDKGFunction · 0.36
TestVSSSessionIDFunction · 0.36