-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
27 changed files
with
1,029 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,67 @@ | ||
mod bn254Fq; | ||
mod bls12381Fr; | ||
mod bls12_377Fq; | ||
mod bls12_377Fr; | ||
mod bls12_381Fr; | ||
mod bls12_381Fq; | ||
mod ed25519Fq; | ||
mod ed25519Fr; | ||
mod mnt4_753Fq; | ||
mod mnt4_753Fr; | ||
mod mnt6_753Fq; | ||
mod mnt6_753Fr; | ||
mod pallasFq; | ||
mod pallasFr; | ||
mod secp256k1Fq; | ||
mod secp256k1Fr; | ||
mod secp256r1Fq; | ||
mod secp256r1Fr; | ||
mod secp384r1Fq; | ||
mod secp384r1Fr; | ||
mod vestaFq; | ||
mod vestaFr; | ||
|
||
use crate::BigNum; | ||
use crate::runtime_bignum::BigNumInstance; | ||
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; | ||
use crate::fields::bn254Fq::BNParams; | ||
use crate::fields::bls12381Fr::Bls12_381_Fr_Params; | ||
|
||
/** | ||
* @brief Parameter definitions for generic fields of varying bit lengths | ||
* (these can be used when defining modular fields where the | ||
* modulus is a witness value and cannot be predefined | ||
* e.g. 2048-bit RSA) | ||
**/ | ||
struct Params512 {} | ||
impl RuntimeBigNumParamsTrait<5> for Params512 { | ||
fn modulus_bits() -> u64 { | ||
512 | ||
} | ||
} | ||
struct Params768 {} | ||
impl RuntimeBigNumParamsTrait<7> for Params768 { | ||
fn modulus_bits() -> u64 { | ||
768 | ||
} | ||
} | ||
struct Params1024 {} | ||
impl RuntimeBigNumParamsTrait<9> for Params1024 { | ||
fn modulus_bits() -> u64 { | ||
1024 | ||
} | ||
} | ||
struct Params2048 {} | ||
impl RuntimeBigNumParamsTrait<18> for Params2048 { | ||
fn modulus_bits() -> u64 { | ||
2048 | ||
} | ||
} | ||
struct Params4096 {} | ||
impl RuntimeBigNumParamsTrait<35> for Params4096 { | ||
fn modulus_bits() -> u64 { | ||
4096 | ||
} | ||
} | ||
|
||
// example typedef when using a defined bignum instance | ||
type Fq = BigNum<3, BNParams>; | ||
|
||
|
||
pub fn BLS12381Instance() -> BigNumInstance<3, Bls12_381_Fr_Params> { | ||
let modulus = [0xbda402fffe5bfeffffffff00000001, 0xa753299d7d483339d80809a1d80553, 0x0073ed]; | ||
let redc_param = [0x410fad2f92eb5c509cde80830358e4, 0x253b7fb78ddf0e2d772dc1f823b4d9, 0x008d54]; | ||
|
||
BigNumInstance::new(modulus, redc_param) | ||
} |
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
//! Blurb sourced from https://github.com/arkworks-rs | ||
//! This library implements the base field of the BLS12_377 curve generated in [\[BCGMMW20, “Zexe”\]](https://eprint.iacr.org/2018/962). | ||
//! The name denotes that it is a Barreto--Lynn--Scott curve of embedding degree | ||
//! 12, defined over a 377-bit (prime) field. The main feature of this curve is | ||
//! that both the scalar field and the base field are highly 2-adic. | ||
//! (This is in contrast to the BLS12_381 curve for which only the scalar field | ||
//! is highly 2-adic.) | ||
//! | ||
//! | ||
//! Curve information: | ||
//! * Base field: q = 258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 | ||
//! * Scalar field: r = | ||
//! 8444461749428370424248824938781546531375899335154063827935233455917409239041 | ||
//! * valuation(q - 1, 2) = 46 | ||
//! * valuation(r - 1, 2) = 47 | ||
//! * G1 curve equation: y^2 = x^3 + 1 | ||
//! * G2 curve equation: y^2 = x^3 + B, where | ||
//! * B = Fq2(0, 155198655607781456406391640216936120121836107652948796323930557600032281009004493664981332883744016074664192874906) | ||
use crate::BigNum; | ||
use crate::BigNumParamsTrait; | ||
use crate::runtime_bignum::BigNumInstance; | ||
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; | ||
use crate::utils::u60_representation::U60Repr; | ||
use crate::utils::arrayX::ArrayX; | ||
|
||
struct BLS12_377_Fq_Params {} | ||
impl RuntimeBigNumParamsTrait<4> for BLS12_377_Fq_Params { | ||
fn modulus_bits() -> u64 { | ||
377 | ||
} | ||
} | ||
impl BigNumParamsTrait<4> for BLS12_377_Fq_Params { | ||
fn get_instance() -> BigNumInstance<4, Self> { | ||
BLS12_377_Fq_Instance | ||
} | ||
fn modulus_bits() -> u64 { | ||
377 | ||
} | ||
} | ||
global BLS12_377_Fq_Instance: BigNumInstance<4, BLS12_377_Fq_Params> = BigNumInstance { | ||
modulus: [ | ||
0x0b5d44300000008508c00000000001, 0xd9f300f5138f1ef3622fba09480017, 0x4617c510eac63b05c06ca1493b1a22, 0x01ae3a | ||
], | ||
double_modulus: [ | ||
0x0116ba88600000010a11800000000002, 0x01b3e601ea271e3de6c45f741290002d, 0x018c2f8a21d58c760b80d94292763444, 0x035c73 | ||
], | ||
modulus_u60: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0508c00000000001, 0xb5d44300000008, 0x03622fba09480017, 0x0d9f300f5138f1ef], [0x05c06ca1493b1a22, 0x04617c510eac63b0, 0x01ae3a, 0x00]] } }, | ||
modulus_u60_x4: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0508c00000000001, 0xb5d44300000008, 0x03622fba09480017, 0x0d9f300f5138f1ef], [0x05c06ca1493b1a22, 0x04617c510eac63b0, 0x01ae3a, 0x00], [0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00]] } }, | ||
redc_param: [ | ||
0xed687789c42a591f9fd58c5e4daffc, 0xd0de6776b1a06af2d488d85a6d02d0, 0x8d0cc4060e976c3ca0582ef4f73bba, 0x026150 | ||
] | ||
}; | ||
|
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,55 @@ | ||
//! Blurb sourced from https://github.com/arkworks-rs | ||
//! This library implements the scalar field of the BLS12_377 curve generated in [\[BCGMMW20, “Zexe”\]](https://eprint.iacr.org/2018/962). | ||
//! The name denotes that it is a Barreto--Lynn--Scott curve of embedding degree | ||
//! 12, defined over a 377-bit (prime) field. The main feature of this curve is | ||
//! that both the scalar field and the base field are highly 2-adic. | ||
//! (This is in contrast to the BLS12_381 curve for which only the scalar field | ||
//! is highly 2-adic.) | ||
//! | ||
//! | ||
//! Curve information: | ||
//! * Base field: q = 258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 | ||
//! * Scalar field: r = | ||
//! 8444461749428370424248824938781546531375899335154063827935233455917409239041 | ||
//! * valuation(q - 1, 2) = 46 | ||
//! * valuation(r - 1, 2) = 47 | ||
//! * G1 curve equation: y^2 = x^3 + 1 | ||
//! * G2 curve equation: y^2 = x^3 + B, where | ||
//! * B = Fq2(0, 155198655607781456406391640216936120121836107652948796323930557600032281009004493664981332883744016074664192874906) | ||
use crate::BigNum; | ||
use crate::BigNumParamsTrait; | ||
use crate::runtime_bignum::BigNumInstance; | ||
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; | ||
use crate::utils::u60_representation::U60Repr; | ||
use crate::utils::arrayX::ArrayX; | ||
|
||
struct BLS12_377_Fr_Params {} | ||
impl RuntimeBigNumParamsTrait<3> for BLS12_377_Fr_Params { | ||
fn modulus_bits() -> u64 { | ||
253 | ||
} | ||
} | ||
impl BigNumParamsTrait<3> for BLS12_377_Fr_Params { | ||
fn get_instance() -> BigNumInstance<3, Self> { | ||
BLS12_377_Fr_Instance | ||
} | ||
fn modulus_bits() -> u64 { | ||
253 | ||
} | ||
} | ||
global BLS12_377_Fr_Instance: BigNumInstance<3, BLS12_377_Fr_Params> = BigNumInstance { | ||
modulus: [ | ||
0xaa76fed00000010a11800000000001, 0x655e9a2ca55660b44d1e5c37b00159, 0x12ab | ||
], | ||
double_modulus: [ | ||
0x0154edfda00000021423000000000002, 0x01cabd34594aacc1689a3cb86f6002b2, 0x2555 | ||
], | ||
modulus_u60: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0a11800000000001, 0x0aa76fed00000010, 0x044d1e5c37b00159], [0x0655e9a2ca55660b, 0x12ab, 0x00]] } }, | ||
modulus_u60_x4: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0a11800000000001, 0x0aa76fed00000010, 0x044d1e5c37b00159], [0x0655e9a2ca55660b, 0x12ab, 0x00], [0x00, 0x00, 0x00], [0x00, 0x00, 0x00]] } }, | ||
redc_param: [ | ||
0x0a180b8d69e258f5204c21151e79ea, 0x491ec40b2c9ee4e51e49faa80548fd, 0x36d9 | ||
] | ||
}; | ||
|
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,53 @@ | ||
//! Blurb sourced from https://github.com/arkworks-rs | ||
//! This library implements the base field of the BLS12_381 curve generated by [Sean Bowe](https://electriccoin.co/blog/new-snark-curve/). | ||
//! The name denotes that it is a Barreto--Lynn--Scott curve of embedding degree | ||
//! 12, defined over a 381-bit (prime) field. | ||
//! This curve was intended to replace the BN254 curve to provide a higher | ||
//! security level without incurring a large performance overhead. | ||
//! | ||
//! | ||
//! Curve information: | ||
//! * Base field: q = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 | ||
//! * Scalar field: r = | ||
//! 52435875175126190479447740508185965837690552500527637822603658699938581184513 | ||
//! * valuation(q - 1, 2) = 1 | ||
//! * valuation(r - 1, 2) = 32 | ||
//! * G1 curve equation: y^2 = x^3 + 4 | ||
//! * G2 curve equation: y^2 = x^3 + Fq2(4, 4) | ||
use crate::BigNum; | ||
use crate::BigNumParamsTrait; | ||
use crate::runtime_bignum::BigNumInstance; | ||
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; | ||
use crate::utils::u60_representation::U60Repr; | ||
use crate::utils::arrayX::ArrayX; | ||
|
||
struct BLS12_381_Fq_Params {} | ||
impl RuntimeBigNumParamsTrait<4> for BLS12_381_Fq_Params { | ||
fn modulus_bits() -> u64 { | ||
381 | ||
} | ||
} | ||
impl BigNumParamsTrait<4> for BLS12_381_Fq_Params { | ||
fn get_instance() -> BigNumInstance<4, Self> { | ||
BLS12_381_Fq_Instance | ||
} | ||
fn modulus_bits() -> u64 { | ||
381 | ||
} | ||
} | ||
global BLS12_381_Fq_Instance: BigNumInstance<4, BLS12_381_Fq_Params> = BigNumInstance { | ||
modulus: [ | ||
0xabfffeb153ffffb9feffffffffaaab, 0x4b84f38512bf6730d2a0f6b0f6241e, 0xea397fe69a4b1ba7b6434bacd76477, 0x1a0111 | ||
], | ||
double_modulus: [ | ||
0x0157fffd62a7ffff73fdffffffff5556, 0x019709e70a257ece61a541ed61ec483c, 0x01d472ffcd3496374f6c869759aec8ed, 0x340222 | ||
], | ||
modulus_u60: U60Repr { limbs: ArrayX { segments: [[ | ||
0x09feffffffffaaab, 0x0abfffeb153ffffb, 0xd2a0f6b0f6241e, 0x04b84f38512bf673], [0x07b6434bacd76477, 0x0ea397fe69a4b1ba, 0x1a0111, 0x00]] } }, | ||
modulus_u60_x4: U60Repr { limbs: ArrayX { segments: [[ | ||
0x09feffffffffaaab, 0x0abfffeb153ffffb, 0xd2a0f6b0f6241e, 0x04b84f38512bf673], [0x07b6434bacd76477, 0x0ea397fe69a4b1ba, 0x1a0111, 0x00], [0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00]] } }, | ||
redc_param: [ | ||
0x65c59e8163c701ec4f881fd59646e8, 0x09d07fda82a52f7d1dc780a19de74e, 0x4bcf32791738a0406c331e9ae8a46e, 0x2760d7 | ||
] | ||
}; | ||
|
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,52 @@ | ||
//! Blurb sourced from https://github.com/arkworks-rs | ||
//! This library implements the scalar field of the BLS12_381 curve generated by [Sean Bowe](https://electriccoin.co/blog/new-snark-curve/). | ||
//! The name denotes that it is a Barreto--Lynn--Scott curve of embedding degree | ||
//! 12, defined over a 381-bit (prime) field. | ||
//! This curve was intended to replace the BN254 curve to provide a higher | ||
//! security level without incurring a large performance overhead. | ||
//! | ||
//! | ||
//! Curve information: | ||
//! * Base field: q = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 | ||
//! * Scalar field: r = | ||
//! 52435875175126190479447740508185965837690552500527637822603658699938581184513 | ||
//! * valuation(q - 1, 2) = 1 | ||
//! * valuation(r - 1, 2) = 32 | ||
//! * G1 curve equation: y^2 = x^3 + 4 | ||
//! * G2 curve equation: y^2 = x^3 + Fq2(4, 4) | ||
use crate::BigNum; | ||
use crate::BigNumParamsTrait; | ||
use crate::runtime_bignum::BigNumInstance; | ||
use crate::runtime_bignum::BigNumParamsTrait as RuntimeBigNumParamsTrait; | ||
use crate::utils::u60_representation::U60Repr; | ||
use crate::utils::arrayX::ArrayX; | ||
|
||
struct BLS12_381_Fr_Params {} | ||
impl RuntimeBigNumParamsTrait<3> for BLS12_381_Fr_Params { | ||
fn modulus_bits() -> u64 { | ||
255 | ||
} | ||
} | ||
impl BigNumParamsTrait<3> for BLS12_381_Fr_Params { | ||
fn get_instance() -> BigNumInstance<3, Self> { | ||
BLS12_381_Fr_Instance | ||
} | ||
fn modulus_bits() -> u64 { | ||
255 | ||
} | ||
} | ||
global BLS12_381_Fr_Instance: BigNumInstance<3, BLS12_381_Fr_Params> = BigNumInstance { | ||
modulus: [ | ||
0xbda402fffe5bfeffffffff00000001, 0xa753299d7d483339d80809a1d80553, 0x73ed | ||
], | ||
double_modulus: [ | ||
0x017b4805fffcb7fdfffffffe00000002, 0x014ea6533afa906673b0101343b00aa6, 0xe7da | ||
], | ||
modulus_u60: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0fffffff00000001, 0x0bda402fffe5bfef, 0x09d80809a1d80553], [0x0a753299d7d48333, 0x73ed, 0x00]] } }, | ||
modulus_u60_x4: U60Repr { limbs: ArrayX { segments: [[ | ||
0x0fffffff00000001, 0x0bda402fffe5bfef, 0x09d80809a1d80553], [0x0a753299d7d48333, 0x73ed, 0x00], [0x00, 0x00, 0x00], [0x00, 0x00, 0x00]] } }, | ||
redc_param: [ | ||
0x410fad2f92eb5c509cde80830358e4, 0x253b7fb78ddf0e2d772dc1f823b4d9, 0x8d54 | ||
] | ||
}; |
Oops, something went wrong.