You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Remove legacy code and unnecessary pickle support (v0.2.0)
Major cleanup and simplification:
- Remove all pickle support from PyO3 classes (unused complexity)
- Delete serialization.rs (was only for pickle support)
- Remove legacy compatibility methods:
- journal_bytes() (use journal property instead)
- image_id property (use id property instead)
- ed25519_input_vecs() (use ed25519_input() instead)
- Clean up serialization helpers:
- Remove incompatible merkle_proof_input() for env::read() style
- Keep merkle_commitment_input() for 2LA-style demo
- Update demos to use serialization helpers properly
Benefits:
- Smaller codebase with less maintenance burden
- Clearer separation between Rust and Python code
- No confusing duplicate methods or unused features
- Demos now properly test the serialization helpers
Breaking changes from v0.1.0:
- Removed pickle support (use standard serialization if needed)
- Removed deprecated method aliases
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
PyR0 provides serialization helpers for sending data to RISC Zero guest programs. The choice of serialization method depends on how your guest reads the data:
112
+
113
+
#### For Guests Using `env::read()`
114
+
115
+
These helpers add length prefixes and are designed for serde deserialization:
98
116
99
117
```python
100
118
from pyr0 import serialization
101
119
102
-
#Optional serialization helpers for guest programs
120
+
#These work with env::read() in the guest
103
121
data = serialization.to_vec_u8(bytes_data) # Vec<u8> with length prefix
104
-
data = serialization.to_u32(value) # 32-bit unsigned integer
105
-
data = serialization.to_u64(value) # 64-bit unsigned integer
106
-
data = serialization.to_string(text) # String with length prefix
107
-
data = serialization.to_bool(value) # Boolean value
108
-
data = serialization.to_bytes32(data) # Fixed [u8; 32] array
109
-
data = serialization.to_bytes64(data) # Fixed [u8; 64] array
110
-
111
-
# Convenience functions for common patterns
122
+
data = serialization.to_u32(value) # u32 (4 bytes, little-endian)
123
+
data = serialization.to_u64(value) # u64 (8 bytes, little-endian)
124
+
data = serialization.to_string(text) # String with 8-byte length prefix
125
+
data = serialization.to_bool(value) # bool (single byte: 0 or 1)
126
+
127
+
# Guest code would use:
128
+
# let data: Vec<u8> = env::read();
129
+
# let value: u32 = env::read();
130
+
# let text: String = env::read();
131
+
```
132
+
133
+
#### For Guests Using `env::read_slice()`
134
+
135
+
These helpers provide raw bytes without length prefixes:
136
+
137
+
```python
138
+
# Fixed-size arrays (no length prefix)
139
+
data = serialization.to_bytes32(data) # [u8; 32] - exactly 32 bytes
140
+
data = serialization.to_bytes64(data) # [u8; 64] - exactly 64 bytes
141
+
data = serialization.raw_bytes(data) # Raw bytes, no transformation
142
+
143
+
# Guest code would use:
144
+
# let mut buffer = [0u8; 32];
145
+
# env::read_slice(&mut buffer);
146
+
```
147
+
148
+
#### Convenience Functions
149
+
150
+
Pre-built serializers for common cryptographic operations:
151
+
152
+
```python
153
+
# For Ed25519 signature verification (uses env::read() format)
The `--force-reinstall` flag is crucial to ensure you're using the latest version.
338
+
183
339
## Acknowledgments
184
340
185
341
This project is based on the original [PyR0](https://github.com/l2iterative/pyr0prover-python) by L2 Iterative, which focused on distributed proof generation using Dask/Ray. The current fork extends PyR0 with additional features for zero-knowledge proof development, including Merkle tree support and improved guest program interfaces.
0 commit comments