From 21a47189fa85af7e9bc1d55c1066727883bb0993 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 24 Nov 2023 09:49:21 +0000 Subject: [PATCH] chore: prefer Buffer in node --- src/crypto/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/crypto/index.ts b/src/crypto/index.ts index 64e1678..946799c 100644 --- a/src/crypto/index.ts +++ b/src/crypto/index.ts @@ -1,7 +1,6 @@ import crypto from 'node:crypto' import { newInstance, ChaCha20Poly1305 } from '@chainsafe/as-chacha20poly1305' import { digest } from '@chainsafe/as-sha256' -import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { isElectronMain } from 'wherearewe' import { pureJsCrypto } from './js.js' import type { KeyPair } from '../@types/libp2p.js' @@ -120,12 +119,12 @@ export const defaultCrypto: ICryptoInterface = { } }, generateX25519SharedKey (privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array { - publicKey = uint8ArrayConcat([ + publicKey = Buffer.concat([ X25519_PREFIX, publicKey ], X25519_PREFIX.byteLength + publicKey.byteLength) - privateKey = uint8ArrayConcat([ + privateKey = Buffer.concat([ PKCS8_PREFIX, privateKey ], PKCS8_PREFIX.byteLength + privateKey.byteLength)