-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moving pub_key_to_bytes to aztec-nr
- Loading branch information
Showing
5 changed files
with
22 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use dep::protocol_types::point::Point; | ||
|
||
/// Converts a public key to a byte array. | ||
/// | ||
/// We don't serialize the point at infinity flag because this function is used in situations where we do not want | ||
/// to waste the extra byte (encrypted log). | ||
pub fn pub_key_to_bytes(pk: Point) -> [u8; 64] { | ||
assert(!pk.is_infinite, "Point at infinity is not a valid public key."); | ||
let mut result = [0 as u8; 64]; | ||
let x_bytes = pk.x.to_be_bytes(32); | ||
let y_bytes = pk.y.to_be_bytes(32); | ||
for i in 0..32 { | ||
result[i] = x_bytes[i]; | ||
result[i + 32] = y_bytes[i]; | ||
} | ||
result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters