-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add elgamal encryption to utils; add pvss module; check that the secp…
…256k1 group order is prime, and also (order - 1)/2 which is sadly not
- Loading branch information
Showing
4 changed files
with
89 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use is_prime; | ||
use rand_core::{CryptoRng, RngCore}; | ||
|
||
use crate::curve::scalar::Scalar; | ||
|
||
/// A publicly verifiable secret share algorithm | ||
pub struct PVSS { | ||
R: Vec<Scalar>, | ||
c: Scalar, | ||
} | ||
|
||
impl PVSS { | ||
/// Construct a random polynomial of the passed degree `n` | ||
pub fn new<RNG: RngCore + CryptoRng>(rng: &mut RNG) -> PVSS { | ||
let R = Vec::new(); | ||
let c = Scalar::random(rng); | ||
PVSS { R, c } | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use crate::curve::{point::Point, scalar::Scalar}; | ||
|
||
use num_bigint::BigUint; | ||
|
||
#[test] | ||
fn is_p_minus_1_over_2_prime() { | ||
let p = BigUint::from_bytes_be(crate::curve::point::N.as_slice()); | ||
|
||
assert!(is_prime::is_biguint_prime(p.clone())); | ||
|
||
let p12 = (p - 1u32) / 2u32; | ||
|
||
assert!(is_prime::is_biguint_prime(p12.clone())); | ||
} | ||
} |
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