-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use common::Polynomial for private polys; add operators and helpers t…
…o Polynomial to make code cleaner
- Loading branch information
Showing
5 changed files
with
59 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
use rand_core::{CryptoRng, RngCore}; | ||
|
||
use crate::common::Polynomial; | ||
use crate::curve::scalar::Scalar; | ||
|
||
/// A verifiable secret share algorithm | ||
pub struct VSS {} | ||
|
||
impl VSS { | ||
/// Construct a random polynomial of the passed degree `n` | ||
pub fn random_poly<RNG: RngCore + CryptoRng>(n: u32, rng: &mut RNG) -> Vec<Scalar> { | ||
(0..n + 1).map(|_| Scalar::random(rng)).collect() | ||
pub fn random_poly<RNG: RngCore + CryptoRng>( | ||
n: u32, | ||
rng: &mut RNG, | ||
) -> Polynomial<Scalar, Scalar> { | ||
Polynomial::random(n, rng) | ||
} | ||
|
||
/// Construct a random polynomial of the passed degree `n` using the passed constant term | ||
pub fn random_poly_with_constant<RNG: RngCore + CryptoRng>( | ||
n: u32, | ||
constant: Scalar, | ||
rng: &mut RNG, | ||
) -> Vec<Scalar> { | ||
let mut params: Vec<Scalar> = (0..n + 1).map(|_| Scalar::random(rng)).collect(); | ||
params[0] = constant; | ||
) -> Polynomial<Scalar, Scalar> { | ||
let mut poly = Polynomial::random(n, rng); | ||
poly.params[0] = constant; | ||
|
||
params | ||
poly | ||
} | ||
} |