From d5675062c1d3456d8c7992411363c54c928fdb81 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 20 Oct 2018 03:09:42 +1100 Subject: [PATCH] Add proof-of-possession hash fn --- beacon_chain/utils/hashing/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/beacon_chain/utils/hashing/src/lib.rs b/beacon_chain/utils/hashing/src/lib.rs index 8e2bd37a9..7c349e39d 100644 --- a/beacon_chain/utils/hashing/src/lib.rs +++ b/beacon_chain/utils/hashing/src/lib.rs @@ -6,3 +6,12 @@ pub fn canonical_hash(input: &[u8]) -> Vec { let result = blake2b(64, &[], input); result.as_bytes()[0..32].to_vec() } + +pub fn proof_of_possession_hash(input: &[u8]) -> Vec { + 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 +}