Skip to content

Commit 845bbfc

Browse files
chore: use 256 bits
1 parent 9b71499 commit 845bbfc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/rln/src/utils/bytes.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ export function writeUIntLE(
5656
return buf;
5757
}
5858

59-
/**
60-
* Transforms Uint8Array into BigInt
61-
* @param array: Uint8Array
62-
* @returns BigInt
63-
*/
6459
export function buildBigIntFromUint8Array(
6560
array: Uint8Array,
6661
byteOffset: number = 0
6762
): bigint {
68-
const dataView = new DataView(array.buffer);
69-
return dataView.getBigUint64(byteOffset, true);
63+
// Use all bytes from byteOffset to the end, little-endian
64+
let hex = "";
65+
for (let i = array.length - 1; i >= byteOffset; i--) {
66+
hex += array[i].toString(16).padStart(2, "0");
67+
}
68+
return BigInt("0x" + hex);
7069
}
7170

7271
/**

0 commit comments

Comments
 (0)