I am trying to convert the following Kotlin code into NodeJS so that the Kotlin application can also communicate with the server. I unfortunately notice within CryptoJS that I can't get this to function fully. How can I use the function getSharedSecret and getAESKey in nodejs to get this script working?
Kotlin code: Kotlin ECC Encryption
This is my nodejs code so far - which is nothing special by the way:
var crypto = require('crypto');
const keyPairA = crypto.createECDH('secp521r1'); keyPairA.generateKeys();
const keyPairB = crypto.createECDH('secp521r1'); keyPairB.generateKeys();
const rawPrivateA = keyPairA.getPrivateKey('hex');
const rawPublicA = keyPairA.getPublicKey('hex', 'uncompressed');
const rawPrivateB = keyPairB.getPrivateKey('hex');
const rawPublicB = keyPairB.getPublicKey('hex', 'uncompressed');
console.log('rawPrivateA',rawPrivateA) console.log('rawPublicA',rawPublicA) console.log('---')
console.log('rawPrivateB',rawPrivateB)
console.log('rawPublicB',rawPublicB)
console.log('------------')
I've tried the derive function within nodejs but it keeps crashing the app.
Who can point me in the right direction for this?