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)
| 146 | // described above. This is only for use in secret sharing schemes. It is not |
| 147 | // a general polynomial multiplication routine. |
| 148 | func (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 |