Function crypto::shamir::poly_random
source · fn poly_random(rng: &mut Rand32, secret: gf256, degree: usize) -> Vec<gf256>
Expand description
This function generates a random polynomial for Shamir’s secret sharing.
It takes a secret and degree of polynomial to create (the amount of shares)
It sets the y-intercept to the secret passed in and then generates as many points as there are
shares, and returns the polynomial, with the secret as the first item.
Imagine you’re trying to create a polynomial with a degree of 2:
In math notation that would look like this: $ ax^2 + bx + c $
Since the y-intercept will be the secret, we can set the secret to $c$.
Then, we generate two values, $a$ and $b$, which define the $x^2$ portion of the polynomial and
the $x$.
Imagine our $a$ is 7, our $b$ is 5 and our secret is 8. The polynomial would look like this:
$7x^2 + 5x + 8$.
In code, since we populate the values in reverse, that would be: vec![8, 5, 7]
.