mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-05-05 20:29:26 +00:00
chore: use big endian instead of little endian
This commit is contained in:
parent
682377cd50
commit
f70cc56322
@ -65,8 +65,16 @@ export function buildBigIntFromUint8Array(
|
|||||||
array: Uint8Array,
|
array: Uint8Array,
|
||||||
byteOffset: number = 0
|
byteOffset: number = 0
|
||||||
): bigint {
|
): bigint {
|
||||||
const dataView = new DataView(array.buffer);
|
// Convert byte array to BigInt in big-endian format (to match nwaku)
|
||||||
return dataView.getBigUint64(byteOffset, true);
|
let result = 0n;
|
||||||
|
// Process all 32 bytes (or the available bytes if less)
|
||||||
|
const length = Math.min(array.length - byteOffset, 32);
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
result = (result << 8n) | BigInt(array[byteOffset + i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user