Skip to content

Conversation

@4l0n50
Copy link

@4l0n50 4l0n50 commented Aug 25, 2025

Add also a rudimentary prover

@sai-deng
Copy link

Should we rename ‘gates’ to ‘chips’ to match the STARK vocabulary?

Comment on lines 14 to 18
pub fn prove<SC>(
config: &SC,
asic: Asic<Val<SC>>,
all_events: AllEvents<Val<SC>>,
) -> RecursiveProof<SC>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything ends up tightly coupled, I am wondering if we couldn't have something a bit less monolithic and also more flexible, which would make it easier on the long run to iterate and expand without these tight bindings?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this perhaps:

pub trait ProofSystem<F: Field> {
    type Config;
    type Asic;
    type Proof;
    type Error;
    
    fn prove(&self, config: &Self::Config, asic: &Self::Asic) -> Result<Self::Proof, Self::Error>;
    fn verify(&self, config: &Self::Config, proof: &Self::Proof) -> Result<(), Self::Error>;
}

Comment on lines +9 to +15
pub struct CircuitBuilder<F: Field> {
wires: Vec<Option<F>>,
gate_instances: Vec<Box<dyn Gate<F>>>,
}

impl<F: Field> CircuitBuilder<F> {
pub fn new() -> Self {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all come from plonky2 I guess, we could probably improve allocation down the line, maybe just add a TODO for now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk, maybe @hratoanina can tell?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's based on Plonky2, yes, but majorly simplified, especially for the wires. For gate_instances it would be better to keep everything on the stack indeed, but I reused the (working) P2 logic. Do you believe it could be a significant overhead down the line?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the gates would probably be too large to be on the stack efficiently, but there are still allocations that could be removed here and there

it's low prio though

Comment on lines +75 to +79
pub enum CircuitError {
InvalidWireId,
InputNotSet,
WireSetTwice,
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think these could be made more extensive to help debugging?
Something like

Suggested change
pub enum CircuitError {
InvalidWireId,
InputNotSet,
WireSetTwice,
}
pub enum CircuitError {
InvalidWireId {
id: WireId,
air: Air,
},
InputNotSet {
id: WireId,
air: Air,
},
WireSetTwice {
id: WireId,
existing_value: Val,
new_value: Val,
},
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you can use thiserror crate to derive error messages like #[error("Invalid wire ID {id} for air {Air}")]

Comment on lines +481 to +482
// #[cfg(test)]
// fn do_test_m31_circle(log_blowup: usize, log_n: usize) -> Result<(), impl Debug> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants