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