From 56e597187ea956e47716f57181d30029e577a276 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 26 Sep 2018 23:30:24 +0800 Subject: [PATCH 1/2] Added Appendix A - Hash function --- specs/casper_sharding_v2.1.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/specs/casper_sharding_v2.1.md b/specs/casper_sharding_v2.1.md index 100073300..8bd1f8fb9 100644 --- a/specs/casper_sharding_v2.1.md +++ b/specs/casper_sharding_v2.1.md @@ -441,5 +441,14 @@ Slashing conditions may include: Proof of custody no secret reveal RANDAO leak +# Appendix +## Appendix A - Hash function +The general hash function `hash(x)` in this specification is defined as: + +`hash(x) := BLAKE2b(x)[0:32]`, where `BLAKE2b` algorithm is deifned in [RFC7693](https://tools.ietf.org/html/rfc7693) and input `x` is bytes type. + +* The output of *default* `BLAKE2b` algorithm is a 64-byte type. To get a 32-byte result, the general hash function output is defined as the leftmost 32 bytes of `BLAKE2b` hash output. +* The design rationale is keeping using the default algorithm and avoiding too much dependency on external hash function libraries. + ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). From e5af9ba2548e9f515ca3ecff489513504574ad66 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 27 Sep 2018 19:58:38 +0800 Subject: [PATCH 2/2] PR feedback --- specs/casper_sharding_v2.1.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/casper_sharding_v2.1.md b/specs/casper_sharding_v2.1.md index 8bd1f8fb9..cd36fb23b 100644 --- a/specs/casper_sharding_v2.1.md +++ b/specs/casper_sharding_v2.1.md @@ -445,9 +445,9 @@ Slashing conditions may include: ## Appendix A - Hash function The general hash function `hash(x)` in this specification is defined as: -`hash(x) := BLAKE2b(x)[0:32]`, where `BLAKE2b` algorithm is deifned in [RFC7693](https://tools.ietf.org/html/rfc7693) and input `x` is bytes type. +`hash(x) := BLAKE2b-512(x)[0:32]`, where `BLAKE2b-512` (`blake2b512`) algorithm is defined in [RFC 7693](https://tools.ietf.org/html/rfc7693) and input `x` is bytes type. -* The output of *default* `BLAKE2b` algorithm is a 64-byte type. To get a 32-byte result, the general hash function output is defined as the leftmost 32 bytes of `BLAKE2b` hash output. +* `BLAKE2b-512` is the *default* `BLAKE2b` algorithm with 64-byte digest size. To get a 32-byte result, the general hash function output is defined as the leftmost `32` bytes of `BLAKE2b-512` hash output. * The design rationale is keeping using the default algorithm and avoiding too much dependency on external hash function libraries. ## Copyright