Merge pull request #197 from str4d/clippy-cleanups

Clippy cleanups
This commit is contained in:
str4d 2020-01-16 13:08:32 -05:00 committed by GitHub
commit 53ef825468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1619 additions and 1620 deletions

View File

@ -66,35 +66,35 @@ impl ConditionallySelectable for Fp {
/// p = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787
const MODULUS: [u64; 6] = [
0xb9feffffffffaaab,
0x1eabfffeb153ffff,
0x6730d2a0f6b0f624,
0x64774b84f38512bf,
0x4b1ba7b6434bacd7,
0x1a0111ea397fe69a,
0xb9fe_ffff_ffff_aaab,
0x1eab_fffe_b153_ffff,
0x6730_d2a0_f6b0_f624,
0x6477_4b84_f385_12bf,
0x4b1b_a7b6_434b_acd7,
0x1a01_11ea_397f_e69a,
];
/// INV = -(p^{-1} mod 2^64) mod 2^64
const INV: u64 = 0x89f3fffcfffcfffd;
const INV: u64 = 0x89f3_fffc_fffc_fffd;
/// R = 2^384 mod p
const R: Fp = Fp([
0x760900000002fffd,
0xebf4000bc40c0002,
0x5f48985753c758ba,
0x77ce585370525745,
0x5c071a97a256ec6d,
0x15f65ec3fa80e493,
0x7609_0000_0002_fffd,
0xebf4_000b_c40c_0002,
0x5f48_9857_53c7_58ba,
0x77ce_5853_7052_5745,
0x5c07_1a97_a256_ec6d,
0x15f6_5ec3_fa80_e493,
]);
/// R2 = 2^(384*2) mod p
const R2: Fp = Fp([
0xf4df1f341c341746,
0xa76e6a609d104f1,
0x8de5476c4c95b6d5,
0x67eb88a9939d83c0,
0x9a793e85b519952d,
0x11988fe592cae3aa,
0xf4df_1f34_1c34_1746,
0x0a76_e6a6_09d1_04f1,
0x8de5_476c_4c95_b6d5,
0x67eb_88a9_939d_83c0,
0x9a79_3e85_b519_952d,
0x1198_8fe5_92ca_e3aa,
]);
impl<'a> Neg for &'a Fp {
@ -227,12 +227,12 @@ impl Fp {
self.0[0], self.0[1], self.0[2], self.0[3], self.0[4], self.0[5], 0, 0, 0, 0, 0, 0,
);
let (_, borrow) = sbb(tmp.0[0], 0xdcff7fffffffd556, 0);
let (_, borrow) = sbb(tmp.0[1], 0x0f55ffff58a9ffff, borrow);
let (_, borrow) = sbb(tmp.0[2], 0xb39869507b587b12, borrow);
let (_, borrow) = sbb(tmp.0[3], 0xb23ba5c279c2895f, borrow);
let (_, borrow) = sbb(tmp.0[4], 0x258dd3db21a5d66b, borrow);
let (_, borrow) = sbb(tmp.0[5], 0x0d0088f51cbff34d, borrow);
let (_, borrow) = sbb(tmp.0[0], 0xdcff_7fff_ffff_d556, 0);
let (_, borrow) = sbb(tmp.0[1], 0x0f55_ffff_58a9_ffff, borrow);
let (_, borrow) = sbb(tmp.0[2], 0xb398_6950_7b58_7b12, borrow);
let (_, borrow) = sbb(tmp.0[3], 0xb23b_a5c2_79c2_895f, borrow);
let (_, borrow) = sbb(tmp.0[4], 0x258d_d3db_21a5_d66b, borrow);
let (_, borrow) = sbb(tmp.0[5], 0x0d00_88f5_1cbf_f34d, borrow);
// If the element was smaller, the subtraction will underflow
// producing a borrow value of 0xffff...ffff, otherwise it will
@ -274,12 +274,12 @@ impl Fp {
// so we check that we got the correct result at the end.
let sqrt = self.pow_vartime(&[
0xee7fbfffffffeaab,
0x7aaffffac54ffff,
0xd9cc34a83dac3d89,
0xd91dd2e13ce144af,
0x92c6e9ed90d2eb35,
0x680447a8e5ff9a6,
0xee7f_bfff_ffff_eaab,
0x07aa_ffff_ac54_ffff,
0xd9cc_34a8_3dac_3d89,
0xd91d_d2e1_3ce1_44af,
0x92c6_e9ed_90d2_eb35,
0x0680_447a_8e5f_f9a6,
]);
CtOption::new(sqrt, sqrt.square().ct_eq(self))
@ -292,12 +292,12 @@ impl Fp {
pub fn invert(&self) -> CtOption<Self> {
// Exponentiate by p - 2
let t = self.pow_vartime(&[
0xb9feffffffffaaa9,
0x1eabfffeb153ffff,
0x6730d2a0f6b0f624,
0x64774b84f38512bf,
0x4b1ba7b6434bacd7,
0x1a0111ea397fe69a,
0xb9fe_ffff_ffff_aaa9,
0x1eab_fffe_b153_ffff,
0x6730_d2a0_f6b0_f624,
0x6477_4b84_f385_12bf,
0x4b1b_a7b6_434b_acd7,
0x1a01_11ea_397f_e69a,
]);
CtOption::new(t, !self.is_zero())
@ -584,20 +584,20 @@ fn test_equality() {
#[test]
fn test_squaring() {
let a = Fp([
0xd215d2768e83191b,
0x5085d80f8fb28261,
0xce9a032ddf393a56,
0x3e9c4fff2ca0c4bb,
0x6436b6f7f4d95dfb,
0x10606628ad4a4d90,
0xd215_d276_8e83_191b,
0x5085_d80f_8fb2_8261,
0xce9a_032d_df39_3a56,
0x3e9c_4fff_2ca0_c4bb,
0x6436_b6f7_f4d9_5dfb,
0x1060_6628_ad4a_4d90,
]);
let b = Fp([
0x33d9c42a3cb3e235,
0xdad11a094c4cd455,
0xa2f144bd729aaeba,
0xd4150932be9ffeac,
0xe27bc7c47d44ee50,
0x14b6a78d3ec7a560,
0x33d9_c42a_3cb3_e235,
0xdad1_1a09_4c4c_d455,
0xa2f1_44bd_729a_aeba,
0xd415_0932_be9f_feac,
0xe27b_c7c4_7d44_ee50,
0x14b6_a78d_3ec7_a560,
]);
assert_eq!(a.square(), b);
@ -606,28 +606,28 @@ fn test_squaring() {
#[test]
fn test_multiplication() {
let a = Fp([
0x397a38320170cd4,
0x734c1b2c9e761d30,
0x5ed255ad9a48beb5,
0x95a3c6b22a7fcfc,
0x2294ce75d4e26a27,
0x13338bd870011ebb,
0x0397_a383_2017_0cd4,
0x734c_1b2c_9e76_1d30,
0x5ed2_55ad_9a48_beb5,
0x095a_3c6b_22a7_fcfc,
0x2294_ce75_d4e2_6a27,
0x1333_8bd8_7001_1ebb,
]);
let b = Fp([
0xb9c3c7c5b1196af7,
0x2580e2086ce335c1,
0xf49aed3d8a57ef42,
0x41f281e49846e878,
0xe0762346c38452ce,
0x652e89326e57dc0,
0xb9c3_c7c5_b119_6af7,
0x2580_e208_6ce3_35c1,
0xf49a_ed3d_8a57_ef42,
0x41f2_81e4_9846_e878,
0xe076_2346_c384_52ce,
0x0652_e893_26e5_7dc0,
]);
let c = Fp([
0xf96ef3d711ab5355,
0xe8d459ea00f148dd,
0x53f7354a5f00fa78,
0x9e34a4f3125c5f83,
0x3fbe0c47ca74c19e,
0x1b06a8bbd4adfe4,
0xf96e_f3d7_11ab_5355,
0xe8d4_59ea_00f1_48dd,
0x53f7_354a_5f00_fa78,
0x9e34_a4f3_125c_5f83,
0x3fbe_0c47_ca74_c19e,
0x01b0_6a8b_bd4a_dfe4,
]);
assert_eq!(a * b, c);
@ -636,28 +636,28 @@ fn test_multiplication() {
#[test]
fn test_addition() {
let a = Fp([
0x5360bb5978678032,
0x7dd275ae799e128e,
0x5c5b5071ce4f4dcf,
0xcdb21f93078dbb3e,
0xc32365c5e73f474a,
0x115a2a5489babe5b,
0x5360_bb59_7867_8032,
0x7dd2_75ae_799e_128e,
0x5c5b_5071_ce4f_4dcf,
0xcdb2_1f93_078d_bb3e,
0xc323_65c5_e73f_474a,
0x115a_2a54_89ba_be5b,
]);
let b = Fp([
0x9fd287733d23dda0,
0xb16bf2af738b3554,
0x3e57a75bd3cc6d1d,
0x900bc0bd627fd6d6,
0xd319a080efb245fe,
0x15fdcaa4e4bb2091,
0x9fd2_8773_3d23_dda0,
0xb16b_f2af_738b_3554,
0x3e57_a75b_d3cc_6d1d,
0x900b_c0bd_627f_d6d6,
0xd319_a080_efb2_45fe,
0x15fd_caa4_e4bb_2091,
]);
let c = Fp([
0x393442ccb58bb327,
0x1092685f3bd547e3,
0x3382252cab6ac4c9,
0xf94694cb76887f55,
0x4b215e9093a5e071,
0xd56e30f34f5f853,
0x3934_42cc_b58b_b327,
0x1092_685f_3bd5_47e3,
0x3382_252c_ab6a_c4c9,
0xf946_94cb_7688_7f55,
0x4b21_5e90_93a5_e071,
0x0d56_e30f_34f5_f853,
]);
assert_eq!(a + b, c);
@ -666,28 +666,28 @@ fn test_addition() {
#[test]
fn test_subtraction() {
let a = Fp([
0x5360bb5978678032,
0x7dd275ae799e128e,
0x5c5b5071ce4f4dcf,
0xcdb21f93078dbb3e,
0xc32365c5e73f474a,
0x115a2a5489babe5b,
0x5360_bb59_7867_8032,
0x7dd2_75ae_799e_128e,
0x5c5b_5071_ce4f_4dcf,
0xcdb2_1f93_078d_bb3e,
0xc323_65c5_e73f_474a,
0x115a_2a54_89ba_be5b,
]);
let b = Fp([
0x9fd287733d23dda0,
0xb16bf2af738b3554,
0x3e57a75bd3cc6d1d,
0x900bc0bd627fd6d6,
0xd319a080efb245fe,
0x15fdcaa4e4bb2091,
0x9fd2_8773_3d23_dda0,
0xb16b_f2af_738b_3554,
0x3e57_a75b_d3cc_6d1d,
0x900b_c0bd_627f_d6d6,
0xd319_a080_efb2_45fe,
0x15fd_caa4_e4bb_2091,
]);
let c = Fp([
0x6d8d33e63b434d3d,
0xeb1282fdb766dd39,
0x85347bb6f133d6d5,
0xa21daa5a9892f727,
0x3b256cfb3ad8ae23,
0x155d7199de7f8464,
0x6d8d_33e6_3b43_4d3d,
0xeb12_82fd_b766_dd39,
0x8534_7bb6_f133_d6d5,
0xa21d_aa5a_9892_f727,
0x3b25_6cfb_3ad8_ae23,
0x155d_7199_de7f_8464,
]);
assert_eq!(a - b, c);
@ -696,20 +696,20 @@ fn test_subtraction() {
#[test]
fn test_negation() {
let a = Fp([
0x5360bb5978678032,
0x7dd275ae799e128e,
0x5c5b5071ce4f4dcf,
0xcdb21f93078dbb3e,
0xc32365c5e73f474a,
0x115a2a5489babe5b,
0x5360_bb59_7867_8032,
0x7dd2_75ae_799e_128e,
0x5c5b_5071_ce4f_4dcf,
0xcdb2_1f93_078d_bb3e,
0xc323_65c5_e73f_474a,
0x115a_2a54_89ba_be5b,
]);
let b = Fp([
0x669e44a687982a79,
0xa0d98a5037b5ed71,
0xad5822f2861a854,
0x96c52bf1ebf75781,
0x87f841f05c0c658c,
0x8a6e795afc5283e,
0x669e_44a6_8798_2a79,
0xa0d9_8a50_37b5_ed71,
0x0ad5_822f_2861_a854,
0x96c5_2bf1_ebf7_5781,
0x87f8_41f0_5c0c_658c,
0x08a6_e795_afc5_283e,
]);
assert_eq!(-a, b);
@ -720,7 +720,14 @@ fn test_debug() {
assert_eq!(
format!(
"{:?}",
Fp([0x5360bb5978678032, 0x7dd275ae799e128e, 0x5c5b5071ce4f4dcf, 0xcdb21f93078dbb3e, 0xc32365c5e73f474a, 0x115a2a5489babe5b])
Fp([
0x5360_bb59_7867_8032,
0x7dd2_75ae_799e_128e,
0x5c5b_5071_ce4f_4dcf,
0xcdb2_1f93_078d_bb3e,
0xc323_65c5_e73f_474a,
0x115a_2a54_89ba_be5b,
])
),
"0x104bf052ad3bc99bcb176c24a06a6c3aad4eaf2308fc4d282e106c84a757d061052630515305e59bdddf8111bfdeb704"
);
@ -729,12 +736,12 @@ fn test_debug() {
#[test]
fn test_from_bytes() {
let mut a = Fp([
0xdc906d9be3f95dc8,
0x8755caf7459691a1,
0xcff1a7f4e9583ab3,
0x9b43821f849e2284,
0xf57554f3a2974f3f,
0x85dbea84ed47f79,
0xdc90_6d9b_e3f9_5dc8,
0x8755_caf7_4596_91a1,
0xcff1_a7f4_e958_3ab3,
0x9b43_821f_849e_2284,
0xf575_54f3_a297_4f3f,
0x085d_bea8_4ed4_7f79,
]);
for _ in 0..100 {
@ -773,12 +780,12 @@ fn test_from_bytes() {
fn test_sqrt() {
// a = 4
let a = Fp::from_raw_unchecked([
0xaa270000000cfff3,
0x53cc0032fc34000a,
0x478fe97a6b0a807f,
0xb1d37ebee6ba24d7,
0x8ec9733bbf78ab2f,
0x9d645513d83de7e,
0xaa27_0000_000c_fff3,
0x53cc_0032_fc34_000a,
0x478f_e97a_6b0a_807f,
0xb1d3_7ebe_e6ba_24d7,
0x8ec9_733b_bf78_ab2f,
0x09d6_4551_3d83_de7e,
]);
assert_eq!(
@ -786,12 +793,12 @@ fn test_sqrt() {
-a.sqrt().unwrap(),
// 2
Fp::from_raw_unchecked([
0x321300000006554f,
0xb93c0018d6c40005,
0x57605e0db0ddbb51,
0x8b256521ed1f9bcb,
0x6cf28d7901622c03,
0x11ebab9dbb81e28c
0x3213_0000_0006_554f,
0xb93c_0018_d6c4_0005,
0x5760_5e0d_b0dd_bb51,
0x8b25_6521_ed1f_9bcb,
0x6cf2_8d79_0162_2c03,
0x11eb_ab9d_bb81_e28c,
])
);
}
@ -799,20 +806,20 @@ fn test_sqrt() {
#[test]
fn test_inversion() {
let a = Fp([
0x43b43a5078ac2076,
0x1ce0763046f8962b,
0x724a5276486d735c,
0x6f05c2a6282d48fd,
0x2095bd5bb4ca9331,
0x3b35b3894b0f7da,
0x43b4_3a50_78ac_2076,
0x1ce0_7630_46f8_962b,
0x724a_5276_486d_735c,
0x6f05_c2a6_282d_48fd,
0x2095_bd5b_b4ca_9331,
0x03b3_5b38_94b0_f7da,
]);
let b = Fp([
0x69ecd7040952148f,
0x985ccc2022190f55,
0xe19bba36a9ad2f41,
0x19bb16c95219dbd8,
0x14dcacfdfb478693,
0x115ff58afff9a8e1,
0x69ec_d704_0952_148f,
0x985c_cc20_2219_0f55,
0xe19b_ba36_a9ad_2f41,
0x19bb_16c9_5219_dbd8,
0x14dc_acfd_fb47_8693,
0x115f_f58a_fff9_a8e1,
]);
assert_eq!(a.invert().unwrap(), b);
@ -825,34 +832,34 @@ fn test_lexicographic_largest() {
assert!(!bool::from(Fp::one().lexicographically_largest()));
assert!(!bool::from(
Fp::from_raw_unchecked([
0xa1fafffffffe5557,
0x995bfff976a3fffe,
0x3f41d24d174ceb4,
0xf6547998c1995dbd,
0x778a468f507a6034,
0x20559931f7f8103
0xa1fa_ffff_fffe_5557,
0x995b_fff9_76a3_fffe,
0x03f4_1d24_d174_ceb4,
0xf654_7998_c199_5dbd,
0x778a_468f_507a_6034,
0x0205_5993_1f7f_8103
])
.lexicographically_largest()
));
assert!(bool::from(
Fp::from_raw_unchecked([
0x1804000000015554,
0x855000053ab00001,
0x633cb57c253c276f,
0x6e22d1ec31ebb502,
0xd3916126f2d14ca2,
0x17fbb8571a006596
0x1804_0000_0001_5554,
0x8550_0005_3ab0_0001,
0x633c_b57c_253c_276f,
0x6e22_d1ec_31eb_b502,
0xd391_6126_f2d1_4ca2,
0x17fb_b857_1a00_6596,
])
.lexicographically_largest()
));
assert!(bool::from(
Fp::from_raw_unchecked([
0x43f5fffffffcaaae,
0x32b7fff2ed47fffd,
0x7e83a49a2e99d69,
0xeca8f3318332bb7a,
0xef148d1ea0f4c069,
0x40ab3263eff0206
0x43f5_ffff_fffc_aaae,
0x32b7_fff2_ed47_fffd,
0x07e8_3a49_a2e9_9d69,
0xeca8_f331_8332_bb7a,
0xef14_8d1e_a0f4_c069,
0x040a_b326_3eff_0206,
])
.lexicographically_largest()
));

View File

@ -136,20 +136,20 @@ impl Fp12 {
let c1 = c1
* Fp6::from(Fp2 {
c0: Fp::from_raw_unchecked([
0x7089552b319d465,
0xc6695f92b50a8313,
0x97e83cccd117228f,
0xa35baecab2dc29ee,
0x1ce393ea5daace4d,
0x8f2220fb0fb66eb,
0x0708_9552_b319_d465,
0xc669_5f92_b50a_8313,
0x97e8_3ccc_d117_228f,
0xa35b_aeca_b2dc_29ee,
0x1ce3_93ea_5daa_ce4d,
0x08f2_220f_b0fb_66eb,
]),
c1: Fp::from_raw_unchecked([
0xb2f66aad4ce5d646,
0x5842a06bfc497cec,
0xcf4895d42599d394,
0xc11b9cba40a8e8d0,
0x2e3813cbe5a0de89,
0x110eefda88847faf,
0xb2f6_6aad_4ce5_d646,
0x5842_a06b_fc49_7cec,
0xcf48_95d4_2599_d394,
0xc11b_9cba_40a8_e8d0,
0x2e38_13cb_e5a0_de89,
0x110e_efda_8884_7faf,
]),
});
@ -256,112 +256,112 @@ fn test_arithmetic() {
c0: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c5744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_c040,
]),
},
},
c1: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c5744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_c040,
]),
},
},
@ -371,112 +371,112 @@ fn test_arithmetic() {
c0: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d272c9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d272_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe348,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e348,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c5744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_c040,
]),
},
},
c1: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd21db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd2_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa117df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a117_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c5744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_c040,
]),
},
},
@ -486,112 +486,112 @@ fn test_arithmetic() {
c0: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb9871b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_71b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0x7791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0x7791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b133c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_133c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76240e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_40e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c1744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_1744_c040,
]),
},
},
c1: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d3c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d3_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c57441040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_1040,
]),
},
},
@ -600,24 +600,21 @@ fn test_arithmetic() {
// because a and b and c are similar to each other and
// I was lazy, this is just some arbitrary way to make
// them a little more different
let a = &a.square().invert().unwrap().square() + &c;
let b = &b.square().invert().unwrap().square() + &a;
let c = &c.square().invert().unwrap().square() + &b;
let a = a.square().invert().unwrap().square() + c;
let b = b.square().invert().unwrap().square() + a;
let c = c.square().invert().unwrap().square() + b;
assert_eq!(a.square(), &a * &a);
assert_eq!(b.square(), &b * &b);
assert_eq!(c.square(), &c * &c);
assert_eq!(a.square(), a * a);
assert_eq!(b.square(), b * b);
assert_eq!(c.square(), c * c);
assert_eq!((a + b) * c.square(), (c * c * a) + (c * c * b));
assert_eq!(
(a + b) * c.square(),
&(&(&c * &c) * &a) + &(&(&c * &c) * &b)
a.invert().unwrap() * b.invert().unwrap(),
(a * b).invert().unwrap()
);
assert_eq!(
&a.invert().unwrap() * &b.invert().unwrap(),
(&a * &b).invert().unwrap()
);
assert_eq!(&a.invert().unwrap() * &a, Fp12::one());
assert_eq!(a.invert().unwrap() * a, Fp12::one());
assert!(a != a.frobenius_map());
assert_eq!(

View File

@ -247,12 +247,12 @@ impl Fp2 {
CtOption::new(Fp2::zero(), self.is_zero()).or_else(|| {
// a1 = self^((p - 3) / 4)
let a1 = self.pow_vartime(&[
0xee7fbfffffffeaaa,
0x7aaffffac54ffff,
0xd9cc34a83dac3d89,
0xd91dd2e13ce144af,
0x92c6e9ed90d2eb35,
0x680447a8e5ff9a6,
0xee7f_bfff_ffff_eaaa,
0x07aa_ffff_ac54_ffff,
0xd9cc_34a8_3dac_3d89,
0xd91d_d2e1_3ce1_44af,
0x92c6_e9ed_90d2_eb35,
0x0680_447a_8e5f_f9a6,
]);
// alpha = a1^2 * self = self^((p - 3) / 2 + 1) = self^((p - 1) / 2)
@ -276,12 +276,12 @@ impl Fp2 {
.or_else(|| {
CtOption::new(
(alpha + Fp2::one()).pow_vartime(&[
0xdcff7fffffffd555,
0xf55ffff58a9ffff,
0xb39869507b587b12,
0xb23ba5c279c2895f,
0x258dd3db21a5d66b,
0xd0088f51cbff34d,
0xdcff_7fff_ffff_d555,
0x0f55_ffff_58a9_ffff,
0xb398_6950_7b58_7b12,
0xb23b_a5c2_79c2_895f,
0x258d_d3db_21a5_d66b,
0x0d00_88f5_1cbf_f34d,
]) * x0,
Choice::from(1),
)
@ -404,38 +404,38 @@ fn test_equality() {
fn test_squaring() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0xc9a2183163ee70d4,
0xbc3770a7196b5c91,
0xa247f8c1304c5f44,
0xb01fc2a3726c80b5,
0xe1d293e5bbd919c9,
0x4b78e80020ef2ca,
0xc9a2_1831_63ee_70d4,
0xbc37_70a7_196b_5c91,
0xa247_f8c1_304c_5f44,
0xb01f_c2a3_726c_80b5,
0xe1d2_93e5_bbd9_19c9,
0x04b7_8e80_020e_f2ca,
]),
c1: Fp::from_raw_unchecked([
0x952ea4460462618f,
0x238d5eddf025c62f,
0xf6c94b012ea92e72,
0x3ce24eac1c93808,
0x55950f945da483c,
0x10a768d0df4eabc,
0x952e_a446_0462_618f,
0x238d_5edd_f025_c62f,
0xf6c9_4b01_2ea9_2e72,
0x03ce_24ea_c1c9_3808,
0x0559_50f9_45da_483c,
0x010a_768d_0df4_eabc,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0xa1e09175a4d2c1fe,
0x8b33acfc204eff12,
0xe24415a11b456e42,
0x61d996b1b6ee1936,
0x1164dbe8667c853c,
0x788557acc7d9c79,
0xa1e0_9175_a4d2_c1fe,
0x8b33_acfc_204e_ff12,
0xe244_15a1_1b45_6e42,
0x61d9_96b1_b6ee_1936,
0x1164_dbe8_667c_853c,
0x0788_557a_cc7d_9c79,
]),
c1: Fp::from_raw_unchecked([
0xda6a87cc6f48fa36,
0xfc7b488277c1903,
0x9445ac4adc448187,
0x2616d5bc9099209,
0xdbed46772db58d48,
0x11b94d5076c7b7b1,
0xda6a_87cc_6f48_fa36,
0x0fc7_b488_277c_1903,
0x9445_ac4a_dc44_8187,
0x0261_6d5b_c909_9209,
0xdbed_4677_2db5_8d48,
0x11b9_4d50_76c7_b7b1,
]),
};
@ -446,56 +446,56 @@ fn test_squaring() {
fn test_multiplication() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0xc9a2183163ee70d4,
0xbc3770a7196b5c91,
0xa247f8c1304c5f44,
0xb01fc2a3726c80b5,
0xe1d293e5bbd919c9,
0x4b78e80020ef2ca,
0xc9a2_1831_63ee_70d4,
0xbc37_70a7_196b_5c91,
0xa247_f8c1_304c_5f44,
0xb01f_c2a3_726c_80b5,
0xe1d2_93e5_bbd9_19c9,
0x04b7_8e80_020e_f2ca,
]),
c1: Fp::from_raw_unchecked([
0x952ea4460462618f,
0x238d5eddf025c62f,
0xf6c94b012ea92e72,
0x3ce24eac1c93808,
0x55950f945da483c,
0x10a768d0df4eabc,
0x952e_a446_0462_618f,
0x238d_5edd_f025_c62f,
0xf6c9_4b01_2ea9_2e72,
0x03ce_24ea_c1c9_3808,
0x0559_50f9_45da_483c,
0x010a_768d_0df4_eabc,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0xa1e09175a4d2c1fe,
0x8b33acfc204eff12,
0xe24415a11b456e42,
0x61d996b1b6ee1936,
0x1164dbe8667c853c,
0x788557acc7d9c79,
0xa1e0_9175_a4d2_c1fe,
0x8b33_acfc_204e_ff12,
0xe244_15a1_1b45_6e42,
0x61d9_96b1_b6ee_1936,
0x1164_dbe8_667c_853c,
0x0788_557a_cc7d_9c79,
]),
c1: Fp::from_raw_unchecked([
0xda6a87cc6f48fa36,
0xfc7b488277c1903,
0x9445ac4adc448187,
0x2616d5bc9099209,
0xdbed46772db58d48,
0x11b94d5076c7b7b1,
0xda6a_87cc_6f48_fa36,
0x0fc7_b488_277c_1903,
0x9445_ac4a_dc44_8187,
0x0261_6d5b_c909_9209,
0xdbed_4677_2db5_8d48,
0x11b9_4d50_76c7_b7b1,
]),
};
let c = Fp2 {
c0: Fp::from_raw_unchecked([
0xf597483e27b4e0f7,
0x610fbadf811dae5f,
0x8432af917714327a,
0x6a9a9603cf88f09e,
0xf05a7bf8bad0eb01,
0x9549131c003ffae,
0xf597_483e_27b4_e0f7,
0x610f_badf_811d_ae5f,
0x8432_af91_7714_327a,
0x6a9a_9603_cf88_f09e,
0xf05a_7bf8_bad0_eb01,
0x0954_9131_c003_ffae,
]),
c1: Fp::from_raw_unchecked([
0x963b02d0f93d37cd,
0xc95ce1cdb30a73d4,
0x308725fa3126f9b8,
0x56da3c167fab0d50,
0x6b5086b5f4b6d6af,
0x9c39f062f18e9f2,
0x963b_02d0_f93d_37cd,
0xc95c_e1cd_b30a_73d4,
0x3087_25fa_3126_f9b8,
0x56da_3c16_7fab_0d50,
0x6b50_86b5_f4b6_d6af,
0x09c3_9f06_2f18_e9f2,
]),
};
@ -506,56 +506,56 @@ fn test_multiplication() {
fn test_addition() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0xc9a2183163ee70d4,
0xbc3770a7196b5c91,
0xa247f8c1304c5f44,
0xb01fc2a3726c80b5,
0xe1d293e5bbd919c9,
0x4b78e80020ef2ca,
0xc9a2_1831_63ee_70d4,
0xbc37_70a7_196b_5c91,
0xa247_f8c1_304c_5f44,
0xb01f_c2a3_726c_80b5,
0xe1d2_93e5_bbd9_19c9,
0x04b7_8e80_020e_f2ca,
]),
c1: Fp::from_raw_unchecked([
0x952ea4460462618f,
0x238d5eddf025c62f,
0xf6c94b012ea92e72,
0x3ce24eac1c93808,
0x55950f945da483c,
0x10a768d0df4eabc,
0x952e_a446_0462_618f,
0x238d_5edd_f025_c62f,
0xf6c9_4b01_2ea9_2e72,
0x03ce_24ea_c1c9_3808,
0x0559_50f9_45da_483c,
0x010a_768d_0df4_eabc,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0xa1e09175a4d2c1fe,
0x8b33acfc204eff12,
0xe24415a11b456e42,
0x61d996b1b6ee1936,
0x1164dbe8667c853c,
0x788557acc7d9c79,
0xa1e0_9175_a4d2_c1fe,
0x8b33_acfc_204e_ff12,
0xe244_15a1_1b45_6e42,
0x61d9_96b1_b6ee_1936,
0x1164_dbe8_667c_853c,
0x0788_557a_cc7d_9c79,
]),
c1: Fp::from_raw_unchecked([
0xda6a87cc6f48fa36,
0xfc7b488277c1903,
0x9445ac4adc448187,
0x2616d5bc9099209,
0xdbed46772db58d48,
0x11b94d5076c7b7b1,
0xda6a_87cc_6f48_fa36,
0x0fc7_b488_277c_1903,
0x9445_ac4a_dc44_8187,
0x0261_6d5b_c909_9209,
0xdbed_4677_2db5_8d48,
0x11b9_4d50_76c7_b7b1,
]),
};
let c = Fp2 {
c0: Fp::from_raw_unchecked([
0x6b82a9a708c132d2,
0x476b1da339ba5ba4,
0x848c0e624b91cd87,
0x11f95955295a99ec,
0xf3376fce22559f06,
0xc3fe3face8c8f43,
0x6b82_a9a7_08c1_32d2,
0x476b_1da3_39ba_5ba4,
0x848c_0e62_4b91_cd87,
0x11f9_5955_295a_99ec,
0xf337_6fce_2255_9f06,
0x0c3f_e3fa_ce8c_8f43,
]),
c1: Fp::from_raw_unchecked([
0x6f992c1273ab5bc5,
0x3355136617a1df33,
0x8b0ef74c0aedaff9,
0x62f92468ad2ca12,
0xe1469770738fd584,
0x12c3c3dd84bca26d,
0x6f99_2c12_73ab_5bc5,
0x3355_1366_17a1_df33,
0x8b0e_f74c_0aed_aff9,
0x062f_9246_8ad2_ca12,
0xe146_9770_738f_d584,
0x12c3_c3dd_84bc_a26d,
]),
};
@ -566,56 +566,56 @@ fn test_addition() {
fn test_subtraction() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0xc9a2183163ee70d4,
0xbc3770a7196b5c91,
0xa247f8c1304c5f44,
0xb01fc2a3726c80b5,
0xe1d293e5bbd919c9,
0x4b78e80020ef2ca,
0xc9a2_1831_63ee_70d4,
0xbc37_70a7_196b_5c91,
0xa247_f8c1_304c_5f44,
0xb01f_c2a3_726c_80b5,
0xe1d2_93e5_bbd9_19c9,
0x04b7_8e80_020e_f2ca,
]),
c1: Fp::from_raw_unchecked([
0x952ea4460462618f,
0x238d5eddf025c62f,
0xf6c94b012ea92e72,
0x3ce24eac1c93808,
0x55950f945da483c,
0x10a768d0df4eabc,
0x952e_a446_0462_618f,
0x238d_5edd_f025_c62f,
0xf6c9_4b01_2ea9_2e72,
0x03ce_24ea_c1c9_3808,
0x0559_50f9_45da_483c,
0x010a_768d_0df4_eabc,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0xa1e09175a4d2c1fe,
0x8b33acfc204eff12,
0xe24415a11b456e42,
0x61d996b1b6ee1936,
0x1164dbe8667c853c,
0x788557acc7d9c79,
0xa1e0_9175_a4d2_c1fe,
0x8b33_acfc_204e_ff12,
0xe244_15a1_1b45_6e42,
0x61d9_96b1_b6ee_1936,
0x1164_dbe8_667c_853c,
0x0788_557a_cc7d_9c79,
]),
c1: Fp::from_raw_unchecked([
0xda6a87cc6f48fa36,
0xfc7b488277c1903,
0x9445ac4adc448187,
0x2616d5bc9099209,
0xdbed46772db58d48,
0x11b94d5076c7b7b1,
0xda6a_87cc_6f48_fa36,
0x0fc7_b488_277c_1903,
0x9445_ac4a_dc44_8187,
0x0261_6d5b_c909_9209,
0xdbed_4677_2db5_8d48,
0x11b9_4d50_76c7_b7b1,
]),
};
let c = Fp2 {
c0: Fp::from_raw_unchecked([
0xe1c086bbbf1b5981,
0x4fafc3a9aa705d7e,
0x2734b5c10bb7e726,
0xb2bd7776af037a3e,
0x1b895fb398a84164,
0x17304aef6f113cec,
0xe1c0_86bb_bf1b_5981,
0x4faf_c3a9_aa70_5d7e,
0x2734_b5c1_0bb7_e726,
0xb2bd_7776_af03_7a3e,
0x1b89_5fb3_98a8_4164,
0x1730_4aef_6f11_3cec,
]),
c1: Fp::from_raw_unchecked([
0x74c31c7995191204,
0x3271aa5479fdad2b,
0xc9b471574915a30f,
0x65e40313ec44b8be,
0x7487b2385b7067cb,
0x9523b26d0ad19a4,
0x74c3_1c79_9519_1204,
0x3271_aa54_79fd_ad2b,
0xc9b4_7157_4915_a30f,
0x65e4_0313_ec44_b8be,
0x7487_b238_5b70_67cb,
0x0952_3b26_d0ad_19a4,
]),
};
@ -626,38 +626,38 @@ fn test_subtraction() {
fn test_negation() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0xc9a2183163ee70d4,
0xbc3770a7196b5c91,
0xa247f8c1304c5f44,
0xb01fc2a3726c80b5,
0xe1d293e5bbd919c9,
0x4b78e80020ef2ca,
0xc9a2_1831_63ee_70d4,
0xbc37_70a7_196b_5c91,
0xa247_f8c1_304c_5f44,
0xb01f_c2a3_726c_80b5,
0xe1d2_93e5_bbd9_19c9,
0x04b7_8e80_020e_f2ca,
]),
c1: Fp::from_raw_unchecked([
0x952ea4460462618f,
0x238d5eddf025c62f,
0xf6c94b012ea92e72,
0x3ce24eac1c93808,
0x55950f945da483c,
0x10a768d0df4eabc,
0x952e_a446_0462_618f,
0x238d_5edd_f025_c62f,
0xf6c9_4b01_2ea9_2e72,
0x03ce_24ea_c1c9_3808,
0x0559_50f9_45da_483c,
0x010a_768d_0df4_eabc,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0xf05ce7ce9c1139d7,
0x62748f5797e8a36d,
0xc4e8d9dfc66496df,
0xb45788e181189209,
0x694913d08772930d,
0x1549836a3770f3cf,
0xf05c_e7ce_9c11_39d7,
0x6274_8f57_97e8_a36d,
0xc4e8_d9df_c664_96df,
0xb457_88e1_8118_9209,
0x6949_13d0_8772_930d,
0x1549_836a_3770_f3cf,
]),
c1: Fp::from_raw_unchecked([
0x24d05bb9fb9d491c,
0xfb1ea120c12e39d0,
0x7067879fc807c7b1,
0x60a9269a31bbdab6,
0x45c256bcfd71649b,
0x18f69b5d2b8afbde,
0x24d0_5bb9_fb9d_491c,
0xfb1e_a120_c12e_39d0,
0x7067_879f_c807_c7b1,
0x60a9_269a_31bb_dab6,
0x45c2_56bc_fd71_649b,
0x18f6_9b5d_2b8a_fbde,
]),
};
@ -669,20 +669,20 @@ fn test_sqrt() {
// a = 1488924004771393321054797166853618474668089414631333405711627789629391903630694737978065425271543178763948256226639*u + 784063022264861764559335808165825052288770346101304131934508881646553551234697082295473567906267937225174620141295
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0x2beed14627d7f9e9,
0xb6614e06660e5dce,
0x6c4cc7c2f91d42c,
0x996d78474b7a63cc,
0xebaebc4c820d574e,
0x18865e12d93fd845,
0x2bee_d146_27d7_f9e9,
0xb661_4e06_660e_5dce,
0x06c4_cc7c_2f91_d42c,
0x996d_7847_4b7a_63cc,
0xebae_bc4c_820d_574e,
0x1886_5e12_d93f_d845,
]),
c1: Fp::from_raw_unchecked([
0x7d828664baf4f566,
0xd17e663996ec7339,
0x679ead55cb4078d0,
0xfe3b2260e001ec28,
0x305993d043d91b68,
0x626f03c0489b72d,
0x7d82_8664_baf4_f566,
0xd17e_6639_96ec_7339,
0x679e_ad55_cb40_78d0,
0xfe3b_2260_e001_ec28,
0x3059_93d0_43d9_1b68,
0x0626_f03c_0489_b72d,
]),
};
@ -692,12 +692,12 @@ fn test_sqrt() {
// multiplicative subgroup
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0x6631000000105545,
0x211400400eec000d,
0x3fa7af30c820e316,
0xc52a8b8d6387695d,
0x9fb4e61d1e83eac5,
0x5cb922afe84dc7,
0x6631_0000_0010_5545,
0x2114_0040_0eec_000d,
0x3fa7_af30_c820_e316,
0xc52a_8b8d_6387_695d,
0x9fb4_e61d_1e83_eac5,
0x005c_b922_afe8_4dc7,
]),
c1: Fp::zero(),
};
@ -708,12 +708,12 @@ fn test_sqrt() {
// multiplicative subgroup
let c = Fp2 {
c0: Fp::from_raw_unchecked([
0x44f600000051ffae,
0x86b8014199480043,
0xd7159952f1f3794a,
0x755d6e3dfe1ffc12,
0xd36cd6db5547e905,
0x2f8c8ecbf1867bb,
0x44f6_0000_0051_ffae,
0x86b8_0141_9948_0043,
0xd715_9952_f1f3_794a,
0x755d_6e3d_fe1f_fc12,
0xd36c_d6db_5547_e905,
0x02f8_c8ec_bf18_67bb,
]),
c1: Fp::zero(),
};
@ -725,20 +725,20 @@ fn test_sqrt() {
assert!(bool::from(
Fp2 {
c0: Fp::from_raw_unchecked([
0xc5fa1bc8fd00d7f6,
0x3830ca454606003b,
0x2b287f1104b102da,
0xa7fb30f28230f23e,
0x339cdb9ee953dbf0,
0xd78ec51d989fc57
0xc5fa_1bc8_fd00_d7f6,
0x3830_ca45_4606_003b,
0x2b28_7f11_04b1_02da,
0xa7fb_30f2_8230_f23e,
0x339c_db9e_e953_dbf0,
0x0d78_ec51_d989_fc57,
]),
c1: Fp::from_raw_unchecked([
0x27ec4898cf87f613,
0x9de1394e1abb05a5,
0x947f85dc170fc14,
0x586fbc696b6114b7,
0x2b3475a4077d7169,
0x13e1c895cc4b6c22
0x27ec_4898_cf87_f613,
0x9de1_394e_1abb_05a5,
0x0947_f85d_c170_fc14,
0x586f_bc69_6b61_14b7,
0x2b34_75a4_077d_7169,
0x13e1_c895_cc4b_6c22,
])
}
.sqrt()
@ -750,39 +750,39 @@ fn test_sqrt() {
fn test_inversion() {
let a = Fp2 {
c0: Fp::from_raw_unchecked([
0x1128ecad67549455,
0x9e7a1cff3a4ea1a8,
0xeb208d51e08bcf27,
0xe98ad40811f5fc2b,
0x736c3a59232d511d,
0x10acd42d29cfcbb6,
0x1128_ecad_6754_9455,
0x9e7a_1cff_3a4e_a1a8,
0xeb20_8d51_e08b_cf27,
0xe98a_d408_11f5_fc2b,
0x736c_3a59_232d_511d,
0x10ac_d42d_29cf_cbb6,
]),
c1: Fp::from_raw_unchecked([
0xd328e37cc2f58d41,
0x948df0858a605869,
0x6032f9d56f93a573,
0x2be483ef3fffdc87,
0x30ef61f88f483c2a,
0x1333f55a35725be0,
0xd328_e37c_c2f5_8d41,
0x948d_f085_8a60_5869,
0x6032_f9d5_6f93_a573,
0x2be4_83ef_3fff_dc87,
0x30ef_61f8_8f48_3c2a,
0x1333_f55a_3572_5be0,
]),
};
let b = Fp2 {
c0: Fp::from_raw_unchecked([
0x581a1333d4f48a6,
0x58242f6ef0748500,
0x292c955349e6da5,
0xba37721ddd95fcd0,
0x70d167903aa5dfc5,
0x11895e118b58a9d5,
0x0581_a133_3d4f_48a6,
0x5824_2f6e_f074_8500,
0x0292_c955_349e_6da5,
0xba37_721d_dd95_fcd0,
0x70d1_6790_3aa5_dfc5,
0x1189_5e11_8b58_a9d5,
]),
c1: Fp::from_raw_unchecked([
0xeda09d2d7a85d17,
0x8808e137a7d1a2cf,
0x43ae2625c1ff21db,
0xf85ac9fdf7a74c64,
0x8fccdda5b8da9738,
0x8e84f0cb32cd17d,
0x0eda_09d2_d7a8_5d17,
0x8808_e137_a7d1_a2cf,
0x43ae_2625_c1ff_21db,
0xf85a_c9fd_f7a7_4c64,
0x8fcc_dda5_b8da_9738,
0x08e8_4f0c_b32c_d17d,
]),
};
@ -798,20 +798,20 @@ fn test_lexicographic_largest() {
assert!(bool::from(
Fp2 {
c0: Fp::from_raw_unchecked([
0x1128ecad67549455,
0x9e7a1cff3a4ea1a8,
0xeb208d51e08bcf27,
0xe98ad40811f5fc2b,
0x736c3a59232d511d,
0x10acd42d29cfcbb6,
0x1128_ecad_6754_9455,
0x9e7a_1cff_3a4e_a1a8,
0xeb20_8d51_e08b_cf27,
0xe98a_d408_11f5_fc2b,
0x736c_3a59_232d_511d,
0x10ac_d42d_29cf_cbb6,
]),
c1: Fp::from_raw_unchecked([
0xd328e37cc2f58d41,
0x948df0858a605869,
0x6032f9d56f93a573,
0x2be483ef3fffdc87,
0x30ef61f88f483c2a,
0x1333f55a35725be0,
0xd328_e37c_c2f5_8d41,
0x948d_f085_8a60_5869,
0x6032_f9d5_6f93_a573,
0x2be4_83ef_3fff_dc87,
0x30ef_61f8_8f48_3c2a,
0x1333_f55a_3572_5be0,
]),
}
.lexicographically_largest()
@ -819,20 +819,20 @@ fn test_lexicographic_largest() {
assert!(!bool::from(
Fp2 {
c0: -Fp::from_raw_unchecked([
0x1128ecad67549455,
0x9e7a1cff3a4ea1a8,
0xeb208d51e08bcf27,
0xe98ad40811f5fc2b,
0x736c3a59232d511d,
0x10acd42d29cfcbb6,
0x1128_ecad_6754_9455,
0x9e7a_1cff_3a4e_a1a8,
0xeb20_8d51_e08b_cf27,
0xe98a_d408_11f5_fc2b,
0x736c_3a59_232d_511d,
0x10ac_d42d_29cf_cbb6,
]),
c1: -Fp::from_raw_unchecked([
0xd328e37cc2f58d41,
0x948df0858a605869,
0x6032f9d56f93a573,
0x2be483ef3fffdc87,
0x30ef61f88f483c2a,
0x1333f55a35725be0,
0xd328_e37c_c2f5_8d41,
0x948d_f085_8a60_5869,
0x6032_f9d5_6f93_a573,
0x2be4_83ef_3fff_dc87,
0x30ef_61f8_8f48_3c2a,
0x1333_f55a_3572_5be0,
]),
}
.lexicographically_largest()
@ -840,12 +840,12 @@ fn test_lexicographic_largest() {
assert!(!bool::from(
Fp2 {
c0: Fp::from_raw_unchecked([
0x1128ecad67549455,
0x9e7a1cff3a4ea1a8,
0xeb208d51e08bcf27,
0xe98ad40811f5fc2b,
0x736c3a59232d511d,
0x10acd42d29cfcbb6,
0x1128_ecad_6754_9455,
0x9e7a_1cff_3a4e_a1a8,
0xeb20_8d51_e08b_cf27,
0xe98a_d408_11f5_fc2b,
0x736c_3a59_232d_511d,
0x10ac_d42d_29cf_cbb6,
]),
c1: Fp::zero(),
}
@ -854,12 +854,12 @@ fn test_lexicographic_largest() {
assert!(bool::from(
Fp2 {
c0: -Fp::from_raw_unchecked([
0x1128ecad67549455,
0x9e7a1cff3a4ea1a8,
0xeb208d51e08bcf27,
0xe98ad40811f5fc2b,
0x736c3a59232d511d,
0x10acd42d29cfcbb6,
0x1128_ecad_6754_9455,
0x9e7a_1cff_3a4e_a1a8,
0xeb20_8d51_e08b_cf27,
0xe98a_d408_11f5_fc2b,
0x736c_3a59_232d_511d,
0x10ac_d42d_29cf_cbb6,
]),
c1: Fp::zero(),
}

View File

@ -154,12 +154,12 @@ impl Fp6 {
* Fp2 {
c0: Fp::zero(),
c1: Fp::from_raw_unchecked([
0xcd03c9e48671f071,
0x5dab22461fcda5d2,
0x587042afd3851b95,
0x8eb60ebe01bacb9e,
0x3f97d6e83d050d2,
0x18f0206554638741,
0xcd03_c9e4_8671_f071,
0x5dab_2246_1fcd_a5d2,
0x5870_42af_d385_1b95,
0x8eb6_0ebe_01ba_cb9e,
0x03f9_7d6e_83d0_50d2,
0x18f0_2065_5463_8741,
]),
};
@ -167,12 +167,12 @@ impl Fp6 {
let c2 = c2
* Fp2 {
c0: Fp::from_raw_unchecked([
0x890dc9e4867545c3,
0x2af322533285a5d5,
0x50880866309b7e2c,
0xa20d1b8c7e881024,
0x14e4f04fe2db9068,
0x14e56d3f1564853a,
0x890d_c9e4_8675_45c3,
0x2af3_2253_3285_a5d5,
0x5088_0866_309b_7e2c,
0xa20d_1b8c_7e88_1024,
0x14e4_f04f_e2db_9068,
0x14e5_6d3f_1564_853a,
]),
c1: Fp::zero(),
};
@ -322,56 +322,56 @@ fn test_arithmetic() {
let a = Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x47f9cb98b1b82d58,
0x5fe911eba3aa1d9d,
0x96bf1b5f4dd81db3,
0x8100d27cc9259f5b,
0xafa20b9674640eab,
0x9bbcea7d8d9497d,
0x47f9_cb98_b1b8_2d58,
0x5fe9_11eb_a3aa_1d9d,
0x96bf_1b5f_4dd8_1db3,
0x8100_d27c_c925_9f5b,
0xafa2_0b96_7464_0eab,
0x09bb_cea7_d8d9_497d,
]),
c1: Fp::from_raw_unchecked([
0x303cb98b1662daa,
0xd93110aa0a621d5a,
0xbfa9820c5be4a468,
0xba3643ecb05a348,
0xdc3534bb1f1c25a6,
0x6c305bb19c0e1c1,
0x0303_cb98_b166_2daa,
0xd931_10aa_0a62_1d5a,
0xbfa9_820c_5be4_a468,
0x0ba3_643e_cb05_a348,
0xdc35_34bb_1f1c_25a6,
0x06c3_05bb_19c0_e1c1,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x46f9cb98b162d858,
0xbe9109cf7aa1d57,
0xc791bc55fece41d2,
0xf84c57704e385ec2,
0xcb49c1d9c010e60f,
0xacdb8e158bfe3c8,
0x46f9_cb98_b162_d858,
0x0be9_109c_f7aa_1d57,
0xc791_bc55_fece_41d2,
0xf84c_5770_4e38_5ec2,
0xcb49_c1d9_c010_e60f,
0x0acd_b8e1_58bf_e3c8,
]),
c1: Fp::from_raw_unchecked([
0x8aefcb98b15f8306,
0x3ea1108fe4f21d54,
0xcf79f69fa1b7df3b,
0xe4f54aa1d16b1a3c,
0xba5e4ef86105a679,
0xed86c0797bee5cf,
0x8aef_cb98_b15f_8306,
0x3ea1_108f_e4f2_1d54,
0xcf79_f69f_a1b7_df3b,
0xe4f5_4aa1_d16b_1a3c,
0xba5e_4ef8_6105_a679,
0x0ed8_6c07_97be_e5cf,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xcee5cb98b15c2db4,
0x71591082d23a1d51,
0xd76230e944a17ca4,
0xd19e3dd3549dd5b6,
0xa972dc1701fa66e3,
0x12e31f2dd6bde7d6,
0xcee5_cb98_b15c_2db4,
0x7159_1082_d23a_1d51,
0xd762_30e9_44a1_7ca4,
0xd19e_3dd3_549d_d5b6,
0xa972_dc17_01fa_66e3,
0x12e3_1f2d_d6bd_e7d6,
]),
c1: Fp::from_raw_unchecked([
0xad2acb98b1732d9d,
0x2cfd10dd06961d64,
0x7396b86c6ef24e8,
0xbd76e2fdb1bfc820,
0x6afea7f6de94d0d5,
0x10994b0c5744c040,
0xad2a_cb98_b173_2d9d,
0x2cfd_10dd_0696_1d64,
0x0739_6b86_c6ef_24e8,
0xbd76_e2fd_b1bf_c820,
0x6afe_a7f6_de94_d0d5,
0x1099_4b0c_5744_c040,
]),
},
};
@ -379,56 +379,56 @@ fn test_arithmetic() {
let b = Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0xf120cb98b16fd84b,
0x5fb510cff3de1d61,
0xf21a5d069d8c251,
0xaa1fd62f34f2839a,
0x5a1335157f89913f,
0x14a3fe329643c247,
0xf120_cb98_b16f_d84b,
0x5fb5_10cf_f3de_1d61,
0x0f21_a5d0_69d8_c251,
0xaa1f_d62f_34f2_839a,
0x5a13_3515_7f89_913f,
0x14a3_fe32_9643_c247,
]),
c1: Fp::from_raw_unchecked([
0x3516cb98b16c82f9,
0x926d10c2e1261d5f,
0x1709e01a0cc25fba,
0x96c8c960b8253f14,
0x4927c234207e51a9,
0x18aeb158d542c44e,
0x3516_cb98_b16c_82f9,
0x926d_10c2_e126_1d5f,
0x1709_e01a_0cc2_5fba,
0x96c8_c960_b825_3f14,
0x4927_c234_207e_51a9,
0x18ae_b158_d542_c44e,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0xbf0dcb98b16982fc,
0xa67910b71d1a1d5c,
0xb7c147c2b8fb06ff,
0x1efa710d47d2e7ce,
0xed20a79c7e27653c,
0x2b85294dac1dfba,
0xbf0d_cb98_b169_82fc,
0xa679_10b7_1d1a_1d5c,
0xb7c1_47c2_b8fb_06ff,
0x1efa_710d_47d2_e7ce,
0xed20_a79c_7e27_653c,
0x02b8_5294_dac1_dfba,
]),
c1: Fp::from_raw_unchecked([
0x9d52cb98b18082e5,
0x621d111151761d6f,
0xe79882603b48af43,
0xad31637a4f4da37,
0xaeac737c5ac1cf2e,
0x6e7e735b48b824,
0x9d52_cb98_b180_82e5,
0x621d_1111_5176_1d6f,
0xe798_8260_3b48_af43,
0x0ad3_1637_a4f4_da37,
0xaeac_737c_5ac1_cf2e,
0x006e_7e73_5b48_b824,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0xe148cb98b17d2d93,
0x94d511043ebe1d6c,
0xef80bca9de324cac,
0xf77c0969282795b1,
0x9dc1009afbb68f97,
0x47931999a47ba2b,
0xe148_cb98_b17d_2d93,
0x94d5_1104_3ebe_1d6c,
0xef80_bca9_de32_4cac,
0xf77c_0969_2827_95b1,
0x9dc1_009a_fbb6_8f97,
0x0479_3199_9a47_ba2b,
]),
c1: Fp::from_raw_unchecked([
0x253ecb98b179d841,
0xc78d10f72c061d6a,
0xf768f6f3811bea15,
0xe424fc9aab5a512b,
0x8cd58db99cab5001,
0x883e4bfd946bc32,
0x253e_cb98_b179_d841,
0xc78d_10f7_2c06_1d6a,
0xf768_f6f3_811b_ea15,
0xe424_fc9a_ab5a_512b,
0x8cd5_8db9_9cab_5001,
0x0883_e4bf_d946_bc32,
]),
},
};
@ -436,72 +436,69 @@ fn test_arithmetic() {
let c = Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x6934cb98b17682ef,
0xfa4510ea194e1d67,
0xff51313d2405877e,
0xd0cdefcc2e8d0ca5,
0x7bea1ad83da0106b,
0xc8e97e61845be39,
0x6934_cb98_b176_82ef,
0xfa45_10ea_194e_1d67,
0xff51_313d_2405_877e,
0xd0cd_efcc_2e8d_0ca5,
0x7bea_1ad8_3da0_106b,
0x0c8e_97e6_1845_be39,
]),
c1: Fp::from_raw_unchecked([
0x4779cb98b18d82d8,
0xb5e911444daa1d7a,
0x2f286bdaa6532fc2,
0xbca694f68baeff0f,
0x3d75e6b81a3a7a5d,
0xa44c3c498cc96a3,
0x4779_cb98_b18d_82d8,
0xb5e9_1144_4daa_1d7a,
0x2f28_6bda_a653_2fc2,
0xbca6_94f6_8bae_ff0f,
0x3d75_e6b8_1a3a_7a5d,
0x0a44_c3c4_98cc_96a3,
]),
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x8b6fcb98b18a2d86,
0xe8a111373af21d77,
0x3710a624493ccd2b,
0xa94f88280ee1ba89,
0x2c8a73d6bb2f3ac7,
0xe4f76ead7cb98aa,
0x8b6f_cb98_b18a_2d86,
0xe8a1_1137_3af2_1d77,
0x3710_a624_493c_cd2b,
0xa94f_8828_0ee1_ba89,
0x2c8a_73d6_bb2f_3ac7,
0x0e4f_76ea_d7cb_98aa,
]),
c1: Fp::from_raw_unchecked([
0xcf65cb98b186d834,
0x1b59112a283a1d74,
0x3ef8e06dec266a95,
0x95f87b5992147603,
0x1b9f00f55c23fb31,
0x125a2a1116ca9ab1,
0xcf65_cb98_b186_d834,
0x1b59_112a_283a_1d74,
0x3ef8_e06d_ec26_6a95,
0x95f8_7b59_9214_7603,
0x1b9f_00f5_5c23_fb31,
0x125a_2a11_16ca_9ab1,
]),
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0x135bcb98b18382e2,
0x4e11111d15821d72,
0x46e11ab78f1007fe,
0x82a16e8b1547317d,
0xab38e13fd18bb9b,
0x1664dd3755c99cb8,
0x135b_cb98_b183_82e2,
0x4e11_111d_1582_1d72,
0x46e1_1ab7_8f10_07fe,
0x82a1_6e8b_1547_317d,
0x0ab3_8e13_fd18_bb9b,
0x1664_dd37_55c9_9cb8,
]),
c1: Fp::from_raw_unchecked([
0xce65cb98b1318334,
0xc7590fdb7c3a1d2e,
0x6fcb81649d1c8eb3,
0xd44004d1727356a,
0x3746b738a7d0d296,
0x136c144a96b134fc,
0xce65_cb98_b131_8334,
0xc759_0fdb_7c3a_1d2e,
0x6fcb_8164_9d1c_8eb3,
0x0d44_004d_1727_356a,
0x3746_b738_a7d0_d296,
0x136c_144a_96b1_34fc,
]),
},
};
assert_eq!(a.square(), &a * &a);
assert_eq!(b.square(), &b * &b);
assert_eq!(c.square(), &c * &c);
assert_eq!(a.square(), a * a);
assert_eq!(b.square(), b * b);
assert_eq!(c.square(), c * c);
assert_eq!((a + b) * c.square(), (c * c * a) + (c * c * b));
assert_eq!(
(a + b) * c.square(),
&(&(&c * &c) * &a) + &(&(&c * &c) * &b)
a.invert().unwrap() * b.invert().unwrap(),
(a * b).invert().unwrap()
);
assert_eq!(
&a.invert().unwrap() * &b.invert().unwrap(),
(&a * &b).invert().unwrap()
);
assert_eq!(&a.invert().unwrap() * &a, Fp6::one());
assert_eq!(a.invert().unwrap() * a, Fp6::one());
}

View File

@ -144,12 +144,12 @@ impl_binops_additive!(G1Projective, G1Affine);
impl_binops_additive_specify_output!(G1Affine, G1Projective, G1Projective);
const B: Fp = Fp::from_raw_unchecked([
0xaa270000000cfff3,
0x53cc0032fc34000a,
0x478fe97a6b0a807f,
0xb1d37ebee6ba24d7,
0x8ec9733bbf78ab2f,
0x9d645513d83de7e,
0xaa27_0000_000c_fff3,
0x53cc_0032_fc34_000a,
0x478f_e97a_6b0a_807f,
0xb1d3_7ebe_e6ba_24d7,
0x8ec9_733b_bf78_ab2f,
0x09d6_4551_3d83_de7e,
]);
impl G1Affine {
@ -167,20 +167,20 @@ impl G1Affine {
pub fn generator() -> G1Affine {
G1Affine {
x: Fp::from_raw_unchecked([
0x5cb38790fd530c16,
0x7817fc679976fff5,
0x154f95c7143ba1c1,
0xf0ae6acdf3d0e747,
0xedce6ecc21dbf440,
0x120177419e0bfb75,
0x5cb3_8790_fd53_0c16,
0x7817_fc67_9976_fff5,
0x154f_95c7_143b_a1c1,
0xf0ae_6acd_f3d0_e747,
0xedce_6ecc_21db_f440,
0x1201_7741_9e0b_fb75,
]),
y: Fp::from_raw_unchecked([
0xbaac93d50ce72271,
0x8c22631a7918fd8e,
0xdd595f13570725ce,
0x51ac582950405194,
0xe1c8c3fad0059c0,
0xbbc3efc5008a26a,
0xbaac_93d5_0ce7_2271,
0x8c22_631a_7918_fd8e,
0xdd59_5f13_5707_25ce,
0x51ac_5829_5040_5194,
0x0e1c_8c3f_ad00_59c0,
0x0bbc_3efc_5008_a26a,
]),
infinity: Choice::from(0u8),
}
@ -527,20 +527,20 @@ impl G1Projective {
pub fn generator() -> G1Projective {
G1Projective {
x: Fp::from_raw_unchecked([
0x5cb38790fd530c16,
0x7817fc679976fff5,
0x154f95c7143ba1c1,
0xf0ae6acdf3d0e747,
0xedce6ecc21dbf440,
0x120177419e0bfb75,
0x5cb3_8790_fd53_0c16,
0x7817_fc67_9976_fff5,
0x154f_95c7_143b_a1c1,
0xf0ae_6acd_f3d0_e747,
0xedce_6ecc_21db_f440,
0x1201_7741_9e0b_fb75,
]),
y: Fp::from_raw_unchecked([
0xbaac93d50ce72271,
0x8c22631a7918fd8e,
0xdd595f13570725ce,
0x51ac582950405194,
0xe1c8c3fad0059c0,
0xbbc3efc5008a26a,
0xbaac_93d5_0ce7_2271,
0x8c22_631a_7918_fd8e,
0xdd59_5f13_5707_25ce,
0x51ac_5829_5040_5194,
0x0e1c_8c3f_ad00_59c0,
0x0bbc_3efc_5008_a26a,
]),
z: Fp::one(),
}
@ -801,12 +801,12 @@ fn test_is_on_curve() {
assert!(bool::from(G1Projective::generator().is_on_curve()));
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
let gen = G1Affine::generator();
@ -823,6 +823,7 @@ fn test_is_on_curve() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_affine_point_equality() {
let a = G1Affine::generator();
let b = G1Affine::identity();
@ -834,6 +835,7 @@ fn test_affine_point_equality() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_projective_point_equality() {
let a = G1Projective::generator();
let b = G1Projective::identity();
@ -844,12 +846,12 @@ fn test_projective_point_equality() {
assert!(b != a);
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
let mut c = G1Projective {
@ -915,12 +917,12 @@ fn test_projective_to_affine() {
assert!(bool::from(G1Affine::from(b).is_identity()));
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
let c = G1Projective {
@ -959,20 +961,20 @@ fn test_doubling() {
G1Affine::from(tmp),
G1Affine {
x: Fp::from_raw_unchecked([
0x53e978ce58a9ba3c,
0x3ea0583c4f3d65f9,
0x4d20bb47f0012960,
0xa54c664ae5b2b5d9,
0x26b552a39d7eb21f,
0x8895d26e68785
0x53e9_78ce_58a9_ba3c,
0x3ea0_583c_4f3d_65f9,
0x4d20_bb47_f001_2960,
0xa54c_664a_e5b2_b5d9,
0x26b5_52a3_9d7e_b21f,
0x0008_895d_26e6_8785,
]),
y: Fp::from_raw_unchecked([
0x70110b3298293940,
0xda33c5393f1f6afc,
0xb86edfd16a5aa785,
0xaec6d1c9e7b1c895,
0x25cfc2b522d11720,
0x6361c83f8d09b15
0x7011_0b32_9829_3940,
0xda33_c539_3f1f_6afc,
0xb86e_dfd1_6a5a_a785,
0xaec6_d1c9_e7b1_c895,
0x25cf_c2b5_22d1_1720,
0x0636_1c83_f8d0_9b15,
]),
infinity: Choice::from(0u8)
}
@ -994,12 +996,12 @@ fn test_projective_addition() {
let mut b = G1Projective::generator();
{
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
b = G1Projective {
@ -1018,12 +1020,12 @@ fn test_projective_addition() {
let mut b = G1Projective::generator();
{
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
b = G1Projective {
@ -1044,7 +1046,7 @@ fn test_projective_addition() {
let mut d = G1Projective::generator();
for _ in 0..5 {
d = d + G1Projective::generator();
d += G1Projective::generator();
}
assert!(!bool::from(c.is_identity()));
assert!(bool::from(c.is_on_curve()));
@ -1056,12 +1058,12 @@ fn test_projective_addition() {
// Degenerate case
{
let beta = Fp::from_raw_unchecked([
0xcd03c9e48671f071,
0x5dab22461fcda5d2,
0x587042afd3851b95,
0x8eb60ebe01bacb9e,
0x3f97d6e83d050d2,
0x18f0206554638741,
0xcd03_c9e4_8671_f071,
0x5dab_2246_1fcd_a5d2,
0x5870_42af_d385_1b95,
0x8eb6_0ebe_01ba_cb9e,
0x03f9_7d6e_83d0_50d2,
0x18f0_2065_5463_8741,
]);
let beta = beta.square();
let a = G1Projective::generator().double().double();
@ -1078,20 +1080,20 @@ fn test_projective_addition() {
G1Affine::from(c),
G1Affine::from(G1Projective {
x: Fp::from_raw_unchecked([
0x29e1e987ef68f2d0,
0xc5f3ec531db03233,
0xacd6c4b6ca19730f,
0x18ad9e827bc2bab7,
0x46e3b2c5785cc7a9,
0x7e571d42d22ddd6
0x29e1_e987_ef68_f2d0,
0xc5f3_ec53_1db0_3233,
0xacd6_c4b6_ca19_730f,
0x18ad_9e82_7bc2_bab7,
0x46e3_b2c5_785c_c7a9,
0x07e5_71d4_2d22_ddd6,
]),
y: Fp::from_raw_unchecked([
0x94d117a7e5a539e7,
0x8e17ef673d4b5d22,
0x9d746aaf508a33ea,
0x8c6d883d2516c9a2,
0xbc3b8d5fb0447f7,
0x7bfa4c7210f4f44
0x94d1_17a7_e5a5_39e7,
0x8e17_ef67_3d4b_5d22,
0x9d74_6aaf_508a_33ea,
0x8c6d_883d_2516_c9a2,
0x0bc3_b8d5_fb04_47f7,
0x07bf_a4c7_210f_4f44,
]),
z: Fp::one()
})
@ -1115,12 +1117,12 @@ fn test_mixed_addition() {
let mut b = G1Projective::generator();
{
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
b = G1Projective {
@ -1139,12 +1141,12 @@ fn test_mixed_addition() {
let mut b = G1Projective::generator();
{
let z = Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]);
b = G1Projective {
@ -1165,7 +1167,7 @@ fn test_mixed_addition() {
let mut d = G1Projective::generator();
for _ in 0..5 {
d = d + G1Affine::generator();
d += G1Affine::generator();
}
assert!(!bool::from(c.is_identity()));
assert!(bool::from(c.is_on_curve()));
@ -1177,12 +1179,12 @@ fn test_mixed_addition() {
// Degenerate case
{
let beta = Fp::from_raw_unchecked([
0xcd03c9e48671f071,
0x5dab22461fcda5d2,
0x587042afd3851b95,
0x8eb60ebe01bacb9e,
0x3f97d6e83d050d2,
0x18f0206554638741,
0xcd03_c9e4_8671_f071,
0x5dab_2246_1fcd_a5d2,
0x5870_42af_d385_1b95,
0x8eb6_0ebe_01ba_cb9e,
0x03f9_7d6e_83d0_50d2,
0x18f0_2065_5463_8741,
]);
let beta = beta.square();
let a = G1Projective::generator().double().double();
@ -1200,20 +1202,20 @@ fn test_mixed_addition() {
G1Affine::from(c),
G1Affine::from(G1Projective {
x: Fp::from_raw_unchecked([
0x29e1e987ef68f2d0,
0xc5f3ec531db03233,
0xacd6c4b6ca19730f,
0x18ad9e827bc2bab7,
0x46e3b2c5785cc7a9,
0x7e571d42d22ddd6
0x29e1_e987_ef68_f2d0,
0xc5f3_ec53_1db0_3233,
0xacd6_c4b6_ca19_730f,
0x18ad_9e82_7bc2_bab7,
0x46e3_b2c5_785c_c7a9,
0x07e5_71d4_2d22_ddd6,
]),
y: Fp::from_raw_unchecked([
0x94d117a7e5a539e7,
0x8e17ef673d4b5d22,
0x9d746aaf508a33ea,
0x8c6d883d2516c9a2,
0xbc3b8d5fb0447f7,
0x7bfa4c7210f4f44
0x94d1_17a7_e5a5_39e7,
0x8e17_ef67_3d4b_5d22,
0x9d74_6aaf_508a_33ea,
0x8c6d_883d_2516_c9a2,
0x0bc3_b8d5_fb04_47f7,
0x07bf_a4c7_210f_4f44,
]),
z: Fp::one()
})
@ -1224,6 +1226,7 @@ fn test_mixed_addition() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_projective_negation_and_subtraction() {
let a = G1Projective::generator().double();
assert_eq!(a + (-a), G1Projective::identity());
@ -1241,16 +1244,16 @@ fn test_affine_negation_and_subtraction() {
fn test_projective_scalar_multiplication() {
let g = G1Projective::generator();
let a = Scalar::from_raw([
0x2b568297a56da71c,
0xd8c39ecb0ef375d1,
0x435c38da67bfbf96,
0x8088a05026b659b2,
0x2b56_8297_a56d_a71c,
0xd8c3_9ecb_0ef3_75d1,
0x435c_38da_67bf_bf96,
0x8088_a050_26b6_59b2,
]);
let b = Scalar::from_raw([
0x785fdd9b26ef8b85,
0xc997f25837695c18,
0x4c8dbc39e7b756c1,
0x70d9b6cc6d87df20,
0x785f_dd9b_26ef_8b85,
0xc997_f258_3769_5c18,
0x4c8d_bc39_e7b7_56c1,
0x70d9_b6cc_6d87_df20,
]);
let c = a * b;
@ -1261,16 +1264,16 @@ fn test_projective_scalar_multiplication() {
fn test_affine_scalar_multiplication() {
let g = G1Affine::generator();
let a = Scalar::from_raw([
0x2b568297a56da71c,
0xd8c39ecb0ef375d1,
0x435c38da67bfbf96,
0x8088a05026b659b2,
0x2b56_8297_a56d_a71c,
0xd8c3_9ecb_0ef3_75d1,
0x435c_38da_67bf_bf96,
0x8088_a050_26b6_59b2,
]);
let b = Scalar::from_raw([
0x785fdd9b26ef8b85,
0xc997f25837695c18,
0x4c8dbc39e7b756c1,
0x70d9b6cc6d87df20,
0x785f_dd9b_26ef_8b85,
0xc997_f258_3769_5c18,
0x4c8d_bc39_e7b7_56c1,
0x70d9_b6cc_6d87_df20,
]);
let c = a * b;
@ -1281,20 +1284,20 @@ fn test_affine_scalar_multiplication() {
fn test_is_torsion_free() {
let a = G1Affine {
x: Fp::from_raw_unchecked([
0xabaf895b97e43c8,
0xba4c6432eb9b61b0,
0x12506f52adfe307f,
0x75028c3439336b72,
0x84744f05b8e9bd71,
0x113d554fb09554f7,
0x0aba_f895_b97e_43c8,
0xba4c_6432_eb9b_61b0,
0x1250_6f52_adfe_307f,
0x7502_8c34_3933_6b72,
0x8474_4f05_b8e9_bd71,
0x113d_554f_b095_54f7,
]),
y: Fp::from_raw_unchecked([
0x73e90e88f5cf01c0,
0x37007b65dd3197e2,
0x5cf9a1992f0d7c78,
0x4f83c10b9eb3330d,
0xf6a63f6f07f60961,
0xc53b5b97e634df3,
0x73e9_0e88_f5cf_01c0,
0x3700_7b65_dd31_97e2,
0x5cf9_a199_2f0d_7c78,
0x4f83_c10b_9eb3_330d,
0xf6a6_3f6f_07f6_0961,
0x0c53_b5b9_7e63_4df3,
]),
infinity: Choice::from(0u8),
};

View File

@ -146,20 +146,20 @@ impl_binops_additive_specify_output!(G2Affine, G2Projective, G2Projective);
const B: Fp2 = Fp2 {
c0: Fp::from_raw_unchecked([
0xaa270000000cfff3,
0x53cc0032fc34000a,
0x478fe97a6b0a807f,
0xb1d37ebee6ba24d7,
0x8ec9733bbf78ab2f,
0x9d645513d83de7e,
0xaa27_0000_000c_fff3,
0x53cc_0032_fc34_000a,
0x478f_e97a_6b0a_807f,
0xb1d3_7ebe_e6ba_24d7,
0x8ec9_733b_bf78_ab2f,
0x09d6_4551_3d83_de7e,
]),
c1: Fp::from_raw_unchecked([
0xaa270000000cfff3,
0x53cc0032fc34000a,
0x478fe97a6b0a807f,
0xb1d37ebee6ba24d7,
0x8ec9733bbf78ab2f,
0x9d645513d83de7e,
0xaa27_0000_000c_fff3,
0x53cc_0032_fc34_000a,
0x478f_e97a_6b0a_807f,
0xb1d3_7ebe_e6ba_24d7,
0x8ec9_733b_bf78_ab2f,
0x09d6_4551_3d83_de7e,
]),
};
@ -179,38 +179,38 @@ impl G2Affine {
G2Affine {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0xf5f28fa202940a10,
0xb3f5fb2687b4961a,
0xa1a893b53e2ae580,
0x9894999d1a3caee9,
0x6f67b7631863366b,
0x58191924350bcd7,
0xf5f2_8fa2_0294_0a10,
0xb3f5_fb26_87b4_961a,
0xa1a8_93b5_3e2a_e580,
0x9894_999d_1a3c_aee9,
0x6f67_b763_1863_366b,
0x0581_9192_4350_bcd7,
]),
c1: Fp::from_raw_unchecked([
0xa5a9c0759e23f606,
0xaaa0c59dbccd60c3,
0x3bb17e18e2867806,
0x1b1ab6cc8541b367,
0xc2b6ed0ef2158547,
0x11922a097360edf3,
0xa5a9_c075_9e23_f606,
0xaaa0_c59d_bccd_60c3,
0x3bb1_7e18_e286_7806,
0x1b1a_b6cc_8541_b367,
0xc2b6_ed0e_f215_8547,
0x1192_2a09_7360_edf3,
]),
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x4c730af860494c4a,
0x597cfa1f5e369c5a,
0xe7e6856caa0a635a,
0xbbefb5e96e0d495f,
0x7d3a975f0ef25a2,
0x83fd8e7e80dae5,
0x4c73_0af8_6049_4c4a,
0x597c_fa1f_5e36_9c5a,
0xe7e6_856c_aa0a_635a,
0xbbef_b5e9_6e0d_495f,
0x07d3_a975_f0ef_25a2,
0x0083_fd8e_7e80_dae5,
]),
c1: Fp::from_raw_unchecked([
0xadc0fc92df64b05d,
0x18aa270a2b1461dc,
0x86adac6a3be4eba0,
0x79495c4ec93da33a,
0xe7175850a43ccaed,
0xb2bc2a163de1bf2,
0xadc0_fc92_df64_b05d,
0x18aa_270a_2b14_61dc,
0x86ad_ac6a_3be4_eba0,
0x7949_5c4e_c93d_a33a,
0xe717_5850_a43c_caed,
0x0b2b_c2a1_63de_1bf2,
]),
},
infinity: Choice::from(0u8),
@ -600,38 +600,38 @@ impl G2Projective {
G2Projective {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0xf5f28fa202940a10,
0xb3f5fb2687b4961a,
0xa1a893b53e2ae580,
0x9894999d1a3caee9,
0x6f67b7631863366b,
0x58191924350bcd7,
0xf5f2_8fa2_0294_0a10,
0xb3f5_fb26_87b4_961a,
0xa1a8_93b5_3e2a_e580,
0x9894_999d_1a3c_aee9,
0x6f67_b763_1863_366b,
0x0581_9192_4350_bcd7,
]),
c1: Fp::from_raw_unchecked([
0xa5a9c0759e23f606,
0xaaa0c59dbccd60c3,
0x3bb17e18e2867806,
0x1b1ab6cc8541b367,
0xc2b6ed0ef2158547,
0x11922a097360edf3,
0xa5a9_c075_9e23_f606,
0xaaa0_c59d_bccd_60c3,
0x3bb1_7e18_e286_7806,
0x1b1a_b6cc_8541_b367,
0xc2b6_ed0e_f215_8547,
0x1192_2a09_7360_edf3,
]),
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x4c730af860494c4a,
0x597cfa1f5e369c5a,
0xe7e6856caa0a635a,
0xbbefb5e96e0d495f,
0x7d3a975f0ef25a2,
0x83fd8e7e80dae5,
0x4c73_0af8_6049_4c4a,
0x597c_fa1f_5e36_9c5a,
0xe7e6_856c_aa0a_635a,
0xbbef_b5e9_6e0d_495f,
0x07d3_a975_f0ef_25a2,
0x0083_fd8e_7e80_dae5,
]),
c1: Fp::from_raw_unchecked([
0xadc0fc92df64b05d,
0x18aa270a2b1461dc,
0x86adac6a3be4eba0,
0x79495c4ec93da33a,
0xe7175850a43ccaed,
0xb2bc2a163de1bf2,
0xadc0_fc92_df64_b05d,
0x18aa_270a_2b14_61dc,
0x86ad_ac6a_3be4_eba0,
0x7949_5c4e_c93d_a33a,
0xe717_5850_a43c_caed,
0x0b2b_c2a1_63de_1bf2,
]),
},
z: Fp2::one(),
@ -894,20 +894,20 @@ fn test_is_on_curve() {
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -925,6 +925,7 @@ fn test_is_on_curve() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_affine_point_equality() {
let a = G2Affine::generator();
let b = G2Affine::identity();
@ -936,6 +937,7 @@ fn test_affine_point_equality() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_projective_point_equality() {
let a = G2Projective::generator();
let b = G2Projective::identity();
@ -947,20 +949,20 @@ fn test_projective_point_equality() {
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1028,20 +1030,20 @@ fn test_projective_to_affine() {
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1082,38 +1084,38 @@ fn test_doubling() {
G2Affine {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0xe9d9e2da9620f98b,
0x54f1199346b97f36,
0x3db3b820376bed27,
0xcfdb31c9b0b64f4c,
0x41d7c12786354493,
0x5710794c255c064
0xe9d9_e2da_9620_f98b,
0x54f1_1993_46b9_7f36,
0x3db3_b820_376b_ed27,
0xcfdb_31c9_b0b6_4f4c,
0x41d7_c127_8635_4493,
0x0571_0794_c255_c064,
]),
c1: Fp::from_raw_unchecked([
0xd6c1d3ca6ea0d06e,
0xda0cbd905595489f,
0x4f5352d43479221d,
0x8ade5d736f8c97e0,
0x48cc8433925ef70e,
0x8d7ea71ea91ef81
0xd6c1_d3ca_6ea0_d06e,
0xda0c_bd90_5595_489f,
0x4f53_52d4_3479_221d,
0x8ade_5d73_6f8c_97e0,
0x48cc_8433_925e_f70e,
0x08d7_ea71_ea91_ef81,
]),
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x15ba26eb4b0d186f,
0xd086d64b7e9e01e,
0xc8b848dd652f4c78,
0xeecf46a6123bae4f,
0x255e8dd8b6dc812a,
0x164142af21dcf93f
0x15ba_26eb_4b0d_186f,
0x0d08_6d64_b7e9_e01e,
0xc8b8_48dd_652f_4c78,
0xeecf_46a6_123b_ae4f,
0x255e_8dd8_b6dc_812a,
0x1641_42af_21dc_f93f,
]),
c1: Fp::from_raw_unchecked([
0xf9b4a1a895984db4,
0xd417b114cccff748,
0x6856301fc89f086e,
0x41c777878931e3da,
0x3556b155066a2105,
0xacf7d325cb89cf
0xf9b4_a1a8_9598_4db4,
0xd417_b114_cccf_f748,
0x6856_301f_c89f_086e,
0x41c7_7787_8931_e3da,
0x3556_b155_066a_2105,
0x00ac_f7d3_25cb_89cf,
]),
},
infinity: Choice::from(0u8)
@ -1137,20 +1139,20 @@ fn test_projective_addition() {
{
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1171,20 +1173,20 @@ fn test_projective_addition() {
{
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1206,7 +1208,7 @@ fn test_projective_addition() {
let mut d = G2Projective::generator();
for _ in 0..5 {
d = d + G2Projective::generator();
d += G2Projective::generator();
}
assert!(!bool::from(c.is_identity()));
assert!(bool::from(c.is_on_curve()));
@ -1219,12 +1221,12 @@ fn test_projective_addition() {
{
let beta = Fp2 {
c0: Fp::from_raw_unchecked([
0xcd03c9e48671f071,
0x5dab22461fcda5d2,
0x587042afd3851b95,
0x8eb60ebe01bacb9e,
0x3f97d6e83d050d2,
0x18f0206554638741,
0xcd03_c9e4_8671_f071,
0x5dab_2246_1fcd_a5d2,
0x5870_42af_d385_1b95,
0x8eb6_0ebe_01ba_cb9e,
0x03f9_7d6e_83d0_50d2,
0x18f0_2065_5463_8741,
]),
c1: Fp::zero(),
};
@ -1244,38 +1246,38 @@ fn test_projective_addition() {
G2Affine::from(G2Projective {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0x705abc799ca773d3,
0xfe132292c1d4bf08,
0xf37ece3e07b2b466,
0x887e1c43f447e301,
0x1e0970d033bc77e8,
0x1985c81e20a693f2
0x705a_bc79_9ca7_73d3,
0xfe13_2292_c1d4_bf08,
0xf37e_ce3e_07b2_b466,
0x887e_1c43_f447_e301,
0x1e09_70d0_33bc_77e8,
0x1985_c81e_20a6_93f2,
]),
c1: Fp::from_raw_unchecked([
0x1d79b25db36ab924,
0x23948e4d529639d3,
0x471ba7fb0d006297,
0x2c36d4b4465dc4c0,
0x82bbc3cfec67f538,
0x51d2728b67bf952
0x1d79_b25d_b36a_b924,
0x2394_8e4d_5296_39d3,
0x471b_a7fb_0d00_6297,
0x2c36_d4b4_465d_c4c0,
0x82bb_c3cf_ec67_f538,
0x051d_2728_b67b_f952,
])
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x41b1bbf6576c0abf,
0xb6cc93713f7a0f9a,
0x6b65b43e48f3f01f,
0xfb7a4cfcaf81be4f,
0x3e32dadc6ec22cb6,
0xbb0fc49d79807e3
0x41b1_bbf6_576c_0abf,
0xb6cc_9371_3f7a_0f9a,
0x6b65_b43e_48f3_f01f,
0xfb7a_4cfc_af81_be4f,
0x3e32_dadc_6ec2_2cb6,
0x0bb0_fc49_d798_07e3,
]),
c1: Fp::from_raw_unchecked([
0x7d1397788f5f2ddf,
0xab2907144ff0d8e8,
0x5b7573e0cdb91f92,
0x4cb8932dd31daf28,
0x62bbfac6db052a54,
0x11f95c16d14c3bbe
0x7d13_9778_8f5f_2ddf,
0xab29_0714_4ff0_d8e8,
0x5b75_73e0_cdb9_1f92,
0x4cb8_932d_d31d_af28,
0x62bb_fac6_db05_2a54,
0x11f9_5c16_d14c_3bbe,
])
},
z: Fp2::one()
@ -1301,20 +1303,20 @@ fn test_mixed_addition() {
{
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1335,20 +1337,20 @@ fn test_mixed_addition() {
{
let z = Fp2 {
c0: Fp::from_raw_unchecked([
0xba7afa1f9a6fe250,
0xfa0f5b595eafe731,
0x3bdc477694c306e7,
0x2149be4b3949fa24,
0x64aa6e0649b2078c,
0x12b108ac33643c3e,
0xba7a_fa1f_9a6f_e250,
0xfa0f_5b59_5eaf_e731,
0x3bdc_4776_94c3_06e7,
0x2149_be4b_3949_fa24,
0x64aa_6e06_49b2_078c,
0x12b1_08ac_3364_3c3e,
]),
c1: Fp::from_raw_unchecked([
0x125325df3d35b5a8,
0xdc469ef5555d7fe3,
0x2d716d2443106a9,
0x5a1db59a6ff37d0,
0x7cf7784e5300bb8f,
0x16a88922c7a5e844,
0x1253_25df_3d35_b5a8,
0xdc46_9ef5_555d_7fe3,
0x02d7_16d2_4431_06a9,
0x05a1_db59_a6ff_37d0,
0x7cf7_784e_5300_bb8f,
0x16a8_8922_c7a5_e844,
]),
};
@ -1370,7 +1372,7 @@ fn test_mixed_addition() {
let mut d = G2Projective::generator();
for _ in 0..5 {
d = d + G2Affine::generator();
d += G2Affine::generator();
}
assert!(!bool::from(c.is_identity()));
assert!(bool::from(c.is_on_curve()));
@ -1383,12 +1385,12 @@ fn test_mixed_addition() {
{
let beta = Fp2 {
c0: Fp::from_raw_unchecked([
0xcd03c9e48671f071,
0x5dab22461fcda5d2,
0x587042afd3851b95,
0x8eb60ebe01bacb9e,
0x3f97d6e83d050d2,
0x18f0206554638741,
0xcd03_c9e4_8671_f071,
0x5dab_2246_1fcd_a5d2,
0x5870_42af_d385_1b95,
0x8eb6_0ebe_01ba_cb9e,
0x03f9_7d6e_83d0_50d2,
0x18f0_2065_5463_8741,
]),
c1: Fp::zero(),
};
@ -1409,38 +1411,38 @@ fn test_mixed_addition() {
G2Affine::from(G2Projective {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0x705abc799ca773d3,
0xfe132292c1d4bf08,
0xf37ece3e07b2b466,
0x887e1c43f447e301,
0x1e0970d033bc77e8,
0x1985c81e20a693f2
0x705a_bc79_9ca7_73d3,
0xfe13_2292_c1d4_bf08,
0xf37e_ce3e_07b2_b466,
0x887e_1c43_f447_e301,
0x1e09_70d0_33bc_77e8,
0x1985_c81e_20a6_93f2,
]),
c1: Fp::from_raw_unchecked([
0x1d79b25db36ab924,
0x23948e4d529639d3,
0x471ba7fb0d006297,
0x2c36d4b4465dc4c0,
0x82bbc3cfec67f538,
0x51d2728b67bf952
0x1d79_b25d_b36a_b924,
0x2394_8e4d_5296_39d3,
0x471b_a7fb_0d00_6297,
0x2c36_d4b4_465d_c4c0,
0x82bb_c3cf_ec67_f538,
0x051d_2728_b67b_f952,
])
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x41b1bbf6576c0abf,
0xb6cc93713f7a0f9a,
0x6b65b43e48f3f01f,
0xfb7a4cfcaf81be4f,
0x3e32dadc6ec22cb6,
0xbb0fc49d79807e3
0x41b1_bbf6_576c_0abf,
0xb6cc_9371_3f7a_0f9a,
0x6b65_b43e_48f3_f01f,
0xfb7a_4cfc_af81_be4f,
0x3e32_dadc_6ec2_2cb6,
0x0bb0_fc49_d798_07e3,
]),
c1: Fp::from_raw_unchecked([
0x7d1397788f5f2ddf,
0xab2907144ff0d8e8,
0x5b7573e0cdb91f92,
0x4cb8932dd31daf28,
0x62bbfac6db052a54,
0x11f95c16d14c3bbe
0x7d13_9778_8f5f_2ddf,
0xab29_0714_4ff0_d8e8,
0x5b75_73e0_cdb9_1f92,
0x4cb8_932d_d31d_af28,
0x62bb_fac6_db05_2a54,
0x11f9_5c16_d14c_3bbe,
])
},
z: Fp2::one()
@ -1452,6 +1454,7 @@ fn test_mixed_addition() {
}
#[test]
#[allow(clippy::eq_op)]
fn test_projective_negation_and_subtraction() {
let a = G2Projective::generator().double();
assert_eq!(a + (-a), G2Projective::identity());
@ -1469,16 +1472,16 @@ fn test_affine_negation_and_subtraction() {
fn test_projective_scalar_multiplication() {
let g = G2Projective::generator();
let a = Scalar::from_raw([
0x2b568297a56da71c,
0xd8c39ecb0ef375d1,
0x435c38da67bfbf96,
0x8088a05026b659b2,
0x2b56_8297_a56d_a71c,
0xd8c3_9ecb_0ef3_75d1,
0x435c_38da_67bf_bf96,
0x8088_a050_26b6_59b2,
]);
let b = Scalar::from_raw([
0x785fdd9b26ef8b85,
0xc997f25837695c18,
0x4c8dbc39e7b756c1,
0x70d9b6cc6d87df20,
0x785f_dd9b_26ef_8b85,
0xc997_f258_3769_5c18,
0x4c8d_bc39_e7b7_56c1,
0x70d9_b6cc_6d87_df20,
]);
let c = a * b;
@ -1489,16 +1492,16 @@ fn test_projective_scalar_multiplication() {
fn test_affine_scalar_multiplication() {
let g = G2Affine::generator();
let a = Scalar::from_raw([
0x2b568297a56da71c,
0xd8c39ecb0ef375d1,
0x435c38da67bfbf96,
0x8088a05026b659b2,
0x2b56_8297_a56d_a71c,
0xd8c3_9ecb_0ef3_75d1,
0x435c_38da_67bf_bf96,
0x8088_a050_26b6_59b2,
]);
let b = Scalar::from_raw([
0x785fdd9b26ef8b85,
0xc997f25837695c18,
0x4c8dbc39e7b756c1,
0x70d9b6cc6d87df20,
0x785f_dd9b_26ef_8b85,
0xc997_f258_3769_5c18,
0x4c8d_bc39_e7b7_56c1,
0x70d9_b6cc_6d87_df20,
]);
let c = a * b;
@ -1510,38 +1513,38 @@ fn test_is_torsion_free() {
let a = G2Affine {
x: Fp2 {
c0: Fp::from_raw_unchecked([
0x89f550c813db6431,
0xa50be8c456cd8a1a,
0xa45b374114cae851,
0xbb6190f5bf7fff63,
0x970ca02c3ba80bc7,
0x2b85d24e840fbac,
0x89f5_50c8_13db_6431,
0xa50b_e8c4_56cd_8a1a,
0xa45b_3741_14ca_e851,
0xbb61_90f5_bf7f_ff63,
0x970c_a02c_3ba8_0bc7,
0x02b8_5d24_e840_fbac,
]),
c1: Fp::from_raw_unchecked([
0x6888bc53d70716dc,
0x3dea6b4117682d70,
0xd8f5f930500ca354,
0x6b5ecb6556f5c155,
0xc96bef0434778ab0,
0x5081505515006ad,
0x6888_bc53_d707_16dc,
0x3dea_6b41_1768_2d70,
0xd8f5_f930_500c_a354,
0x6b5e_cb65_56f5_c155,
0xc96b_ef04_3477_8ab0,
0x0508_1505_5150_06ad,
]),
},
y: Fp2 {
c0: Fp::from_raw_unchecked([
0x3cf1ea0d434b0f40,
0x1a0dc610e603e333,
0x7f89956160c72fa0,
0x25ee03decf6431c5,
0xeee8e206ec0fe137,
0x97592b226dfef28,
0x3cf1_ea0d_434b_0f40,
0x1a0d_c610_e603_e333,
0x7f89_9561_60c7_2fa0,
0x25ee_03de_cf64_31c5,
0xeee8_e206_ec0f_e137,
0x0975_92b2_26df_ef28,
]),
c1: Fp::from_raw_unchecked([
0x71e8bb5f29247367,
0xa5fe049e211831ce,
0xce6b354502a3896,
0x93b012000997314e,
0x6759f3b6aa5b42ac,
0x156944c4dfe92bbb,
0x71e8_bb5f_2924_7367,
0xa5fe_049e_2118_31ce,
0x0ce6_b354_502a_3896,
0x93b0_1200_0997_314e,
0x6759_f3b6_aa5b_42ac,
0x1569_44c4_dfe9_2bbb,
]),
},
infinity: Choice::from(0u8),

View File

@ -15,7 +15,6 @@
#![deny(missing_docs)]
#![deny(unsafe_code)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::many_single_char_names)]
// This lint is described at
// https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
@ -68,7 +67,7 @@ mod fp12;
mod fp6;
// The BLS parameter x for BLS12-381 is -0xd201000000010000
const BLS_X: u64 = 0xd201000000010000;
const BLS_X: u64 = 0xd201_0000_0001_0000;
const BLS_X_IS_NEGATIVE: bool = true;
#[cfg(feature = "pairings")]

View File

@ -46,39 +46,39 @@ impl MillerLoopResult {
// https://eprint.iacr.org/2009/565.pdf
#[must_use]
fn cyclotomic_square(f: Fp12) -> Fp12 {
let mut z0 = f.c0.c0.clone();
let mut z4 = f.c0.c1.clone();
let mut z3 = f.c0.c2.clone();
let mut z2 = f.c1.c0.clone();
let mut z1 = f.c1.c1.clone();
let mut z5 = f.c1.c2.clone();
let mut z0 = f.c0.c0;
let mut z4 = f.c0.c1;
let mut z3 = f.c0.c2;
let mut z2 = f.c1.c0;
let mut z1 = f.c1.c1;
let mut z5 = f.c1.c2;
let (t0, t1) = fp4_square(z0, z1);
// For A
z0 = t0 - z0;
z0 += z0 + t0;
z0 = z0 + z0 + t0;
z1 = t1 + z1;
z1 += z1 + t1;
z1 = z1 + z1 + t1;
let (mut t0, t1) = fp4_square(z2, z3);
let (t2, t3) = fp4_square(z4, z5);
// For C
z4 = t0 - z4;
z4 += z4 + t0;
z4 = z4 + z4 + t0;
z5 = t1 + z5;
z5 += z5 + t1;
z5 = z5 + z5 + t1;
// For B
t0 = t3.mul_by_nonresidue();
z2 = t0 + z2;
z2 += z2 + t0;
z2 = z2 + z2 + t0;
z3 = t2 - z3;
z3 += z3 + t2;
z3 = z3 + z3 + t2;
Fp12 {
c0: Fp6 {
@ -113,7 +113,7 @@ impl MillerLoopResult {
tmp.conjugate()
}
let mut f = self.0.clone();
let mut f = self.0;
let mut t0 = f
.frobenius_map()
.frobenius_map()
@ -124,7 +124,7 @@ impl MillerLoopResult {
Gt(f.invert()
.map(|mut t1| {
let mut t2 = t0 * t1;
t1 = t2.clone();
t1 = t2;
t2 = t2.frobenius_map().frobenius_map();
t2 *= t1;
t1 = cyclotomic_square(t2).conjugate();
@ -311,15 +311,9 @@ impl From<G2Affine> for G2Prepared {
let coeffs = addition_step(&mut self.cur, &self.base);
self.coeffs.push(coeffs);
}
fn square_output(_: Self::Output) -> Self::Output {
()
}
fn conjugate(_: Self::Output) -> Self::Output {
()
}
fn one() -> Self::Output {
()
}
fn square_output(_: Self::Output) -> Self::Output {}
fn conjugate(_: Self::Output) -> Self::Output {}
fn one() -> Self::Output {}
}
let is_identity = q.is_identity();

View File

@ -64,10 +64,10 @@ impl ConditionallySelectable for Scalar {
/// Constant representing the modulus
/// q = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001
const MODULUS: Scalar = Scalar([
0xffffffff00000001,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48,
0xffff_ffff_0000_0001,
0x53bd_a402_fffe_5bfe,
0x3339_d808_09a1_d805,
0x73ed_a753_299d_7d48,
]);
impl<'a> Neg for &'a Scalar {
@ -119,30 +119,30 @@ impl_binops_additive!(Scalar, Scalar);
impl_binops_multiplicative!(Scalar, Scalar);
/// INV = -(q^{-1} mod 2^64) mod 2^64
const INV: u64 = 0xfffffffeffffffff;
const INV: u64 = 0xffff_fffe_ffff_ffff;
/// R = 2^256 mod q
const R: Scalar = Scalar([
0x00000001fffffffe,
0x5884b7fa00034802,
0x998c4fefecbc4ff5,
0x1824b159acc5056f,
0x0000_0001_ffff_fffe,
0x5884_b7fa_0003_4802,
0x998c_4fef_ecbc_4ff5,
0x1824_b159_acc5_056f,
]);
/// R^2 = 2^512 mod q
const R2: Scalar = Scalar([
0xc999e990f3f29c6d,
0x2b6cedcb87925c23,
0x05d314967254398f,
0x0748d9d99f59ff11,
0xc999_e990_f3f2_9c6d,
0x2b6c_edcb_8792_5c23,
0x05d3_1496_7254_398f,
0x0748_d9d9_9f59_ff11,
]);
/// R^3 = 2^768 mod q
const R3: Scalar = Scalar([
0xc62c1807439b73af,
0x1b3e0d188cf06990,
0x73d13c71c7b5f418,
0x6e2a5bb9c8db33e9,
0xc62c_1807_439b_73af,
0x1b3e_0d18_8cf0_6990,
0x73d1_3c71_c7b5_f418,
0x6e2a_5bb9_c8db_33e9,
]);
const S: u32 = 32;
@ -155,10 +155,10 @@ const S: u32 = 32;
/// of the q - 1 order multiplicative
/// subgroup.
const ROOT_OF_UNITY: Scalar = Scalar([
0xb9b58d8c5f0e466a,
0x5b1b4c801819d7ec,
0x0af53ae352a31e64,
0x5bf3adda19e9b27b,
0xb9b5_8d8c_5f0e_466a,
0x5b1b_4c80_1819_d7ec,
0x0af5_3ae3_52a3_1e64,
0x5bf3_adda_19e9_b27b,
]);
impl Default for Scalar {
@ -313,10 +313,10 @@ impl Scalar {
// w = self^((t - 1) // 2)
// = self^6104339283789297388802252303364915521546564123189034618274734669823
let w = self.pow_vartime(&[
0x7fff2dff7fffffff,
0x04d0ec02a9ded201,
0x94cebea4199cec04,
0x0000000039f6d3a9,
0x7fff_2dff_7fff_ffff,
0x04d0_ec02_a9de_d201,
0x94ce_bea4_199c_ec04,
0x0000_0000_39f6_d3a9,
]);
let mut v = S;
@ -806,7 +806,7 @@ fn test_from_u512_r2() {
#[test]
fn test_from_u512_max() {
let max_u64 = 0xffffffffffffffff;
let max_u64 = 0xffff_ffff_ffff_ffff;
assert_eq!(
R3 - R,
Scalar::from_u512([max_u64, max_u64, max_u64, max_u64, max_u64, max_u64, max_u64, max_u64])
@ -841,10 +841,10 @@ fn test_from_bytes_wide_negative_one() {
fn test_from_bytes_wide_maximum() {
assert_eq!(
Scalar([
0xc62c1805439b73b1,
0xc2b9551e8ced218e,
0xda44ec81daf9a422,
0x5605aa601c162e79
0xc62c_1805_439b_73b1,
0xc2b9_551e_8ced_218e,
0xda44_ec81_daf9_a422,
0x5605_aa60_1c16_2e79,
]),
Scalar::from_bytes_wide(&[0xff; 64])
);
@ -860,10 +860,10 @@ fn test_zero() {
#[cfg(test)]
const LARGEST: Scalar = Scalar([
0xffffffff00000000,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48,
0xffff_ffff_0000_0000,
0x53bd_a402_fffe_5bfe,
0x3339_d808_09a1_d805,
0x73ed_a753_299d_7d48,
]);
#[test]
@ -874,10 +874,10 @@ fn test_addition() {
assert_eq!(
tmp,
Scalar([
0xfffffffeffffffff,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48
0xffff_fffe_ffff_ffff,
0x53bd_a402_fffe_5bfe,
0x3339_d808_09a1_d805,
0x73ed_a753_299d_7d48,
])
);
@ -994,10 +994,10 @@ fn test_inversion() {
#[test]
fn test_invert_is_pow() {
let q_minus_2 = [
0xfffffffeffffffff,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48,
0xffff_fffe_ffff_ffff,
0x53bd_a402_fffe_5bfe,
0x3339_d808_09a1_d805,
0x73ed_a753_299d_7d48,
];
let mut r1 = R;
@ -1025,10 +1025,10 @@ fn test_sqrt() {
}
let mut square = Scalar([
0x46cd85a5f273077e,
0x1d30c47dd68fc735,
0x77f656f60beca0eb,
0x494aa01bdf32468d,
0x46cd_85a5_f273_077e,
0x1d30_c47d_d68f_c735,
0x77f6_56f6_0bec_a0eb,
0x494a_a01b_df32_468d,
]);
let mut none_count = 0;
@ -1050,12 +1050,12 @@ fn test_sqrt() {
fn test_from_raw() {
assert_eq!(
Scalar::from_raw([
0x1fffffffd,
0x5884b7fa00034802,
0x998c4fefecbc4ff5,
0x1824b159acc5056f
0x0001_ffff_fffd,
0x5884_b7fa_0003_4802,
0x998c_4fef_ecbc_4ff5,
0x1824_b159_acc5_056f,
]),
Scalar::from_raw([0xffffffffffffffff; 4])
Scalar::from_raw([0xffff_ffff_ffff_ffff; 4])
);
assert_eq!(Scalar::from_raw(MODULUS.0), Scalar::zero());
@ -1066,10 +1066,10 @@ fn test_from_raw() {
#[test]
fn test_double() {
let a = Scalar::from_raw([
0x1fff3231233ffffd,
0x4884b7fa00034802,
0x998c4fefecbc4ff3,
0x1824b159acc50562,
0x1fff_3231_233f_fffd,
0x4884_b7fa_0003_4802,
0x998c_4fef_ecbc_4ff3,
0x1824_b159_acc5_0562,
]);
assert_eq!(a.double(), a + a);

View File

@ -116,112 +116,112 @@ fn test_pairing_result_against_relic() {
c0: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0x1972e433a01f85c5,
0x97d32b76fd772538,
0xc8ce546fc96bcdf9,
0xcef63e7366d40614,
0xa611342781843780,
0x13f3448a3fc6d825
0x1972_e433_a01f_85c5,
0x97d3_2b76_fd77_2538,
0xc8ce_546f_c96b_cdf9,
0xcef6_3e73_66d4_0614,
0xa611_3427_8184_3780,
0x13f3_448a_3fc6_d825,
]),
c1: Fp::from_raw_unchecked([
0xd26331b02e9d6995,
0x9d68a482f7797e7d,
0x9c9b29248d39ea92,
0xf4801ca2e13107aa,
0xa16c0732bdbcb066,
0x83ca4afba360478
0xd263_31b0_2e9d_6995,
0x9d68_a482_f779_7e7d,
0x9c9b_2924_8d39_ea92,
0xf480_1ca2_e131_07aa,
0xa16c_0732_bdbc_b066,
0x083c_a4af_ba36_0478,
])
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x59e261db0916b641,
0x2716b6f4b23e960d,
0xc8e55b10a0bd9c45,
0xbdb0bd99c4deda8,
0x8cf89ebf57fdaac5,
0x12d6b7929e777a5e
0x59e2_61db_0916_b641,
0x2716_b6f4_b23e_960d,
0xc8e5_5b10_a0bd_9c45,
0x0bdb_0bd9_9c4d_eda8,
0x8cf8_9ebf_57fd_aac5,
0x12d6_b792_9e77_7a5e,
]),
c1: Fp::from_raw_unchecked([
0x5fc85188b0e15f35,
0x34a06e3a8f096365,
0xdb3126a6e02ad62c,
0xfc6f5aa97d9a990b,
0xa12f55f5eb89c210,
0x1723703a926f8889
0x5fc8_5188_b0e1_5f35,
0x34a0_6e3a_8f09_6365,
0xdb31_26a6_e02a_d62c,
0xfc6f_5aa9_7d9a_990b,
0xa12f_55f5_eb89_c210,
0x1723_703a_926f_8889,
])
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0x93588f2971828778,
0x43f65b8611ab7585,
0x3183aaf5ec279fdf,
0xfa73d7e18ac99df6,
0x64e176a6a64c99b0,
0x179fa78c58388f1f
0x9358_8f29_7182_8778,
0x43f6_5b86_11ab_7585,
0x3183_aaf5_ec27_9fdf,
0xfa73_d7e1_8ac9_9df6,
0x64e1_76a6_a64c_99b0,
0x179f_a78c_5838_8f1f,
]),
c1: Fp::from_raw_unchecked([
0x672a0a11ca2aef12,
0xd11b9b52aa3f16b,
0xa44412d0699d056e,
0xc01d0177221a5ba5,
0x66e0cede6c735529,
0x5f5a71e9fddc339
0x672a_0a11_ca2a_ef12,
0x0d11_b9b5_2aa3_f16b,
0xa444_12d0_699d_056e,
0xc01d_0177_221a_5ba5,
0x66e0_cede_6c73_5529,
0x05f5_a71e_9fdd_c339,
])
}
},
c1: Fp6 {
c0: Fp2 {
c0: Fp::from_raw_unchecked([
0xd30a88a1b062c679,
0x5ac56a5d35fc8304,
0xd0c834a6a81f290d,
0xcd5430c2da3707c7,
0xf0c27ff780500af0,
0x9245da6e2d72eae
0xd30a_88a1_b062_c679,
0x5ac5_6a5d_35fc_8304,
0xd0c8_34a6_a81f_290d,
0xcd54_30c2_da37_07c7,
0xf0c2_7ff7_8050_0af0,
0x0924_5da6_e2d7_2eae,
]),
c1: Fp::from_raw_unchecked([
0x9f2e0676791b5156,
0xe2d1c8234918fe13,
0x4c9e459f3c561bf4,
0xa3e85e53b9d3e3c1,
0x820a121e21a70020,
0x15af618341c59acc
0x9f2e_0676_791b_5156,
0xe2d1_c823_4918_fe13,
0x4c9e_459f_3c56_1bf4,
0xa3e8_5e53_b9d3_e3c1,
0x820a_121e_21a7_0020,
0x15af_6183_41c5_9acc,
])
},
c1: Fp2 {
c0: Fp::from_raw_unchecked([
0x7c95658c24993ab1,
0x73eb38721ca886b9,
0x5256d749477434bc,
0x8ba41902ea504a8b,
0x4a3d3f80c86ce6d,
0x18a64a87fb686eaa
0x7c95_658c_2499_3ab1,
0x73eb_3872_1ca8_86b9,
0x5256_d749_4774_34bc,
0x8ba4_1902_ea50_4a8b,
0x04a3_d3f8_0c86_ce6d,
0x18a6_4a87_fb68_6eaa,
]),
c1: Fp::from_raw_unchecked([
0xbb83e71bb920cf26,
0x2a5277ac92a73945,
0xfc0ee59f94f046a0,
0x7158cdf3786058f7,
0x7cc1061b82f945f6,
0x3f847aa9fdbe567
0xbb83_e71b_b920_cf26,
0x2a52_77ac_92a7_3945,
0xfc0e_e59f_94f0_46a0,
0x7158_cdf3_7860_58f7,
0x7cc1_061b_82f9_45f6,
0x03f8_47aa_9fdb_e567,
])
},
c2: Fp2 {
c0: Fp::from_raw_unchecked([
0x8078dba56134e657,
0x1cd7ec9a43998a6e,
0xb1aa599a1a993766,
0xc9a0f62f0842ee44,
0x8e159be3b605dffa,
0xc86ba0d4af13fc2
0x8078_dba5_6134_e657,
0x1cd7_ec9a_4399_8a6e,
0xb1aa_599a_1a99_3766,
0xc9a0_f62f_0842_ee44,
0x8e15_9be3_b605_dffa,
0x0c86_ba0d_4af1_3fc2,
]),
c1: Fp::from_raw_unchecked([
0xe80ff2a06a52ffb1,
0x7694ca48721a906c,
0x7583183e03b08514,
0xf567afdd40cee4e2,
0x9a6d96d2e526a5fc,
0x197e9f49861f2242
0xe80f_f2a0_6a52_ffb1,
0x7694_ca48_721a_906c,
0x7583_183e_03b0_8514,
0xf567_afdd_40ce_e4e2,
0x9a6d_96d2_e526_a5fc,
0x197e_9f49_861f_2242,
])
}
}

View File

@ -11,7 +11,7 @@ repository = "https://github.com/ebfull/ff"
edition = "2018"
[dependencies]
byteorder = { version = "1", default-features = false }
byteorder = { version = "1", optional = true }
ff_derive = { version = "0.4.0", path = "ff_derive", optional = true }
rand_core = { version = "0.5", default-features = false }
subtle = { version = "2.2.1", default-features = false, features = ["i128"] }
@ -19,7 +19,7 @@ subtle = { version = "2.2.1", default-features = false, features = ["i128"] }
[features]
default = ["std"]
derive = ["ff_derive"]
std = []
std = ["byteorder"]
[badges]
maintenance = { status = "actively-developed" }

View File

@ -40,7 +40,7 @@ pub fn prime_field(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let mut cur = BigUint::one() << 64; // always 64-bit limbs for now
while cur < mod2 {
limbs += 1;
cur = cur << 64;
cur <<= 64;
}
}
@ -60,23 +60,16 @@ pub fn prime_field(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
/// Fetches the ident being wrapped by the type we're deriving.
fn fetch_wrapped_ident(body: &syn::Data) -> Option<syn::Ident> {
match body {
&syn::Data::Struct(ref variant_data) => match variant_data.fields {
syn::Fields::Unnamed(ref fields) => {
if fields.unnamed.len() == 1 {
match fields.unnamed[0].ty {
syn::Type::Path(ref path) => {
if path.path.segments.len() == 1 {
return Some(path.path.segments[0].ident.clone());
}
}
_ => {}
if let syn::Data::Struct(ref variant_data) = body {
if let syn::Fields::Unnamed(ref fields) = variant_data.fields {
if fields.unnamed.len() == 1 {
if let syn::Type::Path(ref path) = fields.unnamed[0].ty {
if path.path.segments.len() == 1 {
return Some(path.path.segments[0].ident.clone());
}
}
}
_ => {}
},
_ => {}
}
};
None
@ -315,7 +308,7 @@ fn biguint_to_real_u64_vec(mut v: BigUint, limbs: usize) -> Vec<u64> {
while v > BigUint::zero() {
ret.push((&v % &m).to_u64().unwrap());
v = v >> 64;
v >>= 64;
}
while ret.len() < limbs {
@ -337,7 +330,7 @@ fn biguint_num_bits(mut v: BigUint) -> u32 {
let mut bits = 0;
while v != BigUint::zero() {
v = v >> 1;
v >>= 1;
bits += 1;
}
@ -402,7 +395,7 @@ fn prime_field_constants_and_sqrt(
let mut s: u32 = 0;
let mut t = modulus - BigUint::from_str("1").unwrap();
while t.is_even() {
t = t >> 1;
t >>= 1;
s += 1;
}
@ -472,7 +465,7 @@ fn prime_field_constants_and_sqrt(
let result = x * &z;
x = #name::conditional_select(&result, &x, b.ct_eq(&#name::one()));
z = z.square();
b = b * &z;
b *= &z;
v = k;
}
@ -684,7 +677,7 @@ fn prime_field_impl(
let mut mont_calling = proc_macro2::TokenStream::new();
mont_calling.append_separated(
(0..(limbs * 2)).map(|i| get_temp(i)),
(0..(limbs * 2)).map(get_temp),
proc_macro2::Punct::new(',', proc_macro2::Spacing::Alone),
);
@ -732,7 +725,7 @@ fn prime_field_impl(
let mut mont_calling = proc_macro2::TokenStream::new();
mont_calling.append_separated(
(0..(limbs * 2)).map(|i| get_temp(i)),
(0..(limbs * 2)).map(get_temp),
proc_macro2::Punct::new(',', proc_macro2::Spacing::Alone),
);

View File

@ -342,7 +342,7 @@ impl<E: AsRef<[u64]>> Iterator for BitIterator<E> {
#[test]
fn test_bit_iterator() {
let mut a = BitIterator::new([0xa953d79b83f6ab59, 0x6dea2059e200bd39]);
let mut a = BitIterator::new([0xa953_d79b_83f6_ab59, 0x6dea_2059_e200_bd39]);
let expected = "01101101111010100010000001011001111000100000000010111101001110011010100101010011110101111001101110000011111101101010101101011001";
for e in expected.chars() {
@ -354,10 +354,10 @@ fn test_bit_iterator() {
let expected = "1010010101111110101010000101101011101000011101110101001000011001100100100011011010001011011011010001011011101100110100111011010010110001000011110100110001100110011101101000101100011100100100100100001010011101010111110011101011000011101000111011011101011001";
let mut a = BitIterator::new([
0x429d5f3ac3a3b759,
0xb10f4c66768b1c92,
0x92368b6d16ecd3b4,
0xa57ea85ae8775219,
0x429d_5f3a_c3a3_b759,
0xb10f_4c66_768b_1c92,
0x9236_8b6d_16ec_d3b4,
0xa57e_a85a_e877_5219,
]);
for e in expected.chars() {

View File

@ -64,10 +64,10 @@ impl ConditionallySelectable for Fr {
/// Constant representing the modulus
/// r = 0x0e7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7
pub const MODULUS: Fr = Fr([
0xd0970e5ed6f72cb7,
0xa6682093ccc81082,
0x06673b0101343b00,
0x0e7db4ea6533afa9,
0xd097_0e5e_d6f7_2cb7,
0xa668_2093_ccc8_1082,
0x0667_3b01_0134_3b00,
0x0e7d_b4ea_6533_afa9,
]);
impl<'a> Neg for &'a Fr {
@ -121,30 +121,30 @@ impl_binops_additive!(Fr, Fr);
impl_binops_multiplicative!(Fr, Fr);
/// INV = -(r^{-1} mod 2^64) mod 2^64
const INV: u64 = 0x1ba3a358ef788ef9;
const INV: u64 = 0x1ba3_a358_ef78_8ef9;
/// R = 2^256 mod r
const R: Fr = Fr([
0x25f80bb3b99607d9,
0xf315d62f66b6e750,
0x932514eeeb8814f4,
0x09a6fc6f479155c6,
0x25f8_0bb3_b996_07d9,
0xf315_d62f_66b6_e750,
0x9325_14ee_eb88_14f4,
0x09a6_fc6f_4791_55c6,
]);
/// R^2 = 2^512 mod r
const R2: Fr = Fr([
0x67719aa495e57731,
0x51b0cef09ce3fc26,
0x69dab7fac026e9a5,
0x04f6547b8d127688,
0x6771_9aa4_95e5_7731,
0x51b0_cef0_9ce3_fc26,
0x69da_b7fa_c026_e9a5,
0x04f6_547b_8d12_7688,
]);
/// R^2 = 2^768 mod r
const R3: Fr = Fr([
0xe0d6c6563d830544,
0x323e3883598d0f85,
0xf0fea3004c2e2ba8,
0x05874f84946737ec,
0xe0d6_c656_3d83_0544,
0x323e_3883_598d_0f85,
0xf0fe_a300_4c2e_2ba8,
0x0587_4f84_9467_37ec,
]);
impl Default for Fr {
@ -296,15 +296,15 @@ impl Fr {
// sqrt can be done with only one exponentiation,
// via the computation of self^((r + 1) // 4) (mod r)
let sqrt = self.pow_vartime(&[
0xb425c397b5bdcb2e,
0x299a0824f3320420,
0x4199cec0404d0ec0,
0x039f6d3a994cebea,
0xb425_c397_b5bd_cb2e,
0x299a_0824_f332_0420,
0x4199_cec0_404d_0ec0,
0x039f_6d3a_994c_ebea,
]);
CtOption::new(
sqrt,
(&sqrt * &sqrt).ct_eq(self), // Only return Some if it's the square root.
(sqrt * sqrt).ct_eq(self), // Only return Some if it's the square root.
)
}
@ -355,25 +355,25 @@ impl Fr {
// found using https://github.com/kwantam/addchain
let mut t1 = self.square();
let mut t0 = t1.square();
let mut t3 = t0 * &t1;
let mut t3 = t0 * t1;
let t6 = t3 * self;
let t7 = t6 * &t1;
let t12 = t7 * &t3;
let t13 = t12 * &t0;
let t16 = t12 * &t3;
let t2 = t13 * &t3;
let t15 = t16 * &t3;
let t19 = t2 * &t0;
let t9 = t15 * &t3;
let t18 = t9 * &t3;
let t14 = t18 * &t1;
let t4 = t18 * &t0;
let t8 = t18 * &t3;
let t17 = t14 * &t3;
let t11 = t8 * &t3;
t1 = t17 * &t3;
let t5 = t11 * &t3;
t3 = t5 * &t0;
let t7 = t6 * t1;
let t12 = t7 * t3;
let t13 = t12 * t0;
let t16 = t12 * t3;
let t2 = t13 * t3;
let t15 = t16 * t3;
let t19 = t2 * t0;
let t9 = t15 * t3;
let t18 = t9 * t3;
let t14 = t18 * t1;
let t4 = t18 * t0;
let t8 = t18 * t3;
let t17 = t14 * t3;
let t11 = t8 * t3;
t1 = t17 * t3;
let t5 = t11 * t3;
t3 = t5 * t0;
t0 = t5.square();
square_assign_multi(&mut t0, 5);
t0.mul_assign(&t3);
@ -450,6 +450,7 @@ impl Fr {
}
#[inline]
#[allow(clippy::too_many_arguments)]
const fn montgomery_reduce(
r0: u64,
r1: u64,
@ -768,7 +769,7 @@ fn test_from_u512_r2() {
#[test]
fn test_from_u512_max() {
let max_u64 = 0xffffffffffffffff;
let max_u64 = 0xffff_ffff_ffff_ffff;
assert_eq!(
R3 - R,
Fr::from_u512([max_u64, max_u64, max_u64, max_u64, max_u64, max_u64, max_u64, max_u64])
@ -803,10 +804,10 @@ fn test_from_bytes_wide_negative_one() {
fn test_from_bytes_wide_maximum() {
assert_eq!(
Fr([
0x8b75c9015ae42a22,
0xe59082e7bf9e38b8,
0x6440c91261da51b3,
0xa5e07ffb20991cf
0x8b75_c901_5ae4_2a22,
0xe590_82e7_bf9e_38b8,
0x6440_c912_61da_51b3,
0x0a5e_07ff_b209_91cf,
]),
Fr::from_bytes_wide(&[0xff; 64])
);
@ -822,10 +823,10 @@ fn test_zero() {
#[cfg(test)]
const LARGEST: Fr = Fr([
0xd0970e5ed6f72cb6,
0xa6682093ccc81082,
0x06673b0101343b00,
0x0e7db4ea6533afa9,
0xd097_0e5e_d6f7_2cb6,
0xa668_2093_ccc8_1082,
0x0667_3b01_0134_3b00,
0x0e7d_b4ea_6533_afa9,
]);
#[test]
@ -836,10 +837,10 @@ fn test_addition() {
assert_eq!(
tmp,
Fr([
0xd0970e5ed6f72cb5,
0xa6682093ccc81082,
0x06673b0101343b00,
0x0e7db4ea6533afa9
0xd097_0e5e_d6f7_2cb5,
0xa668_2093_ccc8_1082,
0x0667_3b01_0134_3b00,
0x0e7d_b4ea_6533_afa9
])
);
@ -956,10 +957,10 @@ fn test_inversion() {
#[test]
fn test_invert_is_pow() {
let r_minus_2 = [
0xd0970e5ed6f72cb5,
0xa6682093ccc81082,
0x06673b0101343b00,
0x0e7db4ea6533afa9,
0xd097_0e5e_d6f7_2cb5,
0xa668_2093_ccc8_1082,
0x0667_3b01_0134_3b00,
0x0e7d_b4ea_6533_afa9,
];
let mut r1 = R;
@ -984,10 +985,10 @@ fn test_invert_is_pow() {
fn test_sqrt() {
let mut square = Fr([
// r - 2
0xd0970e5ed6f72cb5,
0xa6682093ccc81082,
0x06673b0101343b00,
0x0e7db4ea6533afa9,
0xd097_0e5e_d6f7_2cb5,
0xa668_2093_ccc8_1082,
0x0667_3b01_0134_3b00,
0x0e7d_b4ea_6533_afa9,
]);
let mut none_count = 0;
@ -1009,12 +1010,12 @@ fn test_sqrt() {
fn test_from_raw() {
assert_eq!(
Fr::from_raw([
0x25f80bb3b99607d8,
0xf315d62f66b6e750,
0x932514eeeb8814f4,
0x9a6fc6f479155c6
0x25f8_0bb3_b996_07d8,
0xf315_d62f_66b6_e750,
0x9325_14ee_eb88_14f4,
0x09a6_fc6f_4791_55c6,
]),
Fr::from_raw([0xffffffffffffffff; 4])
Fr::from_raw([0xffff_ffff_ffff_ffff; 4])
);
assert_eq!(Fr::from_raw(MODULUS.0), Fr::zero());

View File

@ -117,8 +117,8 @@ impl ConstantTimeEq for ExtendedPoint {
// (vz'z = v'z'z)
// as z and z' are always nonzero.
(&self.u * &other.z).ct_eq(&(&other.u * &self.z))
& (&self.v * &other.z).ct_eq(&(&other.v * &self.z))
(self.u * other.z).ct_eq(&(other.u * self.z))
& (self.v * other.z).ct_eq(&(other.v * self.z))
}
}
@ -184,8 +184,8 @@ impl<'a> From<&'a ExtendedPoint> for AffinePoint {
let zinv = extended.z.invert().unwrap();
AffinePoint {
u: extended.u * &zinv,
v: extended.v * &zinv,
u: extended.u * zinv,
v: extended.v * zinv,
}
}
}
@ -344,18 +344,18 @@ impl_binops_multiplicative_mixed!(ExtendedNielsPoint, Fr, ExtendedPoint);
// `d = -(10240/10241)`
const EDWARDS_D: Fq = Fq::from_raw([
0x01065fd6d6343eb1,
0x292d7f6d37579d26,
0xf5fd9207e6bd7fd4,
0x2a9318e74bfa2b48,
0x0106_5fd6_d634_3eb1,
0x292d_7f6d_3757_9d26,
0xf5fd_9207_e6bd_7fd4,
0x2a93_18e7_4bfa_2b48,
]);
// `2*d`
const EDWARDS_D2: Fq = Fq::from_raw([
0x020cbfadac687d62,
0x525afeda6eaf3a4c,
0xebfb240fcd7affa8,
0x552631ce97f45691,
0x020c_bfad_ac68_7d62,
0x525a_feda_6eaf_3a4c,
0xebfb_240f_cd7a_ffa8,
0x5526_31ce_97f4_5691,
]);
impl AffinePoint {
@ -430,7 +430,7 @@ impl AffinePoint {
let v2 = v.square();
((v2 - Fq::one()) * ((Fq::one() + EDWARDS_D * &v2).invert().unwrap_or(Fq::zero())))
((v2 - Fq::one()) * ((Fq::one() + EDWARDS_D * v2).invert().unwrap_or(Fq::zero())))
.sqrt()
.and_then(|u| {
// Fix the sign of `u` if necessary
@ -477,7 +477,7 @@ impl AffinePoint {
let u2 = self.u.square();
let v2 = self.v.square();
&v2 - &u2 == Fq::one() + &EDWARDS_D * &u2 * &v2
v2 - u2 == Fq::one() + EDWARDS_D * u2 * v2
}
}
@ -533,10 +533,10 @@ impl ExtendedPoint {
/// for use in multiple additions.
pub fn to_niels(&self) -> ExtendedNielsPoint {
ExtendedNielsPoint {
v_plus_u: &self.v + &self.u,
v_minus_u: &self.v - &self.u,
v_plus_u: self.v + self.u,
v_minus_u: self.v - self.u,
z: self.z,
t2d: &self.t1 * &self.t2 * EDWARDS_D2,
t2d: self.t1 * self.t2 * EDWARDS_D2,
}
}
@ -618,17 +618,17 @@ impl ExtendedPoint {
let uu = self.u.square();
let vv = self.v.square();
let zz2 = self.z.square().double();
let uv2 = (&self.u + &self.v).square();
let vv_plus_uu = &vv + &uu;
let vv_minus_uu = &vv - &uu;
let uv2 = (self.u + self.v).square();
let vv_plus_uu = vv + uu;
let vv_minus_uu = vv - uu;
// The remaining arithmetic is exactly the process of converting
// from a completed point to an extended point.
CompletedPoint {
u: &uv2 - &vv_plus_uu,
u: uv2 - vv_plus_uu,
v: vv_plus_uu,
z: vv_minus_uu,
t: &zz2 - &vv_minus_uu,
t: zz2 - vv_minus_uu,
}
.into_extended()
}
@ -683,18 +683,18 @@ impl<'a, 'b> Add<&'b ExtendedNielsPoint> for &'a ExtendedPoint {
// Z3 = F * G
// T3 = E * H
let a = (&self.v - &self.u) * &other.v_minus_u;
let b = (&self.v + &self.u) * &other.v_plus_u;
let c = &self.t1 * &self.t2 * &other.t2d;
let d = (&self.z * &other.z).double();
let a = (self.v - self.u) * other.v_minus_u;
let b = (self.v + self.u) * other.v_plus_u;
let c = self.t1 * self.t2 * other.t2d;
let d = (self.z * other.z).double();
// The remaining arithmetic is exactly the process of converting
// from a completed point to an extended point.
CompletedPoint {
u: &b - &a,
v: &b + &a,
z: &d + &c,
t: &d - &c,
u: b - a,
v: b + a,
z: d + c,
t: d - c,
}
.into_extended()
}
@ -705,16 +705,16 @@ impl<'a, 'b> Sub<&'b ExtendedNielsPoint> for &'a ExtendedPoint {
#[allow(clippy::suspicious_arithmetic_impl)]
fn sub(self, other: &'b ExtendedNielsPoint) -> ExtendedPoint {
let a = (&self.v - &self.u) * &other.v_plus_u;
let b = (&self.v + &self.u) * &other.v_minus_u;
let c = &self.t1 * &self.t2 * &other.t2d;
let d = (&self.z * &other.z).double();
let a = (self.v - self.u) * other.v_plus_u;
let b = (self.v + self.u) * other.v_minus_u;
let c = self.t1 * self.t2 * other.t2d;
let d = (self.z * other.z).double();
CompletedPoint {
u: &b - &a,
v: &b + &a,
z: &d - &c,
t: &d + &c,
u: b - a,
v: b + a,
z: d - c,
t: d + c,
}
.into_extended()
}
@ -731,18 +731,18 @@ impl<'a, 'b> Add<&'b AffineNielsPoint> for &'a ExtendedPoint {
// except we can assume that `other.z` is one, so that we perform
// 7 multiplications.
let a = (&self.v - &self.u) * &other.v_minus_u;
let b = (&self.v + &self.u) * &other.v_plus_u;
let c = &self.t1 * &self.t2 * &other.t2d;
let a = (self.v - self.u) * other.v_minus_u;
let b = (self.v + self.u) * other.v_plus_u;
let c = self.t1 * self.t2 * other.t2d;
let d = self.z.double();
// The remaining arithmetic is exactly the process of converting
// from a completed point to an extended point.
CompletedPoint {
u: &b - &a,
v: &b + &a,
z: &d + &c,
t: &d - &c,
u: b - a,
v: b + a,
z: d + c,
t: d - c,
}
.into_extended()
}
@ -753,16 +753,16 @@ impl<'a, 'b> Sub<&'b AffineNielsPoint> for &'a ExtendedPoint {
#[allow(clippy::suspicious_arithmetic_impl)]
fn sub(self, other: &'b AffineNielsPoint) -> ExtendedPoint {
let a = (&self.v - &self.u) * &other.v_plus_u;
let b = (&self.v + &self.u) * &other.v_minus_u;
let c = &self.t1 * &self.t2 * &other.t2d;
let a = (self.v - self.u) * other.v_plus_u;
let b = (self.v + self.u) * other.v_minus_u;
let c = self.t1 * self.t2 * other.t2d;
let d = self.z.double();
CompletedPoint {
u: &b - &a,
v: &b + &a,
z: &d - &c,
t: &d + &c,
u: b - a,
v: b + a,
z: d - c,
t: d + c,
}
.into_extended()
}
@ -832,9 +832,9 @@ impl CompletedPoint {
#[inline]
fn into_extended(self) -> ExtendedPoint {
ExtendedPoint {
u: &self.u * &self.t,
v: &self.v * &self.z,
z: &self.z * &self.t,
u: self.u * self.t,
v: self.v * self.z,
z: self.z * self.t,
t1: self.u,
t2: self.v,
}
@ -952,16 +952,16 @@ fn test_extended_niels_point_identity() {
fn test_assoc() {
let p = ExtendedPoint::from(AffinePoint {
u: Fq::from_raw([
0x81c571e5d883cfb0,
0x049f7a686f147029,
0xf539c860bc3ea21f,
0x4284715b7ccc8162,
0x81c5_71e5_d883_cfb0,
0x049f_7a68_6f14_7029,
0xf539_c860_bc3e_a21f,
0x4284_715b_7ccc_8162,
]),
v: Fq::from_raw([
0xbf096275684bb8ca,
0xc7ba245890af256d,
0x59119f3e86380eb0,
0x3793de182f9fb1d2,
0xbf09_6275_684b_b8ca,
0xc7ba_2458_90af_256d,
0x5911_9f3e_8638_0eb0,
0x3793_de18_2f9f_b1d2,
]),
})
.mul_by_cofactor();
@ -977,16 +977,16 @@ fn test_assoc() {
fn test_batch_normalize() {
let mut p = ExtendedPoint::from(AffinePoint {
u: Fq::from_raw([
0x81c571e5d883cfb0,
0x049f7a686f147029,
0xf539c860bc3ea21f,
0x4284715b7ccc8162,
0x81c5_71e5_d883_cfb0,
0x049f_7a68_6f14_7029,
0xf539_c860_bc3e_a21f,
0x4284_715b_7ccc_8162,
]),
v: Fq::from_raw([
0xbf096275684bb8ca,
0xc7ba245890af256d,
0x59119f3e86380eb0,
0x3793de182f9fb1d2,
0xbf09_6275_684b_b8ca,
0xc7ba_2458_90af_256d,
0x5911_9f3e_8638_0eb0,
0x3793_de18_2f9f_b1d2,
]),
})
.mul_by_cofactor();
@ -1019,10 +1019,10 @@ fn test_batch_normalize() {
#[cfg(test)]
const FULL_GENERATOR: AffinePoint = AffinePoint::from_raw_unchecked(
Fq::from_raw([
0xe4b3d35df1a7adfe,
0xcaf55d1b29bf81af,
0x8b0f03ddd60a8187,
0x62edcbb8bf3787c8,
0xe4b3_d35d_f1a7_adfe,
0xcaf5_5d1b_29bf_81af,
0x8b0f_03dd_d60a_8187,
0x62ed_cbb8_bf37_87c8,
]),
Fq::from_raw([0xb, 0x0, 0x0, 0x0]),
);
@ -1031,80 +1031,85 @@ const FULL_GENERATOR: AffinePoint = AffinePoint::from_raw_unchecked(
const EIGHT_TORSION: [AffinePoint; 8] = [
AffinePoint::from_raw_unchecked(
Fq::from_raw([
0xd92e6a7927200d43,
0x7aa41ac43dae8582,
0xeaaae086a16618d1,
0x71d4df38ba9e7973,
0xd92e_6a79_2720_0d43,
0x7aa4_1ac4_3dae_8582,
0xeaaa_e086_a166_18d1,
0x71d4_df38_ba9e_7973,
]),
Fq::from_raw([
0xff0d2068eff496dd,
0x9106ee90f384a4a1,
0x16a13035ad4d7266,
0x4958bdb21966982e,
0xff0d_2068_eff4_96dd,
0x9106_ee90_f384_a4a1,
0x16a1_3035_ad4d_7266,
0x4958_bdb2_1966_982e,
]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([
0xfffeffff00000001,
0x67baa40089fb5bfe,
0xa5e80b39939ed334,
0x73eda753299d7d47,
0xfffe_ffff_0000_0001,
0x67ba_a400_89fb_5bfe,
0xa5e8_0b39_939e_d334,
0x73ed_a753_299d_7d47,
]),
Fq::from_raw([0x0, 0x0, 0x0, 0x0]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([
0xd92e6a7927200d43,
0x7aa41ac43dae8582,
0xeaaae086a16618d1,
0x71d4df38ba9e7973,
0xd92e_6a79_2720_0d43,
0x7aa4_1ac4_3dae_8582,
0xeaaa_e086_a166_18d1,
0x71d4_df38_ba9e_7973,
]),
Fq::from_raw([
0xf2df96100b6924,
0xc2b6b5720c79b75d,
0x1c98a7d25c54659e,
0x2a94e9a11036e51a,
0x00f2_df96_100b_6924,
0xc2b6_b572_0c79_b75d,
0x1c98_a7d2_5c54_659e,
0x2a94_e9a1_1036_e51a,
]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([0x0, 0x0, 0x0, 0x0]),
Fq::from_raw([
0xffffffff00000000,
0x53bda402fffe5bfe,
0x3339d80809a1d805,
0x73eda753299d7d48,
0xffff_ffff_0000_0000,
0x53bd_a402_fffe_5bfe,
0x3339_d808_09a1_d805,
0x73ed_a753_299d_7d48,
]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([
0x26d19585d8dff2be,
0xd919893ec24fd67c,
0x488ef781683bbf33,
0x218c81a6eff03d4,
0x26d1_9585_d8df_f2be,
0xd919_893e_c24f_d67c,
0x488e_f781_683b_bf33,
0x0218_c81a_6eff_03d4,
]),
Fq::from_raw([
0xf2df96100b6924,
0xc2b6b5720c79b75d,
0x1c98a7d25c54659e,
0x2a94e9a11036e51a,
0x00f2_df96_100b_6924,
0xc2b6_b572_0c79_b75d,
0x1c98_a7d2_5c54_659e,
0x2a94_e9a1_1036_e51a,
]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([0x1000000000000, 0xec03000276030000, 0x8d51ccce760304d0, 0x0]),
Fq::from_raw([
0x0001_0000_0000_0000,
0xec03_0002_7603_0000,
0x8d51_ccce_7603_04d0,
0x0,
]),
Fq::from_raw([0x0, 0x0, 0x0, 0x0]),
),
AffinePoint::from_raw_unchecked(
Fq::from_raw([
0x26d19585d8dff2be,
0xd919893ec24fd67c,
0x488ef781683bbf33,
0x218c81a6eff03d4,
0x26d1_9585_d8df_f2be,
0xd919_893e_c24f_d67c,
0x488e_f781_683b_bf33,
0x0218_c81a_6eff_03d4,
]),
Fq::from_raw([
0xff0d2068eff496dd,
0x9106ee90f384a4a1,
0x16a13035ad4d7266,
0x4958bdb21966982e,
0xff0d_2068_eff4_96dd,
0x9106_ee90_f384_a4a1,
0x16a1_3035_ad4d_7266,
0x4958_bdb2_1966_982e,
]),
),
AffinePoint::from_raw_unchecked(
@ -1192,36 +1197,36 @@ fn test_is_identity() {
#[test]
fn test_mul_consistency() {
let a = Fr([
0x21e61211d9934f2e,
0xa52c058a693c3e07,
0x9ccb77bfb12d6360,
0x07df2470ec94398e,
0x21e6_1211_d993_4f2e,
0xa52c_058a_693c_3e07,
0x9ccb_77bf_b12d_6360,
0x07df_2470_ec94_398e,
]);
let b = Fr([
0x03336d1cbe19dbe0,
0x0153618f6156a536,
0x2604c9e1fc3c6b15,
0x04ae581ceb028720,
0x0333_6d1c_be19_dbe0,
0x0153_618f_6156_a536,
0x2604_c9e1_fc3c_6b15,
0x04ae_581c_eb02_8720,
]);
let c = Fr([
0xd7abf5bb24683f4c,
0x9d7712cc274b7c03,
0x973293db9683789f,
0x0b677e29380a97a7,
0xd7ab_f5bb_2468_3f4c,
0x9d77_12cc_274b_7c03,
0x9732_93db_9683_789f,
0x0b67_7e29_380a_97a7,
]);
assert_eq!(a * b, c);
let p = ExtendedPoint::from(AffinePoint {
u: Fq::from_raw([
0x81c571e5d883cfb0,
0x049f7a686f147029,
0xf539c860bc3ea21f,
0x4284715b7ccc8162,
0x81c5_71e5_d883_cfb0,
0x049f_7a68_6f14_7029,
0xf539_c860_bc3e_a21f,
0x4284_715b_7ccc_8162,
]),
v: Fq::from_raw([
0xbf096275684bb8ca,
0xc7ba245890af256d,
0x59119f3e86380eb0,
0x3793de182f9fb1d2,
0xbf09_6275_684b_b8ca,
0xc7ba_2458_90af_256d,
0x5911_9f3e_8638_0eb0,
0x3793_de18_2f9f_b1d2,
]),
})
.mul_by_cofactor();
@ -1318,6 +1323,6 @@ fn test_serialization_consistency() {
let deserialized = AffinePoint::from_bytes(serialized).unwrap();
assert_eq!(affine, deserialized);
assert_eq!(expected_serialized, serialized);
p = p + &gen;
p += gen;
}
}

View File

@ -24,9 +24,8 @@ fn test_key_agreement() {
let addr = loop {
let mut d = [0; 11];
rng.fill_bytes(&mut d);
match vk.to_payment_address(Diversifier(d), &params) {
Some(a) => break a,
None => {}
if let Some(a) = vk.to_payment_address(Diversifier(d), &params) {
break a;
}
};

View File

@ -458,6 +458,7 @@ fn test_b_coeff() {
}
#[test]
#[allow(clippy::cognitive_complexity)]
fn test_frob_coeffs() {
let nqr = Fq::one().neg();

View File

@ -76,7 +76,7 @@ impl Add for Fq12 {
type Output = Self;
fn add(self, other: Self) -> Self {
self + &other
self.add(&other)
}
}
@ -108,7 +108,7 @@ impl Sub for Fq12 {
type Output = Self;
fn sub(self, other: Self) -> Self {
self - &other
self.sub(&other)
}
}
@ -139,7 +139,7 @@ impl Mul for Fq12 {
type Output = Self;
fn mul(self, other: Self) -> Self {
self * &other
self.mul(&other)
}
}

View File

@ -90,7 +90,7 @@ impl Add for Fq2 {
type Output = Self;
fn add(self, other: Self) -> Self {
self + &other
self.add(&other)
}
}
@ -122,7 +122,7 @@ impl Sub for Fq2 {
type Output = Self;
fn sub(self, other: Self) -> Self {
self - &other
self.sub(&other)
}
}
@ -153,7 +153,7 @@ impl Mul for Fq2 {
type Output = Self;
fn mul(self, other: Self) -> Self {
self * &other
self.mul(&other)
}
}
@ -309,7 +309,7 @@ fn test_fq2_ordering() {
c1: Fq::zero(),
};
let mut b = a.clone();
let mut b = a;
assert!(a.cmp(&b) == Ordering::Equal);
b.c0.add_assign(&Fq::one());

View File

@ -139,7 +139,7 @@ impl Add for Fq6 {
type Output = Self;
fn add(self, other: Self) -> Self {
self + &other
self.add(&other)
}
}
@ -173,7 +173,7 @@ impl Sub for Fq6 {
type Output = Self;
fn sub(self, other: Self) -> Self {
self - &other
self.sub(&other)
}
}
@ -205,7 +205,7 @@ impl Mul for Fq6 {
type Output = Self;
fn mul(self, other: Self) -> Self {
self * &other
self.mul(&other)
}
}

View File

@ -9,7 +9,7 @@ pub fn random_frobenius_tests<F: Field, C: AsRef<[u64]>>(characteristic: C, maxp
]);
for _ in 0..100 {
for i in 0..(maxpower + 1) {
for i in 0..=maxpower {
let mut a = F::random(&mut rng);
let mut b = a;

View File

@ -68,7 +68,7 @@ fn random_shl_tests<P: PrimeField>() {
for _ in 0..100 {
let r = P::random(&mut rng).into_repr();
for shift in 0..(r.num_bits() + 1) {
for shift in 0..=r.num_bits() {
let mut r1 = r;
let mut r2 = r;
@ -92,7 +92,7 @@ fn random_shr_tests<P: PrimeField>() {
for _ in 0..100 {
let r = P::random(&mut rng).into_repr();
for shift in 0..(r.num_bits() + 1) {
for shift in 0..=r.num_bits() {
let mut r1 = r;
let mut r2 = r;