garaga
garaga copied to clipboard
dev: Make groth16 generated contracts (a bit) more user friendly.
Current behavior :
Generated groth16 contracts looks like this :
https://github.com/keep-starknet-strange/garaga/blob/6135bd6dec063851a8249e1dafc8a7e4c98abf9d/src/contracts/groth16_example_bls12_381/src/groth16_verifier.cairo#L81-L99
They call an internal function if the proof is verified with the public inputs parsed from the proof as parameter.
Minimal Changes requested :
- Delete the internal function.
- Change the signature of the verification function to -> Option<Span
> : - If check==True, return Option::Some(groth16_proof.public_inputs), else return Option::None.
- Update and provide clear comments on the template.
Rationale :
Users usually expect/are used to have a single verifier contract and interact with it, from another smart contract to forward proof to it. Having the Option::Some(pub_inputs) or Option::None() pattern gives at the same time a True(Some)/False(None) and deserialize correctly the public inputs for the caller. Users have more freedom on how to process the inputs.
How :
- clone repo,
make setup
,source venv/bin/activate
- Update https://github.com/keep-starknet-strange/garaga/blob/main/hydra/garaga/starknet/groth16_contract_generator/generator_risc0.py and https://github.com/keep-starknet-strange/garaga/blob/main/hydra/garaga/starknet/groth16_contract_generator/generator.py
- Regenerate examples using
make rewrite