mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-09 07:21:30 +01:00
Catch up with algebra (#106)
Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
extern crate ark_relations;
|
||||
|
||||
pub mod fields {
|
||||
use ark_ff::{BitIteratorLE, Field, UniformRand};
|
||||
use ark_ff::{BigInteger, BitIteratorLE, Field, PrimeField, UniformRand};
|
||||
use ark_r1cs_std::prelude::*;
|
||||
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
|
||||
use ark_std::{test_rng, vec::Vec};
|
||||
|
||||
pub fn field_test<F, ConstraintF, AF>() -> Result<(), SynthesisError>
|
||||
where
|
||||
F: Field,
|
||||
F: PrimeField,
|
||||
ConstraintF: Field,
|
||||
AF: FieldVar<F, ConstraintF>,
|
||||
AF: TwoBitLookupGadget<ConstraintF, TableConstant = F>,
|
||||
@@ -176,10 +176,10 @@ pub mod fields {
|
||||
assert!(cs.is_satisfied().unwrap());
|
||||
|
||||
let bytes = r.to_non_unique_bytes()?;
|
||||
assert_eq!(ark_ff::to_bytes!(r_native).unwrap(), bytes.value().unwrap());
|
||||
assert_eq!(r_native.into_bigint().to_bytes_le(), bytes.value().unwrap());
|
||||
assert!(cs.is_satisfied().unwrap());
|
||||
let bytes = r.to_bytes()?;
|
||||
assert_eq!(ark_ff::to_bytes!(r_native).unwrap(), bytes.value().unwrap());
|
||||
assert_eq!(r_native.into_bigint().to_bytes_le(), bytes.value().unwrap());
|
||||
assert!(cs.is_satisfied().unwrap());
|
||||
|
||||
let ab_false = &a + (AF::from(Boolean::Constant(false)) * b_native);
|
||||
@@ -231,8 +231,8 @@ pub mod fields {
|
||||
|
||||
pub mod curves {
|
||||
use ark_ec::{
|
||||
short_weierstrass_jacobian::GroupProjective as SWProjective,
|
||||
twisted_edwards_extended::GroupProjective as TEProjective, ProjectiveCurve,
|
||||
short_weierstrass::Projective as SWProjective, twisted_edwards::Projective as TEProjective,
|
||||
ProjectiveCurve,
|
||||
};
|
||||
use ark_ff::{BitIteratorLE, Field, One, PrimeField};
|
||||
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
|
||||
@@ -380,7 +380,7 @@ pub mod curves {
|
||||
|
||||
pub fn sw_test<P, GG>() -> Result<(), SynthesisError>
|
||||
where
|
||||
P: ark_ec::SWModelParameters,
|
||||
P: ark_ec::models::short_weierstrass::SWCurveConfig,
|
||||
GG: CurveVar<SWProjective<P>, <P::BaseField as Field>::BasePrimeField>,
|
||||
for<'a> &'a GG: GroupOpsBounds<'a, SWProjective<P>, GG>,
|
||||
{
|
||||
@@ -391,8 +391,6 @@ pub mod curves {
|
||||
AllocationMode::Constant,
|
||||
];
|
||||
for &mode in &modes {
|
||||
use ark_ec::group::Group;
|
||||
|
||||
let mut rng = test_rng();
|
||||
|
||||
let cs = ConstraintSystem::<<P::BaseField as Field>::BasePrimeField>::new_ref();
|
||||
@@ -428,7 +426,7 @@ pub mod curves {
|
||||
gadget_a_zero.enforce_equal(&gadget_a)?;
|
||||
|
||||
// Check doubling
|
||||
let aa = Group::double(&a);
|
||||
let aa = &a.double();
|
||||
let aa_affine = aa.into_affine();
|
||||
gadget_a.double_in_place()?;
|
||||
let aa_val = gadget_a.value()?.into_affine();
|
||||
@@ -453,7 +451,7 @@ pub mod curves {
|
||||
|
||||
pub fn te_test<P, GG>() -> Result<(), SynthesisError>
|
||||
where
|
||||
P: ark_ec::TEModelParameters,
|
||||
P: ark_ec::twisted_edwards::TECurveConfig,
|
||||
GG: CurveVar<TEProjective<P>, <P::BaseField as Field>::BasePrimeField>,
|
||||
for<'a> &'a GG: GroupOpsBounds<'a, TEProjective<P>, GG>,
|
||||
{
|
||||
@@ -464,8 +462,6 @@ pub mod curves {
|
||||
AllocationMode::Constant,
|
||||
];
|
||||
for &mode in &modes {
|
||||
use ark_ec::group::Group;
|
||||
|
||||
let mut rng = test_rng();
|
||||
|
||||
let cs = ConstraintSystem::<<P::BaseField as Field>::BasePrimeField>::new_ref();
|
||||
@@ -498,7 +494,7 @@ pub mod curves {
|
||||
assert!(cs.is_satisfied().unwrap());
|
||||
|
||||
// Check doubling
|
||||
let aa = Group::double(&a);
|
||||
let aa = &a.double();
|
||||
let aa_affine = aa.into_affine();
|
||||
gadget_a.double_in_place()?;
|
||||
let aa_val = gadget_a.value()?.into_affine();
|
||||
|
||||
Reference in New Issue
Block a user