garaga
garaga copied to clipboard
dev: RiscZero contract should take journal instead of journal Digest as input
Change the struct in src/src/utils/calldata.cairo
from
#[derive(Serde, Drop)]
struct FullProofWithHintsRisc0 {
groth16_proof: Groth16ProofRaw,
image_id: Span<u32>,
journal_digest: Span<u32>,
mpcheck_hint: MPCheckHintBN254,
small_Q: E12DMulQuotient<u288>,
msm_hint: Array<felt252>,
}
to
#[derive(Serde, Drop)]
struct FullProofWithHintsRisc0 {
groth16_proof: Groth16ProofRaw,
image_id: Span<u32>,
journal: Span<u8>,
mpcheck_hint: MPCheckHintBN254,
small_Q: E12DMulQuotient<u288>,
msm_hint: Array<felt252>,
}
- update
parsing_utils.py
,
In particular : https://github.com/keep-starknet-strange/garaga/blob/fa27403e6aa2c968a369c6da6ddfbd8da36a42f3/hydra/garaga/starknet/groth16_contract_generator/parsing_utils.py#L446-L448
This should serialize the journal instead of the journal digest.
- update
risc0_generator.py
This should generate a contract compatible with the new struct above.
In particular :
https://github.com/keep-starknet-strange/garaga/blob/fa27403e6aa2c968a369c6da6ddfbd8da36a42f3/hydra/garaga/starknet/groth16_contract_generator/generator_risc0.py#L96
At this point the journal digest should be computed from journal using the sha256 syscall.
See https://github.com/starkware-libs/cairo/blob/main/corelib/src/sha256.cairo or https://github.com/keep-starknet-strange/garaga/blob/main/src/src/utils/risc0.cairo for examples of using the syscall.
- regenerate the example using
make rewrite
(advice: work inside the real contract first then update the python template instead of the opposite)
- update
deserialize_full_proof_with_hints_risc0
function in (calldata.cairo)
In particular :
https://github.com/keep-starknet-strange/garaga/blob/fa27403e6aa2c968a369c6da6ddfbd8da36a42f3/src/src/utils/calldata.cairo#L120-L125
This should be updated with the changes in the python code above.
Slightly related : #207