Add proof-of-possession hash fn

This commit is contained in:
Paul Hauner 2018-10-20 03:09:42 +11:00
parent f00b39dd3c
commit d5675062c1
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -6,3 +6,12 @@ pub fn canonical_hash(input: &[u8]) -> Vec<u8> {
let result = blake2b(64, &[], input);
result.as_bytes()[0..32].to_vec()
}
pub fn proof_of_possession_hash(input: &[u8]) -> Vec<u8> {
let result = blake2b(64, &[], input);
let mut hash = result.as_bytes()[32..64].to_vec();
// TODO: this padding is not part of the spec, it is required otherwise Milagro will panic.
// We should either drop the padding or ensure the padding is in the spec.
hash.append(&mut vec![0; 18]);
hash
}