Commit 082424b
authored
### What
`Fr` types for BN254 and BLS12-381 stored raw `U256` values without
modular reduction, causing mathematically equal field elements (e.g., 1
and r+1) to compare as not-equal via PartialEq.
The fix: apply `rem_euclid(r)` in `From<U256>` for `Fr`, and ensuring
all public construction paths produce canonical representations in [0,
r).
Also introduces modulus validation for BLS12-381 and BN254 base-field
element wrappers (Fp/Fp2) and refactor `BytesN` wrapper macros to
support validated `from_bytes`.
1 parent 3e529a6 commit 082424b
19 files changed
Lines changed: 1964 additions & 87 deletions
File tree
- soroban-sdk
- src
- crypto
- testutils
- test_snapshots/tests/crypto_bls12_381
- tests-expanded
- tests
- bls
- src
- test_snapshots/test
- bn254
- src
- test_snapshots/test
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
105 | 114 | | |
106 | | - | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
154 | | - | |
155 | | - | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
229 | 253 | | |
230 | 254 | | |
231 | 255 | | |
| |||
0 commit comments