diff --git a/implementations/Libp2pComponent.ts b/implementations/Libp2pComponent.ts index ef26d2b..9364cfb 100644 --- a/implementations/Libp2pComponent.ts +++ b/implementations/Libp2pComponent.ts @@ -218,11 +218,9 @@ export class Libp2pComponent implements ILibp2pComponent { tcpPort: this.options.config?.tcpPort, wsPort: this.options.config?.wsPort, // Convert Uint8Array to base64 for passing to native module - keypair: this.options.keypair - ? { - privateKey: btoa(String.fromCharCode(...this.options.keypair.privateKey)), - publicKey: btoa(String.fromCharCode(...this.options.keypair.publicKey)), - } + // Using Buffer.from for proper encoding of binary data + privateKey: this.options.keypair?.privateKey + ? Buffer.from(this.options.keypair.privateKey).toString('base64') : undefined, };