mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-11 08:21:33 +01:00
Update BN254
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use ark_ec::models::{ModelParameters, SWModelParameters};
|
||||
use ark_ff::{biginteger::BigInteger256, field_new, Zero};
|
||||
use ark_ff::{field_new, Zero};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
@@ -13,28 +13,16 @@ impl ModelParameters for Parameters {
|
||||
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = 0
|
||||
const COEFF_A: Fq = field_new!(Fq, BigInteger256([0x0, 0x0, 0x0, 0x0]));
|
||||
const COEFF_A: Fq = field_new!(Fq, "0");
|
||||
|
||||
/// COEFF_B = 3
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, BigInteger256([
|
||||
0x7a17caa950ad28d7,
|
||||
0x1f6ac17ae15521b9,
|
||||
0x334bea4e696bd284,
|
||||
0x2a1f6744ce179d8e,
|
||||
]));
|
||||
const COEFF_B: Fq = field_new!(Fq, "3");
|
||||
|
||||
/// COFACTOR = 1
|
||||
const COFACTOR: &'static [u64] = &[0x1];
|
||||
|
||||
/// COFACTOR_INV = COFACTOR^{-1} mod r = 1
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, BigInteger256([
|
||||
0xac96341c4ffffffb,
|
||||
0x36fc76959f60cd29,
|
||||
0x666ea36f7879462e,
|
||||
0xe0a77c19a07df2f,
|
||||
]));
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "1");
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
@@ -46,22 +34,8 @@ impl SWModelParameters for Parameters {
|
||||
}
|
||||
}
|
||||
|
||||
/// G1_GENERATOR_X =
|
||||
/// 1
|
||||
#[rustfmt::skip]
|
||||
pub const G1_GENERATOR_X: Fq = field_new!(Fq, BigInteger256([
|
||||
0xd35d438dc58f0d9d,
|
||||
0x0a78eb28f5c70b3d,
|
||||
0x666ea36f7879462c,
|
||||
0x0e0a77c19a07df2f,
|
||||
]));
|
||||
/// G1_GENERATOR_X = 1
|
||||
pub const G1_GENERATOR_X: Fq = field_new!(Fq, "1");
|
||||
|
||||
/// G1_GENERATOR_Y =
|
||||
/// 2
|
||||
#[rustfmt::skip]
|
||||
pub const G1_GENERATOR_Y: Fq = field_new!(Fq, BigInteger256([
|
||||
0xa6ba871b8b1e1b3a,
|
||||
0x14f1d651eb8e167b,
|
||||
0xccdd46def0f28c58,
|
||||
0x1c14ef83340fbe5e,
|
||||
]));
|
||||
/// G1_GENERATOR_Y = 2
|
||||
pub const G1_GENERATOR_Y: Fq = field_new!(Fq, "2");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use ark_ec::models::{ModelParameters, SWModelParameters};
|
||||
use ark_ff::{biginteger::BigInteger256, field_new, Zero};
|
||||
use ark_ff::{field_new, Zero};
|
||||
|
||||
use crate::{g1, Fq, Fq2, Fr};
|
||||
use crate::{Fq, Fq2, Fr};
|
||||
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct Parameters;
|
||||
@@ -14,27 +14,14 @@ impl ModelParameters for Parameters {
|
||||
impl SWModelParameters for Parameters {
|
||||
/// COEFF_A = [0, 0]
|
||||
#[rustfmt::skip]
|
||||
const COEFF_A: Fq2 = field_new!(Fq2,
|
||||
g1::Parameters::COEFF_A,
|
||||
g1::Parameters::COEFF_A,
|
||||
);
|
||||
const COEFF_A: Fq2 = field_new!(Fq2, field_new!(Fq, "0"), field_new!(Fq, "0"));
|
||||
|
||||
/// COEFF_B = 3/(u+9)
|
||||
/// = (19485874751759354771024239261021720505790618469301721065564631296452457478373, 266929791119991161246907387137283842545076965332900288569378510910307636690)
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq2 = field_new!(Fq2,
|
||||
field_new!(Fq, BigInteger256([
|
||||
0x3bf938e377b802a8,
|
||||
0x020b1b273633535d,
|
||||
0x26b7edf049755260,
|
||||
0x2514c6324384a86d,
|
||||
])),
|
||||
field_new!(Fq, BigInteger256([
|
||||
0x38e7ecccd1dcff67,
|
||||
0x65f0b37d93ce0d3e,
|
||||
0xd749d0dd22ac00aa,
|
||||
0x0141b9ce4a688d4d,
|
||||
])),
|
||||
field_new!(Fq, "19485874751759354771024239261021720505790618469301721065564631296452457478373"),
|
||||
field_new!(Fq, "266929791119991161246907387137283842545076965332900288569378510910307636690"),
|
||||
);
|
||||
|
||||
/// COFACTOR = (36 * X^4) + (36 * X^3) + (30 * X^2) + 6*X + 1
|
||||
@@ -49,12 +36,7 @@ impl SWModelParameters for Parameters {
|
||||
|
||||
/// COFACTOR_INV = COFACTOR^{-1} mod r
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, BigInteger256([
|
||||
0x7fff17d53ff2895e,
|
||||
0xd0617390cf7919e5,
|
||||
0xb9af426b22d0eb61,
|
||||
0x270485e31bd72a4d,
|
||||
]));
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "10944121435919637613327163357776759465618812564592884533313067514031822496649");
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (G2_GENERATOR_X, G2_GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) =
|
||||
@@ -74,39 +56,19 @@ pub const G2_GENERATOR_Y: Fq2 = field_new!(Fq2, G2_GENERATOR_Y_C0, G2_GENERATOR_
|
||||
/// G2_GENERATOR_X_C0 =
|
||||
/// 10857046999023057135944570762232829481370756359578518086990519993285655852781
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_X_C0: Fq = field_new!(Fq, BigInteger256([
|
||||
0x8e83b5d102bc2026,
|
||||
0xdceb1935497b0172,
|
||||
0xfbb8264797811adf,
|
||||
0x19573841af96503b,
|
||||
]));
|
||||
pub const G2_GENERATOR_X_C0: Fq = field_new!(Fq, "10857046999023057135944570762232829481370756359578518086990519993285655852781");
|
||||
|
||||
/// G2_GENERATOR_X_C1 =
|
||||
/// 11559732032986387107991004021392285783925812861821192530917403151452391805634
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_X_C1: Fq = field_new!(Fq, BigInteger256([
|
||||
0xafb4737da84c6140,
|
||||
0x6043dd5a5802d8c4,
|
||||
0x09e950fc52a02f86,
|
||||
0x14fef0833aea7b6b,
|
||||
]));
|
||||
pub const G2_GENERATOR_X_C1: Fq = field_new!(Fq, "11559732032986387107991004021392285783925812861821192530917403151452391805634");
|
||||
|
||||
/// G2_GENERATOR_Y_C0 =
|
||||
/// 8495653923123431417604973247489272438418190587263600148770280649306958101930
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_Y_C0: Fq = field_new!(Fq, BigInteger256([
|
||||
0x619dfa9d886be9f6,
|
||||
0xfe7fd297f59e9b78,
|
||||
0xff9e1a62231b7dfe,
|
||||
0x28fd7eebae9e4206,
|
||||
]));
|
||||
pub const G2_GENERATOR_Y_C0: Fq = field_new!(Fq, "8495653923123431417604973247489272438418190587263600148770280649306958101930");
|
||||
|
||||
/// G2_GENERATOR_Y_C1 =
|
||||
/// 4082367875863433681332203403145435568316851327593401208105741076214120093531
|
||||
#[rustfmt::skip]
|
||||
pub const G2_GENERATOR_Y_C1: Fq = field_new!(Fq, BigInteger256([
|
||||
0x64095b56c71856ee,
|
||||
0xdc57f922327d3cbb,
|
||||
0x55f935be33351076,
|
||||
0x0da4a0e693fd6482,
|
||||
]));
|
||||
pub const G2_GENERATOR_Y_C1: Fq = field_new!(Fq, "4082367875863433681332203403145435568316851327593401208105741076214120093531");
|
||||
|
||||
@@ -3,7 +3,7 @@ use ark_ec::{
|
||||
bn,
|
||||
bn::{Bn, BnParameters, TwistType},
|
||||
};
|
||||
use ark_ff::{biginteger::BigInteger256, field_new};
|
||||
use ark_ff::field_new;
|
||||
pub mod g1;
|
||||
pub mod g2;
|
||||
|
||||
@@ -23,47 +23,16 @@ impl BnParameters for Parameters {
|
||||
];
|
||||
/// `ate_loop_count` is positive.
|
||||
const ATE_LOOP_COUNT_IS_NEGATIVE: bool = false;
|
||||
|
||||
const TWIST_MUL_BY_Q_X: Fq2 = field_new!(
|
||||
Fq2,
|
||||
field_new!(
|
||||
Fq,
|
||||
BigInteger256([
|
||||
0xb5773b104563ab30,
|
||||
0x347f91c8a9aa6454,
|
||||
0x7a007127242e0991,
|
||||
0x1956bcd8118214ec,
|
||||
])
|
||||
),
|
||||
field_new!(
|
||||
Fq,
|
||||
BigInteger256([
|
||||
0x6e849f1ea0aa4757,
|
||||
0xaa1c7b6d89f89141,
|
||||
0xb6e713cdfae0ca3a,
|
||||
0x26694fbb4e82ebc3,
|
||||
])
|
||||
),
|
||||
field_new!(Fq, "21575463638280843010398324269430826099269044274347216827212613867836435027261"),
|
||||
field_new!(Fq, "10307601595873709700152284273816112264069230130616436755625194854815875713954"),
|
||||
);
|
||||
const TWIST_MUL_BY_Q_Y: Fq2 = field_new!(
|
||||
Fq2,
|
||||
field_new!(
|
||||
Fq,
|
||||
BigInteger256([
|
||||
0xe4bbdd0c2936b629,
|
||||
0xbb30f162e133bacb,
|
||||
0x31a9d1b6f9645366,
|
||||
0x253570bea500f8dd,
|
||||
])
|
||||
),
|
||||
field_new!(
|
||||
Fq,
|
||||
BigInteger256([
|
||||
0xa1d77ce45ffe77c7,
|
||||
0x07affd117826d1db,
|
||||
0x6d16bd27bb7edc6b,
|
||||
0x2c87200285defecc,
|
||||
])
|
||||
),
|
||||
field_new!(Fq, "2821565182194536844548159561693502659359617185244120367078079554186484126554"),
|
||||
field_new!(Fq, "3505843767911556378687030309984248845540243509899259641013678093033130930403"),
|
||||
);
|
||||
const TWIST_TYPE: TwistType = TwistType::D;
|
||||
type Fp = Fq;
|
||||
|
||||
Reference in New Issue
Block a user