Skip to content

Commit

Permalink
Applies scarb/cargo fmt to risc0_sample_app src files
Browse files Browse the repository at this point in the history
  • Loading branch information
raugfer committed Dec 23, 2024
1 parent 7d0e96b commit 4c04f6a
Show file tree
Hide file tree
Showing 3 changed files with 2,293 additions and 16 deletions.
28 changes: 15 additions & 13 deletions src/contracts/risc0_sample_app/fibonacci_prover/host/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// These constants represent the RISC-V ELF and the image ID generated by risc0-build.
// The ELF is used for proving and the ID is used for verification.
use methods::{
FIBONACCI_GUEST_ELF, FIBONACCI_GUEST_ID
};
use risc0_zkvm::{
compute_image_id, default_prover, ExecutorEnv, ProverOpts, VerifierContext
};
use risc0_ethereum_contracts::encode_seal;
use garaga_rs::definitions::CurveID;
use garaga_rs::calldata::full_proof_with_hints::groth16::{
get_groth16_calldata, Groth16Proof
};
use garaga_rs::calldata::full_proof_with_hints::groth16::risc0_utils::get_risc0_vk;
use garaga_rs::calldata::full_proof_with_hints::groth16::{get_groth16_calldata, Groth16Proof};
use garaga_rs::definitions::CurveID;
use methods::{FIBONACCI_GUEST_ELF, FIBONACCI_GUEST_ID};
use risc0_ethereum_contracts::encode_seal;
use risc0_zkvm::{compute_image_id, default_prover, ExecutorEnv, ProverOpts, VerifierContext};

fn main() {
// Initialize tracing. In order to view logs, run `RUST_LOG=info cargo run`
Expand Down Expand Up @@ -55,7 +49,7 @@ fn main() {
env,
&VerifierContext::default(),
FIBONACCI_GUEST_ELF,
&ProverOpts::groth16()
&ProverOpts::groth16(),
)
.unwrap();

Expand All @@ -80,5 +74,13 @@ fn main() {
// prints the calldata as JSON
let proof = Groth16Proof::from_risc0(seal, image_id, journal);
let calldata = get_groth16_calldata(&proof, &get_risc0_vk(), CurveID::BN254).unwrap();
println!("[{}]", calldata.iter().skip(1).map(|v| format!("\"{}\"", v)).collect::<Vec<_>>().join(", "));
println!(
"[{}]",
calldata
.iter()
.skip(1)
.map(|v| format!("\"{}\"", v))
.collect::<Vec<_>>()
.join(", ")
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[starknet::interface]
pub trait IFibonacciSequencer<TContractState> {
fn verify_and_submit_fibonacci_number(ref self: TContractState, full_proof_with_hints: Span<felt252>);
fn verify_and_submit_fibonacci_number(
ref self: TContractState, full_proof_with_hints: Span<felt252>,
);
}

#[starknet::contract]
Expand All @@ -18,7 +20,9 @@ mod FibonacciSequencer {

#[abi(embed_v0)]
impl FibonacciSequencerImpl of super::IFibonacciSequencer<ContractState> {
fn verify_and_submit_fibonacci_number(ref self: ContractState, full_proof_with_hints: Span<felt252>) {
fn verify_and_submit_fibonacci_number(
ref self: ContractState, full_proof_with_hints: Span<felt252>,
) {
// sets the class hash for the RiscZero verifier already declared on-chain
// by the Garaga team
let class_hash: ClassHash = RISC_ZERO_VERIFIER_CLASS_HASH.try_into().unwrap();
Expand Down
2,273 changes: 2,272 additions & 1 deletion src/contracts/risc0_sample_app/fibonacci_sequencer/tests/test_contract.cairo

Large diffs are not rendered by default.

0 comments on commit 4c04f6a

Please sign in to comment.