Skip to content

Commit 3ec2166

Browse files
committed
feat: Include zkvm and prooftype in ProofReceipt
1 parent a1c73b0 commit 3ec2166

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

adapters/native/src/host.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{fmt, sync::Arc};
22

33
use zkaleido::{
4-
Proof, ProofReceipt, ProofType, PublicValues, VerifyingKey, VerifyingKeyCommitment, ZkVmError,
5-
ZkVmExecutor, ZkVmHost, ZkVmProver, ZkVmResult, ZkVmVerifier,
4+
Proof, ProofReceipt, ProofType, PublicValues, VerifyingKey, VerifyingKeyCommitment, ZkVm,
5+
ZkVmError, ZkVmExecutor, ZkVmHost, ZkVmProver, ZkVmResult, ZkVmVerifier,
66
};
77

88
use crate::{env::NativeMachine, input::NativeMachineInputBuilder, proof::NativeProofReceipt};
@@ -51,7 +51,7 @@ impl ZkVmProver for NativeHost {
5151
) -> ZkVmResult<NativeProofReceipt> {
5252
let public_values = self.execute(native_machine)?;
5353
let proof = Proof::default();
54-
Ok(ProofReceipt::new(proof, public_values).try_into()?)
54+
Ok(ProofReceipt::new(proof, public_values, ZkVm::Native).try_into()?)
5555
}
5656
}
5757

adapters/risc0/host/src/proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use risc0_zkvm::{InnerReceipt, Receipt};
2-
use zkaleido::{Proof, ProofReceipt, PublicValues, ZkVmProofError};
2+
use zkaleido::{Proof, ProofReceipt, PublicValues, ZkVm, ZkVmProofError};
33

44
#[derive(Debug, Clone)]
55
pub struct Risc0ProofReceipt(Receipt);
@@ -51,6 +51,6 @@ impl TryFrom<Risc0ProofReceipt> for ProofReceipt {
5151
};
5252
let proof = Proof::new(proof_bytes);
5353
let public_values = PublicValues::new(value.0.journal.bytes.to_vec());
54-
Ok(ProofReceipt::new(proof, public_values))
54+
Ok(ProofReceipt::new(proof, public_values, ZkVm::Risc0))
5555
}
5656
}

adapters/sp1/host/src/proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use sp1_sdk::{SP1Proof, SP1ProofWithPublicValues, SP1PublicValues};
2-
use zkaleido::{Proof, ProofReceipt, PublicValues, ZkVmProofError};
2+
use zkaleido::{Proof, ProofReceipt, PublicValues, ZkVm, ZkVmProofError};
33

44
#[derive(Debug, Clone)]
55
pub struct SP1ProofReceipt(SP1ProofWithPublicValues);
@@ -62,6 +62,6 @@ impl TryFrom<SP1ProofReceipt> for ProofReceipt {
6262
let proof = Proof::new(proof_bytes);
6363
let public_values = PublicValues::new(sp1_receipt.public_values.to_vec());
6464

65-
Ok(ProofReceipt::new(proof, public_values))
65+
Ok(ProofReceipt::new(proof, public_values, ZkVm::SP1))
6666
}
6767
}

zkaleido/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! - **Error Handling**: A set of error enums (e.g., `ZkVmError`) provides comprehensive error
1616
//! reporting and integration with Rust's `thiserror` crate for detailed diagnostics.
1717
18+
use arbitrary::Arbitrary;
1819
use borsh::{BorshDeserialize, BorshSerialize};
1920
use serde::{Deserialize, Serialize};
2021

@@ -48,18 +49,21 @@ pub use verifier::*;
4849
Clone,
4950
Copy,
5051
PartialEq,
52+
Default,
5153
Eq,
5254
Hash,
5355
BorshSerialize,
5456
BorshDeserialize,
5557
Serialize,
5658
Deserialize,
59+
Arbitrary,
5760
)]
5861
pub enum ZkVm {
5962
/// SP1 ZKVM
6063
SP1,
6164
/// Risc0 ZKVM
6265
Risc0,
6366
/// Native ZKVM
67+
#[default]
6468
Native,
6569
}

zkaleido/src/proof.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use arbitrary::Arbitrary;
44
use borsh::{BorshDeserialize, BorshSerialize};
55
use serde::{Deserialize, Serialize};
66

7-
use crate::{ZkVmError, ZkVmResult};
7+
use crate::{ZkVm, ZkVmError, ZkVmResult};
88

99
/// Macro to define a newtype wrapper around `Vec<u8>` with common implementations.
1010
macro_rules! define_byte_wrapper {
@@ -90,14 +90,17 @@ pub struct ProofReceipt {
9090
proof: Proof,
9191
/// The public values associated with the proof.
9292
public_values: PublicValues,
93+
/// ZKVM used to generate this proof
94+
zkvm: ZkVm,
9395
}
9496

9597
impl ProofReceipt {
9698
/// Creates a new `ProofReceipt` from proof and it's associated public values
97-
pub fn new(proof: Proof, public_values: PublicValues) -> Self {
99+
pub fn new(proof: Proof, public_values: PublicValues, zkvm: ZkVm) -> Self {
98100
Self {
99101
proof,
100102
public_values,
103+
zkvm,
101104
}
102105
}
103106

@@ -111,6 +114,11 @@ impl ProofReceipt {
111114
&self.public_values
112115
}
113116

117+
/// Returns the ZKVM used to generate the proof.
118+
pub fn zkvm(&self) -> &ZkVm {
119+
&self.zkvm
120+
}
121+
114122
/// Saves the proof to a path.
115123
pub fn save(&self, path: impl AsRef<Path>) -> ZkVmResult<()> {
116124
bincode::serialize_into(File::create(path).expect("failed to open file"), self)
@@ -181,9 +189,22 @@ impl VerifyingKeyCommitment {
181189
}
182190

183191
/// Enumeration of proof types supported by the system.
184-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
192+
#[derive(
193+
Debug,
194+
Clone,
195+
Copy,
196+
Default,
197+
PartialEq,
198+
Eq,
199+
Serialize,
200+
Deserialize,
201+
BorshSerialize,
202+
BorshDeserialize,
203+
Arbitrary,
204+
)]
185205
pub enum ProofType {
186206
/// Represents a Groth16 proof.
207+
#[default]
187208
Groth16,
188209
/// Represents a core proof.
189210
Core,

0 commit comments

Comments
 (0)