Commit ea79d1f
committed
fix(common): reject FIELD_IDs whose .np magic aliases another format
`np_format` derives the `.np` magic by offsetting the final byte with
`FIELD_ID`, which reserves all 256 values of that byte for `.np`. Nothing
recorded or enforced that reservation. Assert it at compile time against the
other three format constants, so a field whose magic would collide is a build
error rather than a file one reader silently accepts as another.
Offsetting one byte is a bijection on `u8`, so distinct ids always give distinct
magics and no field can collide with another. What `np_format` cannot see,
working one field at a time, is two backends declaring the same `FIELD_ID`.
`field_tags.rs` is the only place all three fields are in scope together, so it
asserts the ids and magics are pairwise unique. Reading `FORMAT` there also
const-evaluates the new assert for the non-bn254 fields, which nothing else in
the workspace does.1 parent 85798ea commit ea79d1f
2 files changed
Lines changed: 86 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
262 | 282 | | |
263 | 283 | | |
264 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
265 | 288 | | |
266 | 289 | | |
267 | 290 | | |
268 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
269 | 301 | | |
270 | 302 | | |
271 | 303 | | |
| |||
286 | 318 | | |
287 | 319 | | |
288 | 320 | | |
289 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
290 | 325 | | |
291 | 326 | | |
292 | | - | |
| 327 | + | |
293 | 328 | | |
294 | | - | |
295 | | - | |
296 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
297 | 342 | | |
298 | 343 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments