Module risc0_zkvm::serde

source ·
Expand description

Serialization and deserialization tools for the RISC Zero zkVM

Data needs to be serialized for transmission between the zkVM host and guest. This module contains tools for this serialization and the corresponding deserialization.

On the host side, a serialization function such as to_vec should be used when transmitting data to the guest, e.g.

prover.add_input_u32_slice(
    &to_vec(&a).expect("should be given serializeable type")
);

Similarly, the deserialization function from_slice should be used when reading data from the guest, e.g.

let c: u64 = from_slice(&receipt.journal)
    .expect("should deserialize if type matches what the guest committed");

On the guest side, the necessary (de)serialization functionality is included in env module functions such as env::read and env::commit, so this crate rarely needs to be directly used in the guest.

Structs

Functions