Skip to content

Commit

Permalink
feat(circuit_framework): Implement Uint32Target and rename other Uint…
Browse files Browse the repository at this point in the history
… targets
  • Loading branch information
Xearty committed Jun 6, 2024
1 parent 14c685a commit 104bcd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ macro_rules! make_uint32_n {
}

impl PublicInputsReadable for $a {
#[allow(arithmetic_overflow)]
fn from_elements<F: RichField>(elements: &[F]) -> Self::Primitive {
assert_eq!(elements.len(), Self::get_size());
elements
.iter()
.rev()
.fold(Self::Primitive::from(0u64), |acc, limb| {
(acc << 32) + Self::Primitive::from(limb.to_canonical_u64())
.fold(Self::Primitive::from(0u32), |acc, limb| {
(acc << 32) + Self::Primitive::from(limb.to_canonical_u64() as u32)
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ use primitive_types::{U256, U512};
mod r#macro;
pub mod ops;

make_uint32_n!(U64Target, u64, 2);
make_uint32_n!(U128Target, u128, 4);
make_uint32_n!(U256Target, U256, 8);
make_uint32_n!(U512Target, U512, 16);
make_uint32_n!(Uint32Target, u32, 1);
make_uint32_n!(Uint64Target, u64, 2);
make_uint32_n!(Uint128Target, u128, 4);
make_uint32_n!(Uint256Target, U256, 8);
make_uint32_n!(Uint512Target, U512, 16);

fn assert_limbs_are_valid<F: RichField + Extendable<D>, const D: usize>(
builder: &mut CircuitBuilder<F, D>,
Expand Down

0 comments on commit 104bcd5

Please sign in to comment.