generated from succinctlabs/sp1-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11e7b72
commit 6ea59a2
Showing
11 changed files
with
119 additions
and
199 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[package] | ||
version = "0.1.0" | ||
name = "fibonacci-program" | ||
name = "sxg-program" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
alloy-sol-types = { workspace = true } | ||
sp1-zkvm = "2.0.0" | ||
fibonacci-lib = { path = "../lib" } | ||
lib = { path = "../lib" } | ||
hex = "0.4.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,13 @@ | ||
//! A simple program that takes a number `n` as input, and writes the `n-1`th and `n`th fibonacci | ||
//! number as an output. | ||
|
||
// These two lines are necessary for the program to properly compile. | ||
// | ||
// Under the hood, we wrap your main function with some extra code so that it behaves properly | ||
// inside the zkVM. | ||
#![no_main] | ||
sp1_zkvm::entrypoint!(main); | ||
|
||
use alloy_sol_types::SolType; | ||
use fibonacci_lib::constants::{DATA_TO_VERIFY, FINAL_PAYLOAD, PAYLOAD}; | ||
|
||
use fibonacci_lib::sxg::{sxg_verify, SXGInput}; | ||
use fibonacci_lib::{fibonacci, sha256_hash, verify_ecdsa_p256_signature, PublicValuesStruct}; | ||
use hex; | ||
use lib::sxg::SXGInput; | ||
use lib::PublicValuesStruct; | ||
pub fn main() { | ||
// Read an input to the program. | ||
// | ||
// Behind the scenes, this compiles down to a custom system call which handles reading inputs | ||
// from the prover. | ||
|
||
let n = sp1_zkvm::io::read::<u32>(); | ||
|
||
let (a, b) = fibonacci(n); | ||
|
||
let final_payload = FINAL_PAYLOAD; | ||
let data_to_verify = DATA_TO_VERIFY; | ||
let payload = PAYLOAD; | ||
|
||
let data_to_verify_start_index = 0; | ||
let integrity_start_index = 694 / 2; | ||
|
||
let px = "45E3943B0705F9EF69B53A4EFB8C668E6A9F90124E9BCF917662CFADEA56C0C1"; | ||
let py = "F3703834F92F6FE70A004BA4098D079BFB5F927E042991EFD5A1572E8F9D39D6"; | ||
|
||
let r = "9970818CBCA38C196795EEAD295BDED48311702DF7DDB0C2BB448276894C393D"; | ||
let s = "729B2F9229D545A553F0F7CBC1792E9A6185E539DBF667FE5BC38D673D90C014"; | ||
|
||
let r = hex::decode(r).unwrap(); | ||
let s = hex::decode(s).unwrap(); | ||
|
||
let px = hex::decode(px).unwrap(); | ||
let py = hex::decode(py).unwrap(); | ||
|
||
let input = SXGInput { | ||
final_payload: final_payload.to_vec(), | ||
data_to_verify: data_to_verify.to_vec(), | ||
data_to_verify_start_index, | ||
integrity_start_index, | ||
payload: payload.to_vec(), | ||
r: r.try_into().unwrap(), | ||
s: s.try_into().unwrap(), | ||
px: px.try_into().unwrap(), | ||
py: py.try_into().unwrap(), | ||
}; | ||
|
||
let result = sxg_verify(input).unwrap(); | ||
|
||
// Encode the public values of the program. | ||
let bytes = PublicValuesStruct::abi_encode(&PublicValuesStruct { n, a, b }); | ||
|
||
// Commit to the public values of the program. The final proof will have a commitment to all the | ||
// bytes that were committed to. | ||
let sxg_input = sp1_zkvm::io::read::<SXGInput>(); | ||
let result = sxg_input.verify().unwrap() as u32; | ||
let bytes = PublicValuesStruct::abi_encode(&PublicValuesStruct { result }); | ||
sp1_zkvm::io::commit_slice(&bytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.