mirror of
https://github.com/arnaucube/ark-r1cs-std.git
synced 2026-01-12 00:41:32 +01:00
r1cs-std works with no-std (#92)
This commit is contained in:
@@ -5,9 +5,9 @@ use r1cs_core::{
|
||||
LinearCombination, SynthesisError,
|
||||
};
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use core::borrow::Borrow;
|
||||
|
||||
use crate::{boolean::AllocatedBit, prelude::*, Assignment};
|
||||
use crate::{boolean::AllocatedBit, prelude::*, Assignment, Vec};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FpGadget<F: PrimeField> {
|
||||
|
||||
@@ -8,9 +8,9 @@ use algebra::{
|
||||
},
|
||||
BitIterator, Field, One, PrimeField,
|
||||
};
|
||||
use std::{borrow::Borrow, marker::PhantomData};
|
||||
use core::{borrow::Borrow, marker::PhantomData};
|
||||
|
||||
use crate::{prelude::*, Assignment};
|
||||
use crate::{prelude::*, Assignment, Vec};
|
||||
|
||||
type Fp2Gadget<P, ConstraintF> = super::fp2::Fp2Gadget<
|
||||
<<P as Fp12Parameters>::Fp6Params as Fp6Parameters>::Fp2Params,
|
||||
|
||||
@@ -2,10 +2,10 @@ use algebra::{
|
||||
fields::{Fp2, Fp2Parameters},
|
||||
Field, PrimeField,
|
||||
};
|
||||
use core::{borrow::Borrow, marker::PhantomData};
|
||||
use r1cs_core::{ConstraintSystem, ConstraintVar, SynthesisError};
|
||||
use std::{borrow::Borrow, marker::PhantomData};
|
||||
|
||||
use crate::{fields::fp::FpGadget, prelude::*, Assignment};
|
||||
use crate::{fields::fp::FpGadget, prelude::*, Assignment, Vec};
|
||||
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug(bound = "P: Fp2Parameters, ConstraintF: PrimeField"))]
|
||||
|
||||
@@ -5,10 +5,10 @@ use algebra::{
|
||||
},
|
||||
PrimeField,
|
||||
};
|
||||
use core::{borrow::Borrow, marker::PhantomData};
|
||||
use r1cs_core::{ConstraintSystem, ConstraintVar, SynthesisError};
|
||||
use std::{borrow::Borrow, marker::PhantomData};
|
||||
|
||||
use crate::{prelude::*, Assignment};
|
||||
use crate::{prelude::*, Assignment, Vec};
|
||||
|
||||
type Fp2Gadget<P, ConstraintF> =
|
||||
super::fp2::Fp2Gadget<<P as Fp6Parameters>::Fp2Params, ConstraintF>;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// use std::ops::{Mul, MulAssign};
|
||||
use algebra::Field;
|
||||
use core::fmt::Debug;
|
||||
use r1cs_core::{ConstraintSystem, SynthesisError};
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
@@ -237,11 +236,11 @@ pub trait FieldGadget<F: Field, ConstraintF: Field>:
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use rand::{self, thread_rng, SeedableRng};
|
||||
use rand::{self, SeedableRng};
|
||||
use rand_xorshift::XorShiftRng;
|
||||
|
||||
use crate::{prelude::*, test_constraint_system::TestConstraintSystem};
|
||||
use algebra::{BitIterator, Field, UniformRand};
|
||||
use crate::{prelude::*, test_constraint_system::TestConstraintSystem, Vec};
|
||||
use algebra::{test_rng, BitIterator, Field, UniformRand};
|
||||
use r1cs_core::ConstraintSystem;
|
||||
|
||||
fn field_test<
|
||||
@@ -418,7 +417,7 @@ mod test {
|
||||
// a * a * a = a^3
|
||||
let mut constants = [FE::zero(); 4];
|
||||
for c in &mut constants {
|
||||
*c = UniformRand::rand(&mut thread_rng());
|
||||
*c = UniformRand::rand(&mut test_rng());
|
||||
println!("Current c[i]: {:?}", c);
|
||||
}
|
||||
let bits = [Boolean::constant(false), Boolean::constant(true)];
|
||||
@@ -426,7 +425,7 @@ mod test {
|
||||
F::two_bit_lookup(cs.ns(|| "Lookup"), &bits, constants.as_ref()).unwrap();
|
||||
assert_eq!(lookup_result.get_value().unwrap(), constants[2]);
|
||||
|
||||
let negone: FE = UniformRand::rand(&mut thread_rng());
|
||||
let negone: FE = UniformRand::rand(&mut test_rng());
|
||||
|
||||
let n = F::alloc(&mut cs.ns(|| "alloc new var"), || Ok(negone)).unwrap();
|
||||
let _ = n.to_bytes(&mut cs.ns(|| "ToBytes")).unwrap();
|
||||
@@ -525,7 +524,7 @@ mod test {
|
||||
|
||||
let mut cs = TestConstraintSystem::<Fq>::new();
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = test_rng();
|
||||
|
||||
let a = FqGadget::alloc(&mut cs.ns(|| "generate_a"), || Ok(Fq::rand(&mut rng))).unwrap();
|
||||
let b = FqGadget::alloc(&mut cs.ns(|| "generate_b"), || Ok(Fq::rand(&mut rng))).unwrap();
|
||||
@@ -543,7 +542,7 @@ mod test {
|
||||
|
||||
let mut cs = TestConstraintSystem::<Fq>::new();
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = test_rng();
|
||||
|
||||
let a = FqGadget::alloc(&mut cs.ns(|| "generate_a"), || Ok(Fq::rand(&mut rng))).unwrap();
|
||||
let b = FqGadget::alloc(&mut cs.ns(|| "generate_b"), || Ok(Fq::rand(&mut rng))).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user