-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathlib.rs
More file actions
38 lines (33 loc) · 908 Bytes
/
lib.rs
File metadata and controls
38 lines (33 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use serde::{Deserialize, Serialize};
use sha3::{Digest, Keccak256};
#[derive(Serialize, Deserialize)]
pub struct SP1VkAndPubInputs {
pub vk: [u32; 8],
pub public_inputs: Vec<u8>,
}
impl SP1VkAndPubInputs {
pub fn hash(&self) -> [u8; 32] {
let mut hasher = Keccak256::new();
for &word in &self.vk {
hasher.update(word.to_be_bytes());
}
hasher.update(&self.public_inputs);
hasher.finalize().into()
}
}
#[derive(Serialize, Deserialize)]
pub enum ProofVkAndPubInputs {
SP1Compressed(SP1VkAndPubInputs),
}
impl ProofVkAndPubInputs {
pub fn hash(&self) -> [u8; 32] {
match self {
ProofVkAndPubInputs::SP1Compressed(proof_data) => proof_data.hash(),
}
}
}
#[derive(Serialize, Deserialize)]
pub struct Input {
pub proofs_vk_and_pub_inputs: Vec<ProofVkAndPubInputs>,
pub merkle_root: [u8; 32],
}