mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-10 16:01:28 +01:00
[RFC] Convert identity functions in Field, Group, and {Projective,Affine}Curve traits with One/Zero traits from num_traits.
- contributes to #50, - depends on #53 and builds on it, - due to coherence & requirements of `num_traits::{Zero, One}` to implement `std::ops::Add<Self, ..>` and (resp.) `std::ops::Mul<Self, ..>`, I've had to replace the afferent `impl<'a, P: ..> (Add|Mul)<&'a Self> for Group(Affine|Projective)<P>` by direct implementations on `Self`, - I did not have to fight the borrow checker for this conversion => I think this hints arithmetic operations are called in contexts where the operand is owned, - hence should this end up on a merge track, we may want to open an issue to convert the `impl<'a, P:..> (Neg|Sub|..)<&'a Self> for ..<P>` trait usage to direct `impl<P:..> (Neg|Sub|..)<Self> for ..<P>` - the `impl AddAssign for GroupAffine<P>` in curves/models/short_weierstrass_jacobian.rs is provided to fit trait bounds, and without any guarantee of suitability for any particular purpose - and that, even though I don't think it's used.
This commit is contained in:
committed by
Pratyush Mishra
parent
b8a81b5dcb
commit
722a901ae7
@@ -32,6 +32,7 @@ bench-utils = { path = "../bench-utils" }
|
||||
digest = "0.7"
|
||||
blake2 = "0.7"
|
||||
|
||||
num-traits = { version = "0.2.11" }
|
||||
rand = { version = "0.7" }
|
||||
derivative = "1"
|
||||
rayon = "1"
|
||||
|
||||
@@ -372,6 +372,7 @@ mod test {
|
||||
merkle_tree::*,
|
||||
};
|
||||
use algebra::curves::jubjub::JubJubAffine as JubJub;
|
||||
use num_traits::Zero;
|
||||
use rand::SeedableRng;
|
||||
use rand_xorshift::XorShiftRng;
|
||||
|
||||
@@ -419,7 +420,6 @@ mod test {
|
||||
}
|
||||
|
||||
fn bad_merkle_tree_verify<L: ToBytes + Clone + Eq>(leaves: &[L]) -> () {
|
||||
use algebra::groups::Group;
|
||||
let mut rng = XorShiftRng::seed_from_u64(13423423u64);
|
||||
|
||||
let crh_parameters = Rc::new(H::setup(&mut rng).unwrap());
|
||||
|
||||
@@ -59,7 +59,8 @@ mod test {
|
||||
#[test]
|
||||
fn test_gm17() {
|
||||
use crate::nizk::{gm17::Gm17, NIZK};
|
||||
use algebra::{curves::bls12_381::Bls12_381, fields::bls12_381::Fr, Field};
|
||||
use algebra::{curves::bls12_381::Bls12_381, fields::bls12_381::Fr};
|
||||
use num_traits::One;
|
||||
use r1cs_core::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
||||
@@ -6,6 +6,7 @@ use algebra::{
|
||||
to_bytes, ToConstraintField, UniformRand,
|
||||
};
|
||||
use digest::Digest;
|
||||
use num_traits::{One, Zero};
|
||||
use rand::Rng;
|
||||
use std::{
|
||||
hash::Hash,
|
||||
|
||||
Reference in New Issue
Block a user