Skip to content

Commit

Permalink
feat: recursion experiments (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas authored Apr 19, 2024
1 parent dae8d44 commit 7d4ea2e
Show file tree
Hide file tree
Showing 31 changed files with 644 additions and 345 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions eval/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

use clap::{command, Parser};
use csv::WriterBuilder;
Expand Down
Binary file modified examples/fibonacci-io/program/elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
16 changes: 7 additions & 9 deletions examples/fibonacci-io/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ pub fn main() {
sp1_zkvm::io::commit(&n);

// Compute the n'th fibonacci number, using normal Rust code.
let mut a: u32 = 0;
let mut b: u32 = 1;
let mut sum;
for _ in 1..n {
sum = a + b;
a = b;
b = sum;
let mut nums = vec![1, 1];
for _ in 0..n {
let mut c = nums[nums.len() - 1] + nums[nums.len() - 2];
c %= 7919;
nums.push(c);
}

// Write the output of the program.
//
// Behind the scenes, this also compiles down to a custom system call which handles writing
// outputs to the prover.
sp1_zkvm::io::commit(&a);
sp1_zkvm::io::commit(&b);
sp1_zkvm::io::commit(&nums[nums.len() - 2]);
sp1_zkvm::io::commit(&nums[nums.len() - 1]);
}
Loading

0 comments on commit 7d4ea2e

Please sign in to comment.