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 l2r0_small_serde::{from_slice_compact, to_vec_compact};
let input = 42_u32;
let encoded = to_vec_compact(&[input]).unwrap();
let output: u32 = from_slice_compact(&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§
- Deserializer
- Enables deserializing from a WordRead
- Serializer
- Enables serializing to a stream
Enums§
- Error
- Errors used by Serde
Functions§
- align_
up - Align the given address
addr
upwards to alignmentalign
. - from_
slice_ compact - Deserialize a slice into the specified type.
- to_
vec_ compact - Serialize to a vector of u32 words
- to_
vec_ compact_ with_ capacity - Serialize to a vector of u32 words with size hinting
Type Aliases§
- Result
- A Result type for
risc0_zkvm::serde
operations that can fail