Skip to content

Commit 4ce5634

Browse files
authored
chore: Update readme (#85)
2 parents 7367866 + 937854b commit 4ce5634

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

README.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -129,41 +129,6 @@ const keypair = try scheme.keyGen(0, 256);
129129

130130
> **Performance Note**: For lifetimes `2^18` and `2^32`, always compile with `zig build -Doptimize=ReleaseFast` for acceptable performance. Debug builds will be extremely slow for larger lifetimes.
131131
132-
## Cross-Language Compatibility Tests
133-
134-
**Cross-language compatibility status:**
135-
136-
-**Lifetime `2^8`**: All combinations pass (Rust sign → Rust/Zig verify, Zig sign → Zig/Rust verify).
137-
- ⚠️ **Lifetime `2^18`**: Rust sign → Rust/Zig verify and Zig sign → Zig verify pass; **Zig sign → Rust verify currently fails** due to a mismatch in the 2^18 instantiation on the Rust side.
138-
-**Lifetime `2^32`**: All combinations pass (Rust sign → Rust/Zig verify, Zig sign → Zig/Rust verify).
139-
140-
### Quick Start
141-
142-
```bash
143-
# Run all supported lifetimes
144-
python3 benchmark/benchmark.py --lifetime "2^8,2^18,2^32"
145-
146-
# Run specific lifetime
147-
python3 benchmark/benchmark.py --lifetime 2^32
148-
149-
# Enable verbose debug logs
150-
BENCHMARK_DEBUG_LOGS=1 python3 benchmark/benchmark.py --lifetime 2^8
151-
```
152-
153-
The script automatically builds both implementations and runs comprehensive cross-language tests (Rust ↔ Zig signing and verification).
154-
155-
### Test Results
156-
157-
**Lifetime 2^32 (256 active epochs):**
158-
- ✅ Rust keygen: ~2.0s, Zig keygen: ~1.3s
159-
- ✅ All verification tests pass
160-
161-
**Lifetime 2^32 (1024 active epochs):**
162-
- ✅ Zig keygen: ~51.7s (46.5% faster with parallel optimization)
163-
- ✅ All verification tests pass
164-
165-
See [Performance Benchmarks](#performance-benchmarks) for detailed timing information.
166-
167132
## Performance Benchmarks
168133

169134
Performance measurements are taken using ReleaseFast builds with debug logging disabled. For lifetime `2^32` with 1024 active epochs, key generation time is measured using the dedicated profiler:

scripts/benchmark_hash_function.zig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ const hash_zig = @import("hash-zig");
66
const Allocator = std.mem.Allocator;
77
const FieldElement = hash_zig.FieldElement;
88
const Poseidon2RustCompat = hash_zig.Poseidon2RustCompat;
9-
// Import directly to avoid module conflicts (benchmark is separate executable)
109
const poseidon2_simd = @import("../src/hash/poseidon2_hash_simd.zig");
11-
const simd_utils = @import("../src/signature/native/simd_utils.zig");
1210

1311
pub fn main() !void {
1412
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
@@ -26,27 +24,27 @@ pub fn main() !void {
2624
// Test parameters
2725
const num_iterations = 10000;
2826
const hash_len = 8; // HASH_LEN_FE
29-
const SIMD_WIDTH = simd_utils.SIMD_WIDTH;
27+
const SIMD_WIDTH = poseidon2_simd.SIMD_WIDTH_CONST;
3028

3129
std.debug.print("Configuration:\n", .{});
3230
std.debug.print(" SIMD Width: {}\n", .{SIMD_WIDTH});
3331
std.debug.print(" Hash Length: {}\n", .{hash_len});
3432
std.debug.print(" Iterations: {}\n\n", .{num_iterations});
3533

3634
// Benchmark: compress16SIMD with SIMD-packed input
37-
var packed_input: [16]simd_utils.PackedF = undefined;
35+
var packed_input: [16]poseidon2_simd.PackedF = undefined;
3836

3937
// Initialize with test data
4038
for (0..16) |i| {
4139
var values: [SIMD_WIDTH]u32 = undefined;
4240
for (0..SIMD_WIDTH) |lane| {
4341
values[lane] = @as(u32, @intCast((i * 1000) + lane));
4442
}
45-
packed_input[i] = simd_utils.PackedF{ .values = values };
43+
packed_input[i] = poseidon2_simd.PackedF{ .values = values };
4644
}
4745

4846
// Warmup
49-
var output_stack: [8]simd_utils.PackedF = undefined;
47+
var output_stack: [8]poseidon2_simd.PackedF = undefined;
5048
for (0..100) |_| {
5149
_ = try simd_poseidon2.compress16SIMD(&packed_input, hash_len, output_stack[0..hash_len]);
5250
}

src/hash/poseidon2_hash_simd.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const Poseidon2KoalaBear24 = @import("../poseidon2/root.zig").Poseidon2KoalaBear
1616
const WIDTH_16 = 16;
1717
const SIMD_WIDTH = simd_utils.SIMD_WIDTH;
1818

19+
// Re-export SIMD utilities for external benchmarks without importing simd_utils directly
20+
pub const PackedF = simd_utils.PackedF;
21+
pub const SIMD_WIDTH_CONST: u32 = SIMD_WIDTH;
22+
1923
/// SIMD-aware Poseidon2 compression function
2024
/// Processes multiple states simultaneously using SIMD operations
2125
pub const Poseidon2SIMD = struct {

0 commit comments

Comments
 (0)