Add computes the component-wise sum of the polynomials p and q and returns it as a new polynomial. NOTE: If the base points p.b and q.b are different then the base point of the resulting PubPoly cannot be computed without knowing the discrete logarithm between p.b and q.b. In this particular case, w
(q *PubPoly)
| 349 | // p.b as a default value which of course does not correspond to the correct |
| 350 | // base point and thus should not be used in further computations. |
| 351 | func (p *PubPoly) Add(q *PubPoly) (*PubPoly, error) { |
| 352 | if p.g.String() != q.g.String() { |
| 353 | return nil, errorGroups |
| 354 | } |
| 355 | |
| 356 | if p.Threshold() != q.Threshold() { |
| 357 | return nil, errorCoeffs |
| 358 | } |
| 359 | |
| 360 | commits := make([]kyber.Point, p.Threshold()) |
| 361 | for i := range commits { |
| 362 | commits[i] = p.g.Point().Add(p.commits[i], q.commits[i]) |
| 363 | } |
| 364 | |
| 365 | return &PubPoly{p.g, p.b, commits}, nil |
| 366 | } |
| 367 | |
| 368 | // Equal checks equality of two public commitment polynomials p and q. If p and |
| 369 | // q are trivially unequal (e.g., due to mismatching cryptographic groups), |