mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 22:33:06 +00:00
PR feedback
This commit is contained in:
parent
3a68a458c4
commit
954eaf16f2
@ -3,8 +3,8 @@ use plonky2_field::extension_field::Extendable;
|
||||
|
||||
use crate::curve::curve_types::{Curve, CurveScalar};
|
||||
use crate::field::field_types::Field;
|
||||
use crate::gadgets::biguint::BigUintTarget;
|
||||
use crate::gadgets::curve::AffinePointTarget;
|
||||
use crate::gadgets::nonnative::NonNativeTarget;
|
||||
use crate::hash::hash_types::RichField;
|
||||
use crate::hash::keccak::KeccakHash;
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
@ -19,11 +19,11 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
&mut self,
|
||||
p: &AffinePointTarget<C>,
|
||||
q: &AffinePointTarget<C>,
|
||||
n: &BigUintTarget,
|
||||
m: &BigUintTarget,
|
||||
n: &NonNativeTarget<C::ScalarField>,
|
||||
m: &NonNativeTarget<C::ScalarField>,
|
||||
) -> AffinePointTarget<C> {
|
||||
let limbs_n = self.split_biguint_to_2_bit_limbs(n);
|
||||
let limbs_m = self.split_biguint_to_2_bit_limbs(m);
|
||||
let limbs_n = self.split_nonnative_to_2_bit_limbs(n);
|
||||
let limbs_m = self.split_nonnative_to_2_bit_limbs(m);
|
||||
assert_eq!(limbs_n.len(), limbs_m.len());
|
||||
let num_limbs = limbs_n.len();
|
||||
|
||||
@ -119,7 +119,7 @@ mod tests {
|
||||
let n_target = builder.constant_nonnative(n);
|
||||
let m_target = builder.constant_nonnative(m);
|
||||
|
||||
let res_target = builder.curve_msm(&p_target, &q_target, &n_target.value, &m_target.value);
|
||||
let res_target = builder.curve_msm(&p_target, &q_target, &n_target, &m_target);
|
||||
builder.curve_assert_valid(&res_target);
|
||||
|
||||
builder.connect_affine_point(&res_target, &res_expected);
|
||||
|
||||
@ -65,25 +65,13 @@ mod tests {
|
||||
use crate::plonk::config::{GenericConfig, PoseidonGoldilocksConfig};
|
||||
use crate::plonk::verifier::verify;
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_ecdsa_circuit() -> Result<()> {
|
||||
fn test_ecdsa_circuit_with_config(config: CircuitConfig) -> Result<()> {
|
||||
const D: usize = 2;
|
||||
type C = PoseidonGoldilocksConfig;
|
||||
type F = <C as GenericConfig<D>>::F;
|
||||
|
||||
type Curve = Secp256K1;
|
||||
|
||||
const WIDE: bool = true;
|
||||
|
||||
let config = if WIDE {
|
||||
// < 2^16 gates.
|
||||
CircuitConfig::wide_ecc_config()
|
||||
} else {
|
||||
// < 2^17 gates.
|
||||
CircuitConfig::standard_ecc_config()
|
||||
};
|
||||
|
||||
let pw = PartialWitness::new();
|
||||
let mut builder = CircuitBuilder::<F, D>::new(config);
|
||||
|
||||
@ -112,4 +100,16 @@ mod tests {
|
||||
let proof = data.prove(pw).unwrap();
|
||||
verify(proof, &data.verifier_only, &data.common)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_ecdsa_circuit_narrow() -> Result<()> {
|
||||
test_ecdsa_circuit_with_config(CircuitConfig::standard_ecc_config())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_ecdsa_circuit_wide() -> Result<()> {
|
||||
test_ecdsa_circuit_with_config(CircuitConfig::wide_ecc_config())
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
|
||||
let p_neg = self.curve_conditional_neg(p, k1_neg);
|
||||
let sp_neg = self.curve_conditional_neg(&sp, k2_neg);
|
||||
self.curve_msm(&p_neg, &sp_neg, &k1.value, &k2.value)
|
||||
self.curve_msm(&p_neg, &sp_neg, &k1, &k2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,8 +35,12 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn split_biguint_to_2_bit_limbs(&mut self, val: &BigUintTarget) -> Vec<Target> {
|
||||
val.limbs
|
||||
pub fn split_nonnative_to_2_bit_limbs<FF: Field>(
|
||||
&mut self,
|
||||
val: &NonNativeTarget<FF>,
|
||||
) -> Vec<Target> {
|
||||
val.value
|
||||
.limbs
|
||||
.iter()
|
||||
.flat_map(|&l| self.split_le_base::<4>(l.0, 16))
|
||||
.collect()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user