Skip to content

Commit 05c29bc

Browse files
committed
basic crates structure
1 parent 3a9c0e1 commit 05c29bc

File tree

24 files changed

+1567
-109
lines changed

24 files changed

+1567
-109
lines changed

Cargo.lock

+1,500-53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["service", "crypto", "client", "voting-tree"]
3+
members = ["service", "crypto", "client", "voting-tree", "risc0-types", "risc0-verifier"]
44

55
[profile.dev]
66
opt-level = 3

client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ voting-tree = {path="../voting-tree"}
99
crypto = {path="../crypto"}
1010
pgp = "0.13"
1111
serde = {version="1", features=["derive"]}
12-
risc0-zkvm = { version = "0.21.0", default-features = false }
12+
risc0-types = {path="../risc0-types"}

client/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
pub mod prover;
21
pub mod storage;
3-
pub mod verifier;
2+
pub mod prover;

client/src/prover/logic.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// that the merkle proof of that leaf is valid for one of the roots in a given list
44

55
use std::path::PathBuf;
6-
6+
use risc0_types::{CircuitInputs, CircuitOutputs};
77
// private inputs: tree snapshot, public key
88
// public inputs/outputs: list of roots
99
// public outputs: nullifier
@@ -14,20 +14,6 @@ use crypto::identity::{Identity, Nullifier, UniqueIdentity};
1414
use serde::{Deserialize, Serialize};
1515
use voting_tree::VotingTree;
1616

17-
#[derive(Serialize, Deserialize)]
18-
pub struct CircuitInputs {
19-
pub root_history: Vec<TreeRoot>,
20-
pub snapshot: VotingTree,
21-
pub nullifier: Nullifier,
22-
pub public_key_path: PathBuf, // todo: serialize / deserialize pgp public key
23-
}
24-
25-
#[derive(Serialize, Deserialize)]
26-
pub struct CircuitOutputs {
27-
pub nullifier: Nullifier,
28-
pub root_history: Vec<TreeRoot>,
29-
}
30-
3117
pub fn prover_logic(inputs: &mut CircuitInputs) -> CircuitOutputs {
3218
let mut gpg_signer: GpgSigner = GpgSigner {
3319
secret_key_asc_path: None,

risc0-circuit/methods/voting-guest/Cargo.toml

-10
This file was deleted.

risc0-circuit/methods/voting-guest/src/main.rs

-21
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

risc0-circuit/methods/Cargo.toml risc0-circuits/methods/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ edition = "2021"
77
risc0-build = { version = "0.21.0" }
88

99
[package.metadata.risc0]
10-
methods = ["voting-guest"]
10+
methods = ["voting"]
File renamed without changes.
File renamed without changes.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "voting"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[workspace]
7+
8+
[dependencies]
9+
# If you want to try (experimental) std support, add `features = [ "std" ]` to risc0-zkvm
10+
risc0-zkvm = { version = "0.21.0", default-features = false, features=["std"] }
11+
client = {path="../../../client"}
12+
risc0-types = {path="../../../risc0-types"}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![no_main]
2+
use risc0_zkvm::guest::env;
3+
use risc0_types::{CircuitInputs, CircuitOutputs};
4+
use client::prover::logic::prover_logic;
5+
risc0_zkvm::guest::entry!(main);
6+
7+
8+
fn main() {
9+
let input: CircuitInputs = env::read();
10+
11+
env::commit(&input);
12+
}
File renamed without changes.

risc0-types/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "risc0-types"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
7+
[dependencies]
8+
voting-tree = {path="../voting-tree"}
9+
serde={version="1", features=["derive"]}

risc0-types/src/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::path::PathBuf;
2+
3+
use voting_tree::VotingTree;
4+
use serde::{Serialize, Deserialize};
5+
#[derive(Serialize, Deserialize)]
6+
pub struct CircuitInputs {
7+
pub root_history: Vec<Vec<u8>>,
8+
pub snapshot: VotingTree,
9+
pub nullifier: Vec<u8>,
10+
pub public_key_path: PathBuf, // todo: serialize / deserialize pgp public key
11+
}
12+
13+
#[derive(Serialize, Deserialize)]
14+
pub struct CircuitOutputs {
15+
pub nullifier: Vec<u8>,
16+
pub root_history: Vec<Vec<u8>>,
17+
}

risc0-verifier/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "risc0-verifier"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
7+
[dependencies]
8+
risc0-zkvm = { version = "0.21.0", default-features=false, features=["std", "prove"] }

risc0-verifier/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Verify the receipt, check the journal root_history and add the nullifier to state
2-
use crate::storage::TreeRoot;
3-
use crypto::identity::Nullifier;
42
use risc0_zkvm::Receipt;
5-
6-
pub fn verify_receipt(receipt: Receipt, root_history: Vec<TreeRoot>) -> Nullifier {
3+
pub fn verify_receipt(receipt: Receipt, root_history: Vec<Vec<u8>>) -> Vec<u8> {
74
todo!("verify receipt and check that root is in root_history")
85
}

service/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::collections::HashSet;
1010
// for the user
1111
use client::{
1212
storage::{InMemoryTreeState, Snapshot},
13-
verifier::verify_receipt,
1413
};
1514
use crypto::identity::{Identity, Nullifier};
1615
use risc0_zkvm::Receipt;

0 commit comments

Comments
 (0)