mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-12 18:49:07 +00:00
hasher: add HASHER_SAPLING_PREIMAGE
This commit is contained in:
parent
2b7d9bd579
commit
60b5b7032c
7
hasher.c
7
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;
|
||||
}
|
||||
|
3
hasher.h
3
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user