Commit f56fe7c
authored
# Motivation
Some AztecAddresses and x coordinates may not correspond to valid points
on the curve. Previously, `to_address_point` `point_from_x_coord` and
`point_from_x_coord_and_sign` assumed the x coordinate were always
valid, which could lead to runtime errors or potential security issues.
Now, both functions return an `Option`, returning `None` if the x
coordinate does not correspond to a valid point. This makes handling
invalid addresses explicit and safe.
# Key points
- `sqrt` moved from `aztec-nr/aztec/src/utils/field.nr` to
`noir-protocol-circuits`
- Deleted redundant `field.nr` from `aztec-nr`
- `AztecAddress::to_address_point` now returns `Option<AddressPoint>`
- `point_from_x_coord` now returns `Option<Point>`
- `point_from_x_coord_and_sign` now returns `Option<Point>` as well
- Existing internal call sites temporarily use `.unwrap()` to maintain
behaviour
- Added tests in `point.nr`, `field.nr`, and `aztec_address.nr` to
verify Optionals in all relevant functions:
- Valid x (sqrt exists)
- Invalid x (sqrt fails, returns `None`)
# Breaking change
Any code calling `to_address_point`, `point_from_x_coord`, or
`point_from_x_coord_and_sign` must now handle `Option` instead of
assuming a valid point.
# Addresses
Closes #8970
File tree
9 files changed
+230
-246
lines changed- noir-projects
- aztec-nr/aztec/src
- keys
- messages/encryption
- oracle
- utils
- noir-protocol-circuits/crates/types/src
- address
- utils
9 files changed
+230
-246
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
326 | 327 | | |
327 | 328 | | |
328 | 329 | | |
| |||
Lines changed: 21 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
26 | | - | |
27 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
28 | 40 | | |
29 | 41 | | |
30 | 42 | | |
| |||
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
83 | | - | |
| 95 | + | |
84 | 96 | | |
85 | 97 | | |
86 | 98 | | |
87 | 99 | | |
88 | | - | |
| 100 | + | |
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
| |||
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
97 | | - | |
| 109 | + | |
98 | 110 | | |
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | | - | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
338 | 340 | | |
339 | 341 | | |
340 | 342 | | |
341 | | - | |
| 343 | + | |
| 344 | + | |
342 | 345 | | |
343 | 346 | | |
344 | 347 | | |
| |||
426 | 429 | | |
427 | 430 | | |
428 | 431 | | |
429 | | - | |
| 432 | + | |
| 433 | + | |
430 | 434 | | |
431 | 435 | | |
432 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
0 commit comments