mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 09:13:09 +00:00
deterministic build function
This commit is contained in:
parent
146e660523
commit
905c5eb5a0
@ -42,7 +42,7 @@ fn main() -> Result<()> {
|
||||
pw.set_target(initial_a, F::ZERO);
|
||||
pw.set_target(initial_b, F::ONE);
|
||||
|
||||
let data = builder.build::<C>();
|
||||
let data = builder.build_deterministic::<C>();
|
||||
|
||||
let common_circuit_data_serialized = serde_json::to_string(&data.common).unwrap();
|
||||
fs::write("common_circuit_data.json", common_circuit_data_serialized).expect("Unable to write file");
|
||||
|
||||
@ -737,8 +737,10 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Standard build.
|
||||
|
||||
/// Builds a "full circuit", with both prover and verifier data.
|
||||
pub fn build<C: GenericConfig<D, F = F>>(mut self) -> CircuitData<F, C, D>
|
||||
fn build_inner<C: GenericConfig<D, F = F>>(mut self, deterministic: bool) -> CircuitData<F, C, D>
|
||||
where
|
||||
[(); C::HCO::WIDTH]:,
|
||||
[(); C::HCI::WIDTH]:,
|
||||
@ -762,7 +764,9 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
{
|
||||
self.connect(hash_part, Target::wire(pi_gate, wire))
|
||||
}
|
||||
// self.randomize_unused_pi_wires(pi_gate);
|
||||
if !deterministic {
|
||||
self.randomize_unused_pi_wires(pi_gate);
|
||||
}
|
||||
|
||||
// Make sure we have enough constant generators. If not, add a `ConstantGate`.
|
||||
while self.constants_to_targets.len() > self.constant_generators.len() {
|
||||
@ -945,6 +949,24 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Standard build.
|
||||
pub fn build<C: GenericConfig<D, F = F>>(self) -> CircuitData<F, C, D>
|
||||
where
|
||||
[(); C::HCO::WIDTH]:,
|
||||
[(); C::HCI::WIDTH]:,
|
||||
{
|
||||
self.build_inner(false)
|
||||
}
|
||||
|
||||
/// Build without randomizing PI wires
|
||||
pub fn build_deterministic<C: GenericConfig<D, F = F>>(self) -> CircuitData<F, C, D>
|
||||
where
|
||||
[(); C::HCO::WIDTH]:,
|
||||
[(); C::HCI::WIDTH]:,
|
||||
{
|
||||
self.build_inner(true)
|
||||
}
|
||||
|
||||
/// Builds a "prover circuit", with data needed to generate proofs but not verify them.
|
||||
pub fn build_prover<C: GenericConfig<D, F = F>>(self) -> ProverCircuitData<F, C, D>
|
||||
where
|
||||
|
||||
@ -94,7 +94,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
}
|
||||
|
||||
/// Computes all Fiat-Shamir challenges used in the Plonk proof.
|
||||
pub fn get_challenges(
|
||||
pub(crate) fn get_challenges(
|
||||
&self,
|
||||
public_inputs_hash: <<C as GenericConfig<D>>::InnerHasher as Hasher<F, C::HCI>>::Hash,
|
||||
circuit_digest: &<<C as GenericConfig<D>>::Hasher as Hasher<C::F, C::HCO>>::Hash,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user