2019-02-05 14:01:10 +02:00
|
|
|
import
|
2020-04-18 10:17:59 +02:00
|
|
|
stew/byteutils,
|
2021-04-06 13:33:24 +02:00
|
|
|
./trie_defs
|
2019-02-05 14:01:10 +02:00
|
|
|
|
2022-09-02 16:57:52 +02:00
|
|
|
export trie_defs
|
|
|
|
|
2019-02-05 14:01:10 +02:00
|
|
|
template checkValidHashZ*(x: untyped) =
|
|
|
|
when x.type isnot KeccakHash:
|
2019-03-13 23:15:26 +01:00
|
|
|
doAssert(x.len == 32 or x.len == 0)
|
2019-02-05 14:01:10 +02:00
|
|
|
|
2020-04-20 20:14:39 +02:00
|
|
|
template isZeroHash*(x: openArray[byte]): bool =
|
2019-02-05 14:01:10 +02:00
|
|
|
x.len == 0
|
|
|
|
|
|
|
|
proc hashFromHex*(bits: static[int], input: string): MDigest[bits] =
|
2020-04-18 10:17:59 +02:00
|
|
|
MDigest(data: hexToByteArray[bits div 8](input))
|
2019-02-05 14:01:10 +02:00
|
|
|
|
|
|
|
template hashFromHex*(s: static[string]): untyped = hashFromHex(s.len * 4, s)
|