From fe43f9d268fb405c47300c31c7b762e63041a044 Mon Sep 17 00:00:00 2001 From: onewayfunc Date: Fri, 16 Dec 2022 19:41:10 -0800 Subject: [PATCH 1/5] update --- bls12_381/src/fields/fq.rs | 2 ++ bls12_381/src/fields/fr.rs | 2 ++ curve25519/src/fields/fq.rs | 2 ++ curve25519/src/fields/fr.rs | 2 ++ ed25519/Cargo.toml | 1 + ed25519/src/fields/fq.rs | 8 +------- ed25519/src/fields/fr.rs | 8 +------- secp256k1/src/fields/fq.rs | 2 ++ secp256k1/src/fields/fr.rs | 2 ++ 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bls12_381/src/fields/fq.rs b/bls12_381/src/fields/fq.rs index 34517ffd..607b0b89 100644 --- a/bls12_381/src/fields/fq.rs +++ b/bls12_381/src/fields/fq.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp384, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"] #[generator = "2"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "2"] pub struct FqConfig; pub type Fq = Fp384>; diff --git a/bls12_381/src/fields/fr.rs b/bls12_381/src/fields/fr.rs index 721bc6db..284096e5 100644 --- a/bls12_381/src/fields/fr.rs +++ b/bls12_381/src/fields/fr.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "52435875175126190479447740508185965837690552500527637822603658699938581184513"] #[generator = "7"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "1"] pub struct FrConfig; pub type Fr = Fp256>; diff --git a/curve25519/src/fields/fq.rs b/curve25519/src/fields/fq.rs index 05dcf2fb..38ac5a33 100644 --- a/curve25519/src/fields/fq.rs +++ b/curve25519/src/fields/fq.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "57896044618658097711785492504343953926634992332820282019728792003956564819949"] #[generator = "2"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "1"] pub struct FqConfig; pub type Fq = Fp256>; diff --git a/curve25519/src/fields/fr.rs b/curve25519/src/fields/fr.rs index b387bffb..4ef8043b 100644 --- a/curve25519/src/fields/fr.rs +++ b/curve25519/src/fields/fr.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "7237005577332262213973186563042994240857116359379907606001950938285454250989"] #[generator = "2"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "1"] pub struct FrConfig; pub type Fr = Fp256>; diff --git a/ed25519/Cargo.toml b/ed25519/Cargo.toml index c52ee731..3fe0154c 100644 --- a/ed25519/Cargo.toml +++ b/ed25519/Cargo.toml @@ -17,6 +17,7 @@ ark-ff = { version = "0.4.0-alpha", default-features = false } ark-ec = { version = "0.4.0-alpha", default-features = false } ark-std = { version = "0.4.0-alpha", default-features = false } ark-r1cs-std = { version = "0.4.0-alpha", default-features = false, optional = true } +ark-curve25519 = { path = "../curve25519" } [dev-dependencies] ark-relations = { version = "0.4.0-alpha", default-features = false } diff --git a/ed25519/src/fields/fq.rs b/ed25519/src/fields/fq.rs index 05dcf2fb..b92c422c 100644 --- a/ed25519/src/fields/fq.rs +++ b/ed25519/src/fields/fq.rs @@ -1,7 +1 @@ -use ark_ff::fields::{Fp256, MontBackend, MontConfig}; - -#[derive(MontConfig)] -#[modulus = "57896044618658097711785492504343953926634992332820282019728792003956564819949"] -#[generator = "2"] -pub struct FqConfig; -pub type Fq = Fp256>; +pub use ark_curve25519::{Fq, FqConfig}; diff --git a/ed25519/src/fields/fr.rs b/ed25519/src/fields/fr.rs index b387bffb..8c07ca6d 100644 --- a/ed25519/src/fields/fr.rs +++ b/ed25519/src/fields/fr.rs @@ -1,7 +1 @@ -use ark_ff::fields::{Fp256, MontBackend, MontConfig}; - -#[derive(MontConfig)] -#[modulus = "7237005577332262213973186563042994240857116359379907606001950938285454250989"] -#[generator = "2"] -pub struct FrConfig; -pub type Fr = Fp256>; +pub use ark_curve25519::{Fr, FrConfig}; diff --git a/secp256k1/src/fields/fq.rs b/secp256k1/src/fields/fq.rs index eb045f2f..87018cb8 100644 --- a/secp256k1/src/fields/fq.rs +++ b/secp256k1/src/fields/fq.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"] #[generator = "3"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "1"] pub struct FqConfig; pub type Fq = Fp256>; diff --git a/secp256k1/src/fields/fr.rs b/secp256k1/src/fields/fr.rs index cb476cb4..940b97a0 100644 --- a/secp256k1/src/fields/fr.rs +++ b/secp256k1/src/fields/fr.rs @@ -3,5 +3,7 @@ use ark_ff::fields::{Fp256, MontBackend, MontConfig}; #[derive(MontConfig)] #[modulus = "115792089237316195423570985008687907852837564279074904382605163141518161494337"] #[generator = "7"] +#[small_subgroup_base = "3"] +#[small_subgroup_power = "1"] pub struct FrConfig; pub type Fr = Fp256>; From fb1515f5c08c4984d7207042d26ed62ceb474c97 Mon Sep 17 00:00:00 2001 From: onewayfunc Date: Sun, 18 Dec 2022 11:16:51 -0800 Subject: [PATCH 2/5] use r1cs std --- Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9abcd04d..08a0e497 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,4 +67,5 @@ debug = true ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } ark-ec = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } -ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } \ No newline at end of file +ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } +ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std/", branch = "release-0.4" } \ No newline at end of file From 019f539bfa2cd0c1553bee2c3fcb60689423c634 Mon Sep 17 00:00:00 2001 From: onewayfunc Date: Sun, 18 Dec 2022 14:28:02 -0800 Subject: [PATCH 3/5] fix --- Cargo.toml | 9 +++++---- secp256k1/src/fields/tests.rs | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 08a0e497..550de158 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,8 +64,9 @@ debug-assertions = true debug = true [patch.crates-io] -ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } -ark-ec = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } -ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } -ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } +ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } +ark-ec = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } +ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } +ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } +ark-algebra-test-templates = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std/", branch = "release-0.4" } \ No newline at end of file diff --git a/secp256k1/src/fields/tests.rs b/secp256k1/src/fields/tests.rs index bd978b4e..22cc3da9 100644 --- a/secp256k1/src/fields/tests.rs +++ b/secp256k1/src/fields/tests.rs @@ -1,5 +1,8 @@ +use std::str::FromStr; use crate::{Fq, Fr}; use ark_algebra_test_templates::*; +use ark_algebra_test_templates::num_bigint::BigUint; +use ark_ff::{MontFp, PrimeField}; test_field!(fr; Fr; mont_prime_field); -test_field!(fq; Fq; mont_prime_field); +test_field!(fq; Fq; mont_prime_field); \ No newline at end of file From 433a125a93009a71f2fae139f88235e9c886482a Mon Sep 17 00:00:00 2001 From: onewayfunc Date: Sun, 18 Dec 2022 14:28:39 -0800 Subject: [PATCH 4/5] rem --- secp256k1/src/fields/tests.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/secp256k1/src/fields/tests.rs b/secp256k1/src/fields/tests.rs index 22cc3da9..bd978b4e 100644 --- a/secp256k1/src/fields/tests.rs +++ b/secp256k1/src/fields/tests.rs @@ -1,8 +1,5 @@ -use std::str::FromStr; use crate::{Fq, Fr}; use ark_algebra_test_templates::*; -use ark_algebra_test_templates::num_bigint::BigUint; -use ark_ff::{MontFp, PrimeField}; test_field!(fr; Fr; mont_prime_field); -test_field!(fq; Fq; mont_prime_field); \ No newline at end of file +test_field!(fq; Fq; mont_prime_field); From 5d1731f0d576986e4ffffefe6c8324224e8ebe27 Mon Sep 17 00:00:00 2001 From: Weikeng Chen Date: Wed, 21 Dec 2022 16:30:29 -0800 Subject: [PATCH 5/5] Apply suggestions from code review --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 550de158..465d056b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ debug = true [patch.crates-io] ark-ff = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } ark-ec = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } -ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } +ark-poly = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4" } ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } ark-algebra-test-templates = { git = "https://github.com/arkworks-rs/algebra/", branch = "release-0.4-debug-secp256k1" } ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std/", branch = "release-0.4" } \ No newline at end of file