Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion: Replace instances slice type for proving/verifying for Vec #265

Open
ed255 opened this issue Feb 2, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@ed255
Copy link
Member

ed255 commented Feb 2, 2024

Currently the API for proving/verifying receives the instances as:

instances: &[&[&[Scheme::Scalar]]],

I think that the only way to have this type is to create a vector of slices, take it as slice, and create another vector of that, and take it as slice. So we end up creating 2 vectors just to get this type. Why not pass a slice of vectors instead? It would simplify the interaction with the proving/verifying API.

Here's an example of the gymnastics that need to be done to create 1 proof:

    let instances = circuit.instances(); // This is `Vec<Vec<F>>`
    let instances_slice: &[&[Fr]] = &(instances
        .iter()
        .map(|instance| instance.as_slice())
        .collect::<Vec<_>>()); // We already had a vector, but we need to create another one to hold slices instead of Vec :(

    create_proof::<KZGCommitmentScheme<Bn256>, ProverSHPLONK<'_, Bn256>, _, _, _, _>(
        &params,
        &pk,
        &[circuit],
        &[instances_slice],
        &mut rng,
        &mut transcript,
    )
    .expect("proof generation should not fail");

I would propose to use change the API to use:

    instances: &[Vec<Vec<Scheme::Scalar>>],

NOTE: If we apply this change on the legacy API, we will have a breaking change, so I suggest keeping the legacy API as it is. But we can do this change on the frontend-backend split API!

@ed255 ed255 added the enhancement New feature or request label Feb 2, 2024
@ed255 ed255 mentioned this issue Feb 2, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant