Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Use real trusted setup instead of a random generator #272

Conversation

alxkzmn
Copy link
Collaborator

@alxkzmn alxkzmn commented Jul 11, 2024

No description provided.

Comment on lines 675 to 676
#[allow(private_bounds)]
pub trait PlonkishHalo2<W, WG: Halo2WitnessGenerator<Fr, W>>: Halo2Compilable<W, WG> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@leolara I need some advice here on how to better deal with the common functionality while creating the provers. The only difference between supercircuit and single circuit is in the compilation, so I offloaded it into a Halo2Compilable trait. I want it to stay private because it's only used in our halo2 backend. At the same time, it should be shared between both implementations of PlonkishHalo2. When I make it a super trait of PlonkishHalo2 here the clippy gives warning that Halo2Compilable is more private than PlonkishHalo2 which is my intention because I don't want to expose the compilation to a Chiquito API consumer. Do you think there's a better way to do that while not repeating the code?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this compile, that PlonkishHalo2 is public descendant from a private trait? Interesting

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a good solution

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps, it would be even more interesting a blanket trait impl

impl<T: Halo2Compilable> PlonkishHalo2 for T {
    fn create_halo2_prover ....
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

That way PlonkishHalo2 wouldn't have to inherit from the private Halo2Compilable

@alxkzmn alxkzmn marked this pull request as ready for review July 11, 2024 10:28
@alxkzmn alxkzmn requested review from leolara and rutefig July 11, 2024 10:28
@leolara
Copy link
Collaborator

leolara commented Jul 11, 2024

I think there might be more things to configure in the prover than that path. We should create a Config struct, that could pass the path or the Rng.


trait Halo2Compilable<W, WG: Halo2WitnessGenerator<Fr, W>> {
/// Implementation-specific circuit compilation
fn compile_circuit(&mut self) -> (WG, CompiledCircuit<Fr>, u32);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alxkzmn I would call this method halo2_compile.

@alxkzmn
Copy link
Collaborator Author

alxkzmn commented Jul 11, 2024

Do you mean

pub trait PlonkishHalo2<W, WG: Halo2WitnessGenerator<Fr, W>>: Halo2Compilable<W, WG> {
    fn create_halo2_prover(&mut self, params: ProverParams) -> Halo2Prover<Fr, W, WG>;
}

struct ProverParams {
  Option<path>;
  Optin<rng>;
}

and let the caller create the ProverParams? Currently I like that the caller shouldn't worry about the way params are created. If the caller should pass the params, they'll have to take care about what rng to use, and we probably need to disallow them to create params with both rng and path at the same time.

@leolara
Copy link
Collaborator

leolara commented Jul 15, 2024

@alxkzmn You are right, create_halo2_prover is specific for halo2, so it makes sense to get their native params.

}

impl<TG: TraceGenerator<Fr> + Default> PlonkishHalo2<Fr, Assignments<Fr>, ChiquitoHalo2<Fr>>
impl<W, WG: Halo2WitnessGenerator<Fr, W>, T: Halo2Compilable<W, WG>> Halo2Provable<W, WG> for T {}
Copy link
Collaborator

@leolara leolara Jul 15, 2024

Choose a reason for hiding this comment

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

@alxkzmn I think there has been a misunderstanding again.

I am saying to do:

impl<T: Halo2Compilable>  Halo2Provable for T {
    fn create_halo2_prover( ....
}

that way you don't need #[allow(private_bounds)]

Copy link
Collaborator

Choose a reason for hiding this comment

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

With the trait Halo2Provable without default implementation for create_halo2_prover

@alxkzmn alxkzmn requested a review from leolara July 17, 2024 10:46
@alxkzmn alxkzmn merged commit 847259d into chiquito-2024 Jul 17, 2024
4 checks passed
@alxkzmn alxkzmn deleted the 270-we-shouldnt-use-dummyrng-in-examples-and-python-frontend branch August 7, 2024 11:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants