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. Similarly, the deserialization function from_slice should be used when reading data from the guest. For example:
use risc0_zkvm::serde::{from_slice, to_vec};
let input = 42_u32;
let encoded = to_vec(&[input]).unwrap();
let output: u32 = from_slice(&encoded).unwrap();
assert_eq!(input, output);
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§
- Enables deserializing from a WordRead
- Enables serializing to a stream
Enums§
- Errors used by Serde
Traits§
- A reader for reading streams with serialized word-based data
- A writer for writing streams preferring word-based data.
Functions§
- Deserialize a slice into the specified type.
- Serialize to a vector of u32 words
- Serialize to a vector of u32 words with size hinting
Type Aliases§
- A Result type for
risc0_zkvm::serde
operations that can fail