mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Use swap method that works with react-native
This commit is contained in:
@@ -177,10 +177,14 @@ function bufferToArray(buf: Buffer): number[] {
|
||||
* @returns A buffer containing the same data with reversed endianness
|
||||
*/
|
||||
function swap128(buf: Buffer): Buffer {
|
||||
const result = Buffer.alloc(16)
|
||||
result.writeBigUInt64LE(buf.readBigUInt64BE(0), 8)
|
||||
result.writeBigUInt64LE(buf.readBigUInt64BE(8), 0)
|
||||
return result
|
||||
// Interprets buffer as an array of (two, in this case) 64-bit numbers and swaps byte order in-place.
|
||||
const reversedBytes = buf.swap64()
|
||||
|
||||
// Swap the two 64-bit numbers since our buffer is 128 bits.
|
||||
return Buffer.concat(
|
||||
[reversedBytes.slice(8, 16), reversedBytes.slice(0, 8)],
|
||||
16,
|
||||
)
|
||||
}
|
||||
|
||||
export { rfc1751MnemonicToKey, keyToRFC1751Mnemonic }
|
||||
|
||||
Reference in New Issue
Block a user