Refactored keccak interface

- Allow calculating keccak hash in steps
- Only allow 32 and 200 byte final hashes
This commit is contained in:
SChernykh
2023-01-08 12:56:26 +01:00
parent 4f34c4466a
commit 632f3faac5
9 changed files with 58 additions and 31 deletions

View File

@@ -134,7 +134,7 @@ bool check_keys(const hash& pub, const hash& sec)
static FORCEINLINE void hash_to_scalar(const uint8_t* data, int length, uint8_t (&res)[HASH_SIZE])
{
keccak(data, length, res, HASH_SIZE);
keccak(data, length, res);
sc_reduce32(res);
}
@@ -416,7 +416,7 @@ void derive_view_tag(const hash& derivation, size_t output_index, uint8_t& view_
writeVarint(output_index, [&p](uint8_t b) { *(p++) = b; });
hash view_tag_full;
keccak(buf, static_cast<int>(p - buf), view_tag_full.h, HASH_SIZE);
keccak(buf, static_cast<int>(p - buf), view_tag_full.h);
view_tag = view_tag_full.h[0];
}