Skip to content

Commit

Permalink
proving key done
Browse files Browse the repository at this point in the history
  • Loading branch information
rw0x0 committed Sep 26, 2024
1 parent bf32e73 commit 5f1b2ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
25 changes: 15 additions & 10 deletions co-noir/co-ultrahonk/src/parse/proving_key.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::CoUltraCircuitBuilder;
use crate::parse::types::TraceData;
use crate::types::Polynomials;
use crate::types::ProverWitnessEntities;
use crate::types::ProvingKey;
use ark_ec::pairing::Pairing;
use ark_ff::One;
Expand All @@ -9,11 +10,15 @@ use mpc_core::traits::PrimeFieldMpcProtocol;
use std::marker::PhantomData;
use ultrahonk::prelude::ProverCrs;
use ultrahonk::prelude::ProvingKey as PlainProvingKey;
use ultrahonk::prelude::UltraCircuitVariable;

impl<T, P: Pairing> ProvingKey<T, P>
where
T: PrimeFieldMpcProtocol<P::ScalarField>,
{
const PUBLIC_INPUT_WIRE_INDEX: usize =
ProverWitnessEntities::<T::FieldShare, P::ScalarField>::W_R;

// We ignore the TraceStructure for now (it is None in barretenberg for UltraHonk)
pub fn create(driver: &T, mut circuit: CoUltraCircuitBuilder<T, P>, crs: ProverCrs<P>) -> Self {
tracing::info!("ProvingKey create");
Expand Down Expand Up @@ -50,17 +55,17 @@ where
dyadic_circuit_size,
);

todo!("ProvingKey pubinput");
// Construct the public inputs array
// let public_wires_src = proving_key.polynomials.witness.w_r();

// for input in public_wires_src
// .iter()
// .skip(proving_key.pub_inputs_offset as usize)
// .take(proving_key.num_public_inputs as usize)
// {
// proving_key.public_inputs.push(*input);
// }
let block = circuit.blocks.get_pub_inputs();
assert!(block.is_pub_inputs);
for var_idx in block.wires[Self::PUBLIC_INPUT_WIRE_INDEX]
.iter()
.take(proving_key.num_public_inputs as usize)
.cloned()
{
let var = circuit.get_variable(var_idx as usize);
proving_key.public_inputs.push(var.public_into_field());
}

// TODO the following elements are not part of the proving key so far
// Set the recursive proof indices
Expand Down
2 changes: 1 addition & 1 deletion co-noir/co-ultrahonk/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(crate) struct ProverWitnessEntities<Shared, Public> {

impl<Shared, Public> ProverWitnessEntities<Shared, Public> {
const W_L: usize = 0; // column 0
const W_R: usize = 1; // column 1
pub(crate) const W_R: usize = 1; // column 1
const W_O: usize = 2; // column 2
const W_4: usize = 3; // column 3 (modified by prover)

Expand Down
4 changes: 4 additions & 0 deletions co-noir/ultrahonk/src/parse/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ impl<T: Default> UltraTraceBlocks<T> {
&self.poseidon_internal,
]
}

pub fn get_pub_inputs(&self) -> &T {
&self.pub_inputs
}
}

pub const NUM_WIRES: usize = 4;
Expand Down

0 comments on commit 5f1b2ec

Please sign in to comment.