Add computes the component-wise sum of the polynomials p and q and returns it as a new polynomial.
(q *PriPoly)
| 97 | // Add computes the component-wise sum of the polynomials p and q and returns it |
| 98 | // as a new polynomial. |
| 99 | func (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 |