Integration

Proving Schemes Supported

The quantum supports the following proving schemes:

  • GnarkGroth16

  • SnarkjsGroth16 (Circom)

  • Risc0

  • Sp1

  • Plonky2

  • GnarkPlonk

  • Halo2Kzg (Poseidon)

  • Halo2KzgEvm

  • AwsNitroAttestation

Check out quantum-demo which demonstrates the full proof generation cycle for all schemes.

Below is a step-by-step flow.

Install quantum-sdk package in your project

quantum-sdk lets you seamlessly interact with the quantum server for your circuit registration and proof submission.

Retrieve Authorization Key

Retrieve an authorization key for accessing quantum testnet as follows:

Initialise Connection

Before interacting with the server, a connection to the quantum layer needs to be established.

Check if the quantum instance can talk with the server. If rpcLive is True, a connection is established.

Circuit Registration

Before submitting a proof, the user must register their circuit on the aggregation layer using some circuit data, primarily the verification key.

We've already established a connection in the quantum instance above. Let's see how to proceed from there.

circuitHash is a unique, 32 bytes value for your circuit on the quantum layer. This will be used to submit proofs and on-chain to check for proof-inclusion purposes. Each scheme may require a different set of circuit data. See generate-circuit-data to learn how to prepare the circuit data needed for different proving schemes.

Proof Submission

Once the circuit is registered, the proof can be sent for aggregation on the quantum layer.

circuitHash , which we received after circuit registration will be used to submit proof for cheap verification on Ethereum. Primarily, the user sends its proof and publicInputs corresponding to the registered circuit.

A proofHash is returned from the quantum layer if a proof is submitted successfully.

A proof cannot be submitted if another proof associated with the same circuitHash is currently being aggregated.

Check Proof Status

proofHash is used to track the progress or get details of the aggregation request.

proofHash is also used to query some Merkle proof data for on-chain purposes

Currently, the aggregated proof is submitted on Sepolia once every ~15 minutes, so for the STATUS to get toVERIFIEDcan take some time.

Each scheme may require a different set of circuit data. See generate-circuit-data to learn how to prepare the circuit data needed for different proving schemes.

Verifying Protocol Proof On-Chain

On-chain Contract

For protocols to integrate quantum, they would have to make some changes to their verification smart contract. The protocol smart contract imports CircuitVerifier from quantum-contracts which is used to verify if the pubInputs were verified as part of the aggregated proof.

The function verifyPubInputs of the CircuitVerifier lib contract is used for public input verification.

Verification requires some Merkle-proof data, which can be fetched using the proofHash as follows:

Here is an example contract initialized with the circuitHash. This example can be found in example contracts

For Risc0, refer to the example here

Note, merkleProof calldata must be the first parameter as assumed by CircuitVerifier

Last updated