From 60b5b7032c7e38695b405ce50b4d65223b2fd0e3 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 16 Oct 2018 11:29:45 +0200 Subject: [PATCH] hasher: add HASHER_SAPLING_PREIMAGE --- hasher.c | 7 ++++++- hasher.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hasher.c b/hasher.c index b6564e8de..dfcb64a76 100644 --- a/hasher.c +++ b/hasher.c @@ -56,7 +56,10 @@ void hasher_Init(Hasher *hasher, HasherType type) { blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashOutputsHash", 16); break; case HASHER_OVERWINTER_PREIMAGE: - blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSigHash\x19\x1b\xa8\x5b", 16); // BRANCH_ID = 0x5ba81b19 + blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSigHash\x19\x1b\xa8\x5b", 16); // BRANCH_ID = 0x5ba81b19 / Overwinter + break; + case HASHER_SAPLING_PREIMAGE: + blake2b_InitPersonal(&hasher->ctx.blake2b, 32, "ZcashSigHash\xbb\x09\xb8\x76", 16); // BRANCH_ID = 0x76b809bb / Sapling break; } } @@ -90,6 +93,7 @@ void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length) { case HASHER_OVERWINTER_SEQUENCE: case HASHER_OVERWINTER_OUTPUTS: case HASHER_OVERWINTER_PREIMAGE: + case HASHER_SAPLING_PREIMAGE: blake2b_Update(&hasher->ctx.blake2b, data, length); break; } @@ -134,6 +138,7 @@ void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]) { case HASHER_OVERWINTER_SEQUENCE: case HASHER_OVERWINTER_OUTPUTS: case HASHER_OVERWINTER_PREIMAGE: + case HASHER_SAPLING_PREIMAGE: blake2b_Final(&hasher->ctx.blake2b, hash, 32); break; } diff --git a/hasher.h b/hasher.h index 7e748bf8e..e008efdef 100644 --- a/hasher.h +++ b/hasher.h @@ -54,6 +54,7 @@ typedef enum { HASHER_OVERWINTER_SEQUENCE, HASHER_OVERWINTER_OUTPUTS, HASHER_OVERWINTER_PREIMAGE, + HASHER_SAPLING_PREIMAGE, } HasherType; typedef struct { @@ -64,7 +65,7 @@ typedef struct { SHA3_CTX sha3; // for HASHER_SHA3{,K} BLAKE256_CTX blake; // for HASHER_BLAKE{,D} GROESTL512_CTX groestl; // for HASHER_GROESTLD_TRUNC - BLAKE2B_CTX blake2b; // for HASHER_OVERWINTER_* + BLAKE2B_CTX blake2b; // for HASHER_OVERWINTER_*, HASHER_SAPLING_* } ctx; } Hasher;