mirror of
https://github.com/arnaucube/plonky2-u32.git
synced 2026-02-10 05:06:42 +01:00
Remove dead code
This commit is contained in:
@@ -1,23 +1,13 @@
|
|||||||
use alloc::string::{String, ToString};
|
|
||||||
use alloc::vec;
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use anyhow::Result;
|
|
||||||
use core::marker::PhantomData;
|
|
||||||
use plonky2::plonk::circuit_data::CommonCircuitData;
|
|
||||||
use plonky2::util::serialization::{Buffer, IoResult, Read, Write};
|
|
||||||
|
|
||||||
use plonky2::field::extension::Extendable;
|
use plonky2::field::extension::Extendable;
|
||||||
use plonky2::hash::hash_types::RichField;
|
use plonky2::hash::hash_types::RichField;
|
||||||
use plonky2::iop::generator::{GeneratedValues, SimpleGenerator};
|
|
||||||
use plonky2::iop::target::Target;
|
use plonky2::iop::target::Target;
|
||||||
use plonky2::iop::witness::{PartitionWitness, Witness};
|
|
||||||
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
use plonky2::plonk::circuit_builder::CircuitBuilder;
|
||||||
|
|
||||||
use crate::gates::add_many_u32::U32AddManyGate;
|
use crate::gates::add_many_u32::U32AddManyGate;
|
||||||
use crate::gates::arithmetic_u32::U32ArithmeticGate;
|
use crate::gates::arithmetic_u32::U32ArithmeticGate;
|
||||||
use crate::gates::subtraction_u32::U32SubtractionGate;
|
use crate::gates::subtraction_u32::U32SubtractionGate;
|
||||||
use crate::serialization::{ReadU32, WriteU32};
|
|
||||||
use crate::witness::GeneratedValuesU32;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct U32Target(pub Target);
|
pub struct U32Target(pub Target);
|
||||||
@@ -235,58 +225,6 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilderU32<F, D>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
struct SplitToU32Generator<F: RichField + Extendable<D>, const D: usize> {
|
|
||||||
x: Target,
|
|
||||||
low: U32Target,
|
|
||||||
high: U32Target,
|
|
||||||
_phantom: PhantomData<F>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F, D>
|
|
||||||
for SplitToU32Generator<F, D>
|
|
||||||
{
|
|
||||||
fn id(&self) -> String {
|
|
||||||
"SplitToU32Generator".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn serialize(&self, dst: &mut Vec<u8>, _common_data: &CommonCircuitData<F, D>) -> IoResult<()> {
|
|
||||||
dst.write_target(self.x)?;
|
|
||||||
dst.write_target_u32(self.low)?;
|
|
||||||
dst.write_target_u32(self.high)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn deserialize(src: &mut Buffer, _common_data: &CommonCircuitData<F, D>) -> IoResult<Self> {
|
|
||||||
let x = src.read_target()?;
|
|
||||||
let low = src.read_target_u32()?;
|
|
||||||
let high = src.read_target_u32()?;
|
|
||||||
Ok(Self {
|
|
||||||
x,
|
|
||||||
low,
|
|
||||||
high,
|
|
||||||
_phantom: PhantomData,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dependencies(&self) -> Vec<Target> {
|
|
||||||
vec![self.x]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_once(
|
|
||||||
&self,
|
|
||||||
witness: &PartitionWitness<F>,
|
|
||||||
out_buffer: &mut GeneratedValues<F>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let x = witness.get_target(self.x);
|
|
||||||
let x_u64 = x.to_canonical_u64();
|
|
||||||
let low = x_u64 as u32;
|
|
||||||
let high = (x_u64 >> 32) as u32;
|
|
||||||
|
|
||||||
out_buffer.set_u32_target(self.low, low)?;
|
|
||||||
out_buffer.set_u32_target(self.high, high)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|||||||
Reference in New Issue
Block a user