Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed warnings and added hash2curve for G1 #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Make MODULUS const
Signed-off-by: Michael Lodder <[email protected]>
mikelodder7 committed Mar 23, 2020
commit 1a71ea596034d535ceb8db1ef46619edfbaef511
6 changes: 4 additions & 2 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -13,13 +13,14 @@ pub const FIELD_ELEMENT_SIZE: usize = MODBYTES;
// Byte size of element in group G1, 1 extra byte for compression flag
pub const GROUP_G1_SIZE: usize = (2 * MODBYTES + 1) as usize;

pub const MODULUS: BigNum = BigNum{ w: rom::MODULUS };

lazy_static! {
pub static ref GENERATOR_G1: GroupG1 = GroupG1::generator();
pub static ref MODULUS: BigNum = BigNum::new_ints(&rom::MODULUS);
pub static ref MODULUS_BITS: usize = MODULUS.nbits();
pub static ref CURVE_ORDER: BigNum = BigNum::new_ints(&rom::CURVE_ORDER);
pub static ref MODULUS_MINUS_1_DIV_2: BigNum = {
let mut order = BigNum::new_ints(&rom::MODULUS);
let mut order = MODULUS;
order.dec(1);
order.shr(1);
order
@@ -49,3 +50,4 @@ lazy_static! {

#[cfg(any(feature = "bls381", feature = "bn254"))]
pub use crate::types_g2::{GENERATOR_G2, GROUP_G2_SIZE, GROUP_GT_SIZE};