diff --git a/plonky2x/src/frontend/ecc/ed25519/gadgets/eddsa.rs b/plonky2x/src/frontend/ecc/ed25519/gadgets/eddsa.rs index c8a4352e3..d11c15ddf 100644 --- a/plonky2x/src/frontend/ecc/ed25519/gadgets/eddsa.rs +++ b/plonky2x/src/frontend/ecc/ed25519/gadgets/eddsa.rs @@ -3,7 +3,7 @@ use core::fmt::Debug; use curta::chip::ec::edwards::ed25519::Ed25519 as CurtaEd25519; use curta::chip::ec::edwards::scalar_mul::generator::ScalarMulEd25519Gadget; use curta::chip::ec::edwards::EdwardsParameters; -use curta::math::extension::CubicParameters; +use curta::math::extension::cubic::parameters::CubicParameters; use plonky2::field::extension::Extendable; use plonky2::hash::hash_types::RichField; use plonky2::iop::target::{BoolTarget, Target}; diff --git a/plonky2x/src/frontend/hash/sha/sha256.rs b/plonky2x/src/frontend/hash/sha/sha256.rs index 12e46adcf..c0fa1b511 100644 --- a/plonky2x/src/frontend/hash/sha/sha256.rs +++ b/plonky2x/src/frontend/hash/sha/sha256.rs @@ -79,12 +79,12 @@ pub fn sha256_variable_length_single_chunk, const D } // Pad a variable length, single SHA256 chunk from a message -fn pad_single_sha256_chunk, const D: usize>( +pub fn pad_single_sha256_chunk, const D: usize>( builder: &mut CircuitBuilder, message: &[BoolTarget], // Length in bits (assumes less than SINGLE_CHUNK_MAX_MESSAGE_BYTES * 8) length: Target, -) -> Vec { +) -> [BoolTarget; CHUNK_64_BYTES * 8] { assert!(message.len() <= SINGLE_CHUNK_MAX_MESSAGE_BYTES * 8); // 1) Adds all message bits before idx = length // 2) Adds padding bit when idx = length @@ -127,7 +127,11 @@ fn pad_single_sha256_chunk, const D: usize>( msg_input.push(length_bits[i]); } - msg_input + let mut padded_msg = [builder._false(); CHUNK_64_BYTES * 8]; + + padded_msg[..(CHUNK_64_BYTES * 8)].copy_from_slice(&msg_input[..(CHUNK_64_BYTES * 8)]); + + padded_msg } // Process SHA256 on padded chunks @@ -497,18 +501,10 @@ mod tests { let msg_hash = sha256_variable_length_single_chunk(&mut builder, &targets, length); - for i in 0..digest_bits.len() { - if digest_bits[i] { - builder.assert_one(msg_hash[i].target); - } else { - builder.assert_zero(msg_hash[i].target); - } - } - let mut pw = PartialWitness::new(); - for i in 0..msg_bits.len() { - pw.set_bool_target(targets[i], msg_bits[i]); + for i in 0..msg_hash.len() { + pw.set_bool_target(msg_hash[i], digest_bits[i]); } dbg!(builder.num_gates());