Commit 30bcb23
authored
fix: Fr::from_u64 big-endian encoding to match C++ msgpack format (#22233)
## Summary
Fixes bb-rs test failure introduced by #22311 (graceful failures in
verifier code paths).
`Fr::from_u64` was storing values in **little-endian**, but the C++
`field::msgpack_unpack` expects **big-endian** (network byte order).
This was masked before because the C++ side silently reduced
non-canonical values via `to_montgomery_form_reduced()`. After #22311
added strict non-canonical field validation (throwing for values >=
modulus), values like `Fr::from_u64(123)` produce `0x7B<<248` which
exceeds the BN254 Fr modulus (`0x30644e72...`) and cause a C++ exception
that propagates through the FFI boundary, aborting the Rust test process
with "Rust cannot catch foreign exceptions".
## Fix
One-line change: store the u64 value in bytes 24..32 as big-endian
instead of bytes 0..8 as little-endian.
## Test plan
- [x] Reproduced failure locally — `test_pedersen_commit_deterministic`
crashes with SIGABRT
- [x] Applied fix — all 70 bb-rs tests pass (3 perf tests ignored)
- [ ] `./bootstrap.sh ci` running1 parent 5f09c55 commit 30bcb23
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments