Skip to content

Instantly share code, notes, and snippets.

@n4ru
Forked from signorecello/pubkeytoaddress.nr
Created September 6, 2023 06:45
Show Gist options
  • Save n4ru/b79841f27d1bffb93edaaf9f9f973c73 to your computer and use it in GitHub Desktop.
Save n4ru/b79841f27d1bffb93edaaf9f9f973c73 to your computer and use it in GitHub Desktop.
Convert public key to ethereum address in Noir
let hashOfPubKey = std::hash::keccak256(pub_key);
let mut result : Field = 0;
let mut v : Field = 1;
for i in 0..20 {
let index = (20 - i);
result += hashOfPubKey[index + 11] as Field * v;
v *= 256;
}
result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment