Skip to content

Conversation

@Gigatron
Copy link
Contributor

@Gigatron Gigatron commented Nov 2, 2023

This PR demonstrates how we can turn an existing halo2 circuit project into a deployable supported by Snarkify Cloud. The major changes are:

  1. Add snarkify-sdk as dependency
  2. Implement the ProofHandler trait along with the prove method to handle input params and produce a proof output

@snarkify snarkify deleted a comment from Gigatron Nov 2, 2023
@drouyang drouyang changed the title Use snarkify-sdk to build prover Add Snarkify Cloud support by integrating snarkify-sdk Nov 2, 2023
@drouyang drouyang changed the title Add Snarkify Cloud support by integrating snarkify-sdk Add Snarkify Cloud support via snarkify-sdk Nov 2, 2023
let params: ParamsIPA<vesta::Affine> = ParamsIPA::<EqAffine>::new(K);
// private input
let mut inputs = Vec::new();
for i in 0..5 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For demo purpose, we can support input message of type Vec. In this case, we can first use the poseidon_hash function in the library to calculate the out_hash as the public input. The issue is from user's perpective, he/she doesn't know the output hash without precalculate it.

But at least with a larger size of input and increase K accordingly might be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to confirm, shall we remove the public_input (the hash) and calculate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we produce (hash_value, proof) in that case? @chaosma

Copy link
Contributor

Choose a reason for hiding this comment

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

Per our discussion

  • create rust binary that takes integer inputs and outputs a Poseidon hash
  • server computes the hash_value and proof for the user

Copy link
Contributor

@cyphersnake cyphersnake left a comment

Choose a reason for hiding this comment

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

Need a little more top-level context. I understand the repository, but want to understand exactly how it is planned to be used for the demo. I.e. will this code be part of a public presentation of a cloud platform for example

Comment on lines +20 to +25
#[path = "../main_gate.rs"]
mod main_gate;
#[path = "../poseidon_circuit.rs"]
mod poseidon_circuit;
#[path = "../test_circuit.rs"]
mod test_circuit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Each folder and file is a module. Usually you do not specify paths to specific files, but make a structure, i.e. these modules should be imported from super.

Can you tell me what purpose you are pursuing with such a project structure? When we have both main.rs and bin/snarkify.rs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like we need ‘super’ here.

my understanding is that the code has an existing main.rs, to integrate with snarkify-sdk, we created a new bin/snarkify.rs. Developers can use main.rs to run their code locally, while bin/snarkify.rs is for cloud integration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need some hints on how I can use super here, chatgpt doesn't seem to be able to provide an answer

Comment on lines 3 to 10
use halo2_proofs::plonk::{create_proof, keygen_pk, keygen_vk, verify_proof};
use halo2_proofs::poly::commitment::ParamsProver;
use halo2_proofs::poly::ipa::commitment::{IPACommitmentScheme, ParamsIPA};
use halo2_proofs::poly::ipa::multiopen::ProverIPA;
use halo2_proofs::poly::{ipa::strategy::SingleStrategy, VerificationStrategy};
use halo2_proofs::transcript::{
Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

NBD:

use halo2_proofs::{
    plonk::{create_proof, keygen_pk, keygen_vk, verify_proof},
    poly::{
        commitment::ParamsProver,
        ipa::{
            commitment::{IPACommitmentScheme, ParamsIPA},
            multiopen::ProverIPA,
            strategy::SingleStrategy,
        },
        VerificationStrategy,
    },
    transcript::{
        Blake2bRead, Blake2bWrite, Challenge255, TranscriptReadBuffer, TranscriptWriterBuffer,
    },
};

@drouyang
Copy link
Contributor

drouyang commented Nov 4, 2023

will this code be part of a public presentation of a cloud platform for example

Please follow this tutorial and try it out https://docs.snarkify.io/introduction/quickstart/deploy-your-first-prover

@cyphersnake
Copy link
Contributor

Please follow this tutorial and try it out

I still tried it yesterday (all that's left is to generate a proof), the question is exactly about what the final presentation of the cloud platform will look like

I'm asking to understand to what extent to pick on the code

@drouyang
Copy link
Contributor

drouyang commented Nov 4, 2023

Easier to explain over huddle

@cyphersnake
Copy link
Contributor

Please check #5

@Gigatron
Copy link
Contributor Author

Gigatron commented Nov 7, 2023

close as duplicate of #5

@Gigatron Gigatron closed this Nov 7, 2023
@Gigatron Gigatron deleted the snarkify_cloud branch November 7, 2023 22:40
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