Browse Source

Import AdditiveGroup. (#122)

Co-authored-by: mmagician <marcin.gorny.94@protonmail.com>
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
avoid_assigned_value
Michele Orrù 1 year ago
committed by GitHub
parent
commit
529c8dc29e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 10 deletions
  1. +18
    -3
      Cargo.toml
  2. +3
    -1
      src/bits/boolean.rs
  3. +2
    -2
      src/groups/curves/short_weierstrass/mod.rs
  4. +1
    -1
      src/groups/curves/short_weierstrass/non_zero_affine.rs
  5. +2
    -3
      src/groups/curves/twisted_edwards/mod.rs

+ 18
- 3
Cargo.toml

@ -10,7 +10,8 @@ keywords = ["zero-knowledge", "cryptography", "zkSNARK", "SNARK", "r1cs"]
categories = ["cryptography"] categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
edition = "2018"
edition = "2021"
resolver = "2"
[dependencies] [dependencies]
ark-ff = { version = "0.4.0", default-features = false } ark-ff = { version = "0.4.0", default-features = false }
@ -20,8 +21,8 @@ ark-relations = { version = "0.4.0", default-features = false }
derivative = { version = "2", features = ["use_core"] } derivative = { version = "2", features = ["use_core"] }
tracing = { version = "0.1", default-features = false, features = [ "attributes" ] } tracing = { version = "0.1", default-features = false, features = [ "attributes" ] }
num-bigint = {version = "0.4", default-features = false }
num-traits = {version = "0.2", default-features = false }
num-bigint = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }
num-integer = { version = "0.1.44", default-features = false } num-integer = { version = "0.1.44", default-features = false }
[dev-dependencies] [dev-dependencies]
@ -70,3 +71,17 @@ lto = "thin"
incremental = true incremental = true
debug-assertions = true debug-assertions = true
debug = true debug = true
[patch.crates-io]
ark-ff = { git = "https://github.com/arkworks-rs/algebra/" }
ark-ec = { git = "https://github.com/arkworks-rs/algebra/" }
ark-poly = { git = "https://github.com/arkworks-rs/algebra/" }
ark-serialize = { git = "https://github.com/arkworks-rs/algebra/" }
ark-test-curves = { git = "https://github.com/arkworks-rs/algebra/" }
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves/" }
ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves/" }
ark-mnt4-298 = { git = "https://github.com/arkworks-rs/curves/" }
ark-mnt4-753 = { git = "https://github.com/arkworks-rs/curves/" }
ark-mnt6-298 = { git = "https://github.com/arkworks-rs/curves/" }
ark-mnt6-753 = { git = "https://github.com/arkworks-rs/curves/" }
ark-pallas = { git = "https://github.com/arkworks-rs/curves/" }

+ 3
- 1
src/bits/boolean.rs

@ -956,7 +956,9 @@ impl CondSelectGadget for Boolean {
mod test { mod test {
use super::{AllocatedBool, Boolean}; use super::{AllocatedBool, Boolean};
use crate::prelude::*; use crate::prelude::*;
use ark_ff::{BitIteratorBE, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero};
use ark_ff::{
AdditiveGroup, BitIteratorBE, BitIteratorLE, Field, One, PrimeField, UniformRand, Zero,
};
use ark_relations::r1cs::{ConstraintSystem, Namespace, SynthesisError}; use ark_relations::r1cs::{ConstraintSystem, Namespace, SynthesisError};
use ark_test_curves::bls12_381::Fr; use ark_test_curves::bls12_381::Fr;

+ 2
- 2
src/groups/curves/short_weierstrass/mod.rs

@ -4,7 +4,7 @@ use ark_ec::{
}, },
AffineRepr, CurveGroup, AffineRepr, CurveGroup,
}; };
use ark_ff::{BigInteger, BitIteratorBE, Field, One, PrimeField, Zero};
use ark_ff::{AdditiveGroup, BigInteger, BitIteratorBE, Field, One, PrimeField, Zero};
use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError}; use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError};
use ark_std::{borrow::Borrow, marker::PhantomData, ops::Mul}; use ark_std::{borrow::Borrow, marker::PhantomData, ops::Mul};
use non_zero_affine::NonZeroAffineVar; use non_zero_affine::NonZeroAffineVar;
@ -838,7 +838,7 @@ where
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight { let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
let ge = Self::new_variable_omit_prime_order_check( let ge = Self::new_variable_omit_prime_order_check(
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"), ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|| f().map(|g| g.borrow().into_affine().mul_by_cofactor_inv().into()),
|| f().map(|g| g.into_affine().mul_by_cofactor_inv().into()),
mode, mode,
)?; )?;
( (

+ 1
- 1
src/groups/curves/short_weierstrass/non_zero_affine.rs

@ -1,5 +1,5 @@
use super::*; use super::*;
use ark_ec::Group;
use ark_ec::AdditiveGroup;
use ark_std::ops::Add; use ark_std::ops::Add;
/// An affine representation of a prime order curve point that is guaranteed /// An affine representation of a prime order curve point that is guaranteed

+ 2
- 3
src/groups/curves/twisted_edwards/mod.rs

@ -3,7 +3,7 @@ use ark_ec::{
Affine as TEAffine, MontCurveConfig as MontgomeryModelParameter, Affine as TEAffine, MontCurveConfig as MontgomeryModelParameter,
Projective as TEProjective, TECurveConfig as TEModelParameters, Projective as TEProjective, TECurveConfig as TEModelParameters,
}, },
AffineRepr, CurveGroup, Group,
AdditiveGroup, AffineRepr, CurveGroup,
}; };
use ark_ff::{BigInteger, BitIteratorBE, Field, One, PrimeField, Zero}; use ark_ff::{BigInteger, BitIteratorBE, Field, One, PrimeField, Zero};
use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError}; use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError};
@ -337,7 +337,6 @@ where
.iter() .iter()
.zip(segment_powers.borrow()) .zip(segment_powers.borrow())
{ {
let base_power = base_power.borrow();
let mut acc_power = *base_power; let mut acc_power = *base_power;
let mut coords = vec![]; let mut coords = vec![];
for _ in 0..4 { for _ in 0..4 {
@ -609,7 +608,7 @@ where
let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight { let (mut ge, iter) = if cofactor_weight < modulus_minus_1_weight {
let ge = Self::new_variable_omit_prime_order_check( let ge = Self::new_variable_omit_prime_order_check(
ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"), ark_relations::ns!(cs, "Witness without subgroup check with cofactor mul"),
|| f().map(|g| g.borrow().into_affine().mul_by_cofactor_inv().into()),
|| f().map(|g| g.into_affine().mul_by_cofactor_inv().into()),
mode, mode,
)?; )?;
( (

Loading…
Cancel
Save