mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-12 08:51:35 +01:00
Refactor algebra API, split into algebra and algebra-core. (#100)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use algebra::Field;
|
||||
use algebra_core::Field;
|
||||
use r1cs_core::{ConstraintSystem, SynthesisError};
|
||||
use r1cs_std::prelude::*;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::nizk::{gm17::Gm17, NIZKVerifierGadget};
|
||||
use algebra::{AffineCurve, Field, PairingEngine, ToConstraintField};
|
||||
use algebra_core::{AffineCurve, Field, PairingEngine, ToConstraintField};
|
||||
use r1cs_core::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
|
||||
use r1cs_std::prelude::*;
|
||||
|
||||
@@ -404,12 +404,11 @@ mod test {
|
||||
|
||||
use super::*;
|
||||
use algebra::{
|
||||
curves::bls12_377::Bls12_377,
|
||||
fields::bls12_377::{Fq, Fr},
|
||||
bls12_377::{Bls12_377, Fq, Fr},
|
||||
test_rng, BitIterator, PrimeField,
|
||||
};
|
||||
use r1cs_std::{
|
||||
boolean::Boolean, pairing::bls12_377::PairingGadget as Bls12_377PairingGadget,
|
||||
bls12_377::PairingGadget as Bls12_377PairingGadget, boolean::Boolean,
|
||||
test_constraint_system::TestConstraintSystem,
|
||||
};
|
||||
use rand::Rng;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::Error;
|
||||
use algebra::PairingEngine;
|
||||
use algebra_core::PairingEngine;
|
||||
use gm17::{
|
||||
create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof,
|
||||
Parameters, PreparedVerifyingKey, Proof, VerifyingKey,
|
||||
@@ -7,7 +7,7 @@ use gm17::{
|
||||
use r1cs_core::ConstraintSynthesizer;
|
||||
use rand::Rng;
|
||||
|
||||
use algebra::ToConstraintField;
|
||||
use algebra_core::ToConstraintField;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use super::NIZK;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::nizk::{groth16::Groth16, NIZKVerifierGadget};
|
||||
use algebra::{AffineCurve, Field, PairingEngine, ToConstraintField};
|
||||
use algebra_core::{AffineCurve, Field, PairingEngine, ToConstraintField};
|
||||
use r1cs_core::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
|
||||
use r1cs_std::prelude::*;
|
||||
|
||||
@@ -351,12 +351,11 @@ mod test {
|
||||
|
||||
use super::*;
|
||||
use algebra::{
|
||||
curves::bls12_377::Bls12_377,
|
||||
fields::bls12_377::{Fq, Fr},
|
||||
bls12_377::{Bls12_377, Fq, Fr},
|
||||
test_rng, BitIterator, PrimeField,
|
||||
};
|
||||
use r1cs_std::{
|
||||
boolean::Boolean, pairing::bls12_377::PairingGadget as Bls12_377PairingGadget,
|
||||
bls12_377::PairingGadget as Bls12_377PairingGadget, boolean::Boolean,
|
||||
test_constraint_system::TestConstraintSystem,
|
||||
};
|
||||
use rand::Rng;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::Error;
|
||||
use algebra::PairingEngine;
|
||||
use algebra_core::PairingEngine;
|
||||
use groth16::{
|
||||
create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof,
|
||||
Parameters, PreparedVerifyingKey, Proof, VerifyingKey,
|
||||
@@ -7,7 +7,7 @@ use groth16::{
|
||||
use r1cs_core::ConstraintSynthesizer;
|
||||
use rand::Rng;
|
||||
|
||||
use algebra::ToConstraintField;
|
||||
use algebra_core::ToConstraintField;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use super::NIZK;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use algebra::bytes::ToBytes;
|
||||
use algebra_core::bytes::ToBytes;
|
||||
use rand::Rng;
|
||||
|
||||
#[cfg(feature = "gm17")]
|
||||
@@ -59,7 +59,10 @@ mod test {
|
||||
#[test]
|
||||
fn test_gm17() {
|
||||
use crate::nizk::{gm17::Gm17, NIZK};
|
||||
use algebra::{curves::bls12_381::Bls12_381, fields::bls12_381::Fr, One};
|
||||
use algebra::{
|
||||
bls12_377::{Bls12_377, Fr},
|
||||
One,
|
||||
};
|
||||
use r1cs_core::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
@@ -104,13 +107,13 @@ mod test {
|
||||
|
||||
let rng = &mut test_rng();
|
||||
|
||||
let parameters = Gm17::<Bls12_381, R1CSCircuit, [Fr]>::setup(circuit, rng).unwrap();
|
||||
let parameters = Gm17::<Bls12_377, R1CSCircuit, [Fr]>::setup(circuit, rng).unwrap();
|
||||
|
||||
let proof =
|
||||
Gm17::<Bls12_381, R1CSCircuit, [Fr]>::prove(¶meters.0, circuit, rng).unwrap();
|
||||
Gm17::<Bls12_377, R1CSCircuit, [Fr]>::prove(¶meters.0, circuit, rng).unwrap();
|
||||
|
||||
let result =
|
||||
Gm17::<Bls12_381, R1CSCircuit, [Fr]>::verify(¶meters.1, &[Fr::one(), sum], &proof)
|
||||
Gm17::<Bls12_377, R1CSCircuit, [Fr]>::verify(¶meters.1, &[Fr::one(), sum], &proof)
|
||||
.unwrap();
|
||||
assert!(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user