Skip to main content

ProofEnvelope

Struct ProofEnvelope 

Source
pub struct ProofEnvelope {
    pub statement_kind: ProofStatementKind,
    pub backend_id: BackendId,
    pub version: u32,
    pub public_inputs: Vec<Vec<u8>>,
    pub commitment_roots: Vec<Hash256>,
    pub verifier_key_or_image_id: Vec<u8>,
    pub domain_separator: Vec<u8>,
}
Expand description

A versioned envelope binding everything a verifier needs to know about a proof, independent of the proof bytes themselves.

Field order mirrors the VCG-001 “Next red test” bullet: “statement kind, backend id, version, public inputs, commitment roots, verifier key or image id, and domain separator.”

Fields§

§statement_kind: ProofStatementKind

Which kind of statement this envelope attests to.

§backend_id: BackendId

Which backend produced (and must verify) the wrapped proof.

§version: u32

Envelope format version. Independent of the crate/package version; bump when the envelope’s own field shape changes.

§public_inputs: Vec<Vec<u8>>

Public inputs to the statement, as opaque byte strings. Semantics are defined per ProofStatementKind / backend.

§commitment_roots: Vec<Hash256>

Commitment roots (e.g. DAG roots, state roots) the statement is anchored to.

§verifier_key_or_image_id: Vec<u8>

The verifier key (SNARK/STARK) or image id (zkVM-style backends) needed to verify the wrapped proof, as opaque bytes.

§domain_separator: Vec<u8>

Domain separator binding this envelope to its intended context, so a valid proof for one domain cannot be replayed as valid for another.

Implementations§

Source§

impl ProofEnvelope

Source

pub fn validate_backend(&self) -> Result<()>

Validates that Self::backend_id names a known, registered backend.

Fails closed: any BackendId::Unknown value — including ids that happen to coincide with a future backend not yet registered here — is refused. This must be called (directly, or transitively via Self::verify) before any proof bytes wrapped by this envelope are trusted.

Source

pub fn binding_payload(&self) -> Result<Vec<u8>>

Canonical journal-binding digest for a RISC Zero receipt (objective O-1.1, 2026-07-04 ratification slate).

Folds the ENTIRE envelope context — statement_kind, backend_id, version, public_inputs, commitment_roots, verifier_key_or_image_id, and domain_separator — into a single BLAKE3 digest over canonical CBOR, under a fixed domain tag. This is the value a RISC Zero receipt’s journal must commit to: the audited RiscZeroReceiptVerifier checks the receipt verifies against the image id AND that its journal equals this digest, so a receipt proven for one (statement, roots, domain) context can never be replayed as valid under another. Before O-1.1 the seam received only the image id and the raw public inputs, dropping statement_kind, commitment_roots, and domain_separator — an unbound statement.

§Errors

Returns ProofError::InvalidProofFormat if canonical CBOR encoding of the binding tuple fails. Canonical CBOR bytes hashed by Self::binding_digest.

A RISC Zero guest must commit exactly these bytes so blake3(journal.bytes) equals the envelope binding digest.

Source

pub fn binding_digest(&self) -> Result<Hash256>

Source

pub fn verify(&self, receipt_bytes: &[u8]) -> Result<bool>

Verifies the envelope’s named backend is both registered and, if unaudited, explicitly opted into.

receipt_bytes are the serialized risc0 Receipt/proof bytes to check (objective O-1.2). They are threaded down to the RiscZeroReceiptVerifier seam for the BackendId::RiscZero arm so the future audited verifier can decode and check them; the FailClosedRiscZeroVerifier default ignores them and still refuses. The UnauditedBlake3Standin and Unknown arms never inspect receipt_bytes — for them it is simply an unused parameter — so passing any value (including &[]) cannot change their fail-closed outcomes.

No backend has a working, externally-reviewed verifier wired yet: the unaudited blake3 stand-in is feature-gated and still a fail-closed stub even when opted into (VCG-001a), and the RISC Zero seam (VCG-001b, ratified decision D1) is wired but pending external cryptographic review (see RiscZeroReceiptVerifier). Fail-closed: every backend currently registered returns a typed error here — there is no verifier wired for any backend at this stage. This is a deliberate success-shaped surface trap avoidance: verify() must never report Ok(true) unless it actually verified something.

Behavior:

  • Unknown/unregistered backend id → Err(ProofError::InvalidProofFormat) (fail-closed registry, checked first via Self::validate_backend).
  • UNAUDITED_BLAKE3_STANDIN_BACKEND_ID → first refuses with Err(ProofError::UnauditedImplementation) unless the unaudited-pedagogical-proofs feature is enabled (mirroring [crate::guard_unaudited]); if that guard passes, still refuses with Err(ProofError::VerificationFailed) because no verifier is wired for this backend yet — construction/wrapping of an envelope for this backend is feature-gated as above, but verification is not implemented at all.
  • BackendId::RiscZero → always refuses with Err(ProofError::VerificationFailed) via FailClosedRiscZeroVerifier, independent of the unaudited-pedagogical-proofs feature flag (that flag only gates this crate’s own blake3 stand-in, not the RiscZero seam). The refusal reason names pending external review, not a missing feature opt-in.

Trait Implementations§

Source§

impl Clone for ProofEnvelope

Source§

fn clone(&self) -> ProofEnvelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProofEnvelope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ProofEnvelope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ProofEnvelope

Source§

impl PartialEq for ProofEnvelope

Source§

fn eq(&self, other: &ProofEnvelope) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ProofEnvelope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ProofEnvelope

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more