From d30a918a44fb1198d7025cd5c58349f789b3ce3d Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 5 May 2022 10:30:25 +1000 Subject: [PATCH] Fix odd case where 0 is encoded as an empty byte array --- src/lib/enr/enr.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/enr/enr.ts b/src/lib/enr/enr.ts index 049ece3f95..bea1e0bf42 100644 --- a/src/lib/enr/enr.ts +++ b/src/lib/enr/enr.ts @@ -88,7 +88,9 @@ export class ENR extends Map { dbg("Failed to decode ENR key to UTF-8, skipping it", kvs[i], e); } } - const enr = new ENR(obj, BigInt("0x" + bytesToHex(seq)), signature); + // If seq is an empty array, translate as value 0 + const hexSeq = "0x" + (seq.length ? bytesToHex(seq) : "00"); + const enr = new ENR(obj, BigInt(hexSeq), signature); const rlpEncodedBytes = hexToBytes(RLP.encode([seq, ...kvs])); if (!enr.verify(rlpEncodedBytes, signature)) {