mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-08 23:11:29 +01:00
Sync with the recent changes in ark-algebra on pairing and testing (#116)
* Fix another typo in the Jubjub curve comment * fix * progress * get_point_from_x_unchecked * fix * soft link * Fix Bandersnatch * Fix Edwards form of Bandersnatch * Actually fix ed_on_bls12_381_bandersnatch/src/curves/mod.rs * fix * fix * curve-benches * fix the last mul_by_a; fmt Co-authored-by: onewayfunc <onewayfunc@gmail.com> Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
This commit is contained in:
@@ -10,7 +10,7 @@ keywords = ["cryptography", "finite-fields", "elliptic-curves" ]
|
||||
categories = ["cryptography"]
|
||||
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||
license = "MIT/Apache-2.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
ark-ff = { version="^0.3.0", default-features = false }
|
||||
|
||||
@@ -3,7 +3,7 @@ use ark_ec::{
|
||||
bls12::Bls12Parameters,
|
||||
models::CurveConfig,
|
||||
short_weierstrass::{Affine, SWCurveConfig},
|
||||
AffineCurve, ProjectiveCurve,
|
||||
AffineRepr, Group,
|
||||
};
|
||||
use ark_ff::{Field, MontFp, Zero};
|
||||
use ark_std::ops::Neg;
|
||||
@@ -40,7 +40,7 @@ impl SWCurveConfig for Parameters {
|
||||
const GENERATOR: G1Affine = G1Affine::new_unchecked(G1_GENERATOR_X, G1_GENERATOR_Y);
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
|
||||
fn mul_by_a(_: Self::BaseField) -> Self::BaseField {
|
||||
Self::BaseField::zero()
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use ark_ec::{
|
||||
bls12::Bls12Parameters,
|
||||
models::CurveConfig,
|
||||
short_weierstrass::{Affine, SWCurveConfig},
|
||||
AffineCurve,
|
||||
AffineRepr,
|
||||
};
|
||||
use ark_ff::{Field, MontFp, Zero};
|
||||
|
||||
@@ -51,7 +51,7 @@ impl SWCurveConfig for Parameters {
|
||||
const GENERATOR: G2Affine = G2Affine::new_unchecked(G2_GENERATOR_X, G2_GENERATOR_Y);
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_by_a(_: &Self::BaseField) -> Self::BaseField {
|
||||
fn mul_by_a(_: Self::BaseField) -> Self::BaseField {
|
||||
Self::BaseField::zero()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
use ark_algebra_test_templates::{
|
||||
curves::*, generate_bilinearity_test, generate_g1_generator_raw_test, generate_g1_test,
|
||||
generate_g2_test, msm::*,
|
||||
};
|
||||
use ark_ec::{
|
||||
models::short_weierstrass::SWCurveConfig, AffineCurve, PairingEngine, ProjectiveCurve,
|
||||
};
|
||||
use ark_ff::{
|
||||
fields::{Field, PrimeField},
|
||||
One, UniformRand, Zero,
|
||||
};
|
||||
use ark_algebra_test_templates::*;
|
||||
use ark_ec::{AffineRepr, CurveGroup};
|
||||
use ark_ff::{fields::Field, One, UniformRand, Zero};
|
||||
use ark_std::{rand::Rng, test_rng};
|
||||
use core::ops::{AddAssign, MulAssign};
|
||||
|
||||
use crate::{g1, g2, Bls12_381, Fq, Fq12, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
|
||||
use crate::{Bls12_381, Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
|
||||
|
||||
generate_g1_test!(bls12_381; curve_tests; sw_tests;);
|
||||
generate_g2_test!(bls12_381; curve_tests; sw_tests;);
|
||||
generate_bilinearity_test!(Bls12_381, Fq12);
|
||||
generate_g1_generator_raw_test!(bls12_381, 4);
|
||||
test_group!(g1; G1Projective; sw);
|
||||
test_group!(g2; G2Projective; sw);
|
||||
test_group!(pairing_output; ark_ec::pairing::PairingOutput<Bls12_381>; msm);
|
||||
test_pairing!(pairing; crate::Bls12_381);
|
||||
|
||||
#[test]
|
||||
fn test_g1_endomorphism_beta() {
|
||||
assert!(g1::BETA.pow(&[3u64]).is_one());
|
||||
assert!(crate::g1::BETA.pow(&[3u64]).is_one());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -38,12 +29,8 @@ fn test_g1_subgroup_non_membership_via_endomorphism() {
|
||||
let x = Fq::rand(&mut rng);
|
||||
let greatest = rng.gen();
|
||||
|
||||
if let Some(p) = G1Affine::get_point_from_x(x, greatest) {
|
||||
if !p
|
||||
.into_projective()
|
||||
.mul_bigint(Fr::characteristic())
|
||||
.is_zero()
|
||||
{
|
||||
if let Some(p) = G1Affine::get_point_from_x_unchecked(x, greatest) {
|
||||
if !p.mul_bigint(Fr::characteristic()).is_zero() {
|
||||
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
||||
return;
|
||||
}
|
||||
@@ -65,12 +52,8 @@ fn test_g2_subgroup_non_membership_via_endomorphism() {
|
||||
let x = Fq2::rand(&mut rng);
|
||||
let greatest = rng.gen();
|
||||
|
||||
if let Some(p) = G2Affine::get_point_from_x(x, greatest) {
|
||||
if !p
|
||||
.into_projective()
|
||||
.mul_bigint(Fr::characteristic())
|
||||
.is_zero()
|
||||
{
|
||||
if let Some(p) = G2Affine::get_point_from_x_unchecked(x, greatest) {
|
||||
if !p.mul_bigint(Fr::characteristic()).is_zero() {
|
||||
assert!(!p.is_in_correct_subgroup_assuming_on_curve());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
use ark_algebra_test_templates::{
|
||||
fields::*, generate_field_serialization_test, generate_field_test,
|
||||
};
|
||||
use ark_algebra_test_templates::*;
|
||||
use ark_ff::{
|
||||
biginteger::{BigInt, BigInteger, BigInteger384},
|
||||
fields::{FftField, Field, Fp12Config, Fp2Config, Fp6Config, PrimeField},
|
||||
One, UniformRand, Zero,
|
||||
};
|
||||
use ark_serialize::{buffer_bit_byte_size, CanonicalSerialize};
|
||||
use ark_std::{
|
||||
cmp::Ordering,
|
||||
ops::{AddAssign, MulAssign, SubAssign},
|
||||
rand::Rng,
|
||||
test_rng, vec,
|
||||
vec,
|
||||
};
|
||||
|
||||
use crate::{Fq, Fq12, Fq12Config, Fq2, Fq2Config, Fq6, Fq6Config, FqConfig, Fr, FrConfig};
|
||||
use crate::{Fq, Fq12, Fq12Config, Fq2, Fq2Config, Fq6, Fq6Config, Fr};
|
||||
|
||||
generate_field_test!(bls12_381; fq2; fq6; fq12; mont(6, 4); );
|
||||
generate_field_serialization_test!(bls12_381; fq2; fq6; fq12;);
|
||||
test_field!(fr; Fr; mont_prime_field);
|
||||
test_field!(fq; Fq; mont_prime_field);
|
||||
test_field!(fq2; Fq2);
|
||||
test_field!(fq6; Fq6);
|
||||
test_field!(fq12; Fq12);
|
||||
|
||||
#[test]
|
||||
fn test_negative_one() {
|
||||
|
||||
Reference in New Issue
Block a user