NewPriPoly creates a new secret sharing polynomial using the provided cryptographic group, the secret sharing threshold t, and the secret to be shared s. If s is nil, a new s is chosen using the provided randomness stream rand.
(group kyber.Group, t int, s kyber.Scalar, rand cipher.Stream)
| 48 | // shared s. If s is nil, a new s is chosen using the provided randomness |
| 49 | // stream rand. |
| 50 | func NewPriPoly(group kyber.Group, t int, s kyber.Scalar, rand cipher.Stream) *PriPoly { |
| 51 | coeffs := make([]kyber.Scalar, t) |
| 52 | coeffs[0] = s |
| 53 | if coeffs[0] == nil { |
| 54 | coeffs[0] = group.Scalar().Pick(rand) |
| 55 | } |
| 56 | for i := 1; i < t; i++ { |
| 57 | coeffs[i] = group.Scalar().Pick(rand) |
| 58 | } |
| 59 | return &PriPoly{g: group, coeffs: coeffs} |
| 60 | } |
| 61 | |
| 62 | // CoefficientsToPriPoly returns a PriPoly based on the given coefficients |
| 63 | func CoefficientsToPriPoly(g kyber.Group, coeffs []kyber.Scalar) *PriPoly { |