Skip to content

Commit

Permalink
chore: prefer Buffer in node
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 24, 2023
1 parent e63bf0f commit 21a4718
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/crypto/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 21a4718

Please sign in to comment.