Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Apr 29, 2024
1 parent 0e9678f commit 3ef9ef3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use dep::protocol_types::{grumpkin_point::GrumpkinPoint, grumpkin_private_key::GrumpkinPrivateKey};
use dep::std::hash::sha256;
use dep::protocol_types::grumpkin_point::GrumpkinPoint;
use dep::std::{hash::sha256, grumpkin_scalar::GrumpkinScalar, grumpkin_scalar_mul::grumpkin_variable_base};

pub fn point_to_symmetric_key(secret: GrumpkinPrivateKey, point: GrumpkinPoint) -> [u8; 32] {
// let shared_secret = secret * point; // TODO(benesjan): implement grumpkin_scalar_mul::grumpkin_variable_base
let shared_secret = point;
pub fn point_to_symmetric_key(secret: GrumpkinScalar, point: GrumpkinPoint) -> [u8; 32] {
let shared_secret_fields = grumpkin_variable_base(point.x, point.y, secret);
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6061): make the func return Point struct directly
let shared_secret = GrumpkinPoint::new(shared_secret_fields[0], shared_secret_fields[1]);
sha256(shared_secret.to_be_bytes())
}

#[test]
fn check_point_to_symmetric_key() {
let secret = GrumpkinPrivateKey::new(5, 6);
let secret = GrumpkinScalar::new(5, 6);
let point = GrumpkinPoint::new(7, 8);

let key = point_to_symmetric_key(secret, point);
Expand Down

0 comments on commit 3ef9ef3

Please sign in to comment.