paulmillr / noble-ed25519

Fastest 4KB JS implementation of ed25519 signatures
https://paulmillr.com/noble
MIT License
420 stars 51 forks source link

Can someone help me with the getSharedSecret function? #72

Closed gitmachtl closed 1 year ago

gitmachtl commented 1 year ago

Can someone tell me what i am doing wrong here in nodejs?

const ed25519 = require('@noble/ed25519');
const prvKey = Uint8Array.from(Buffer.from('e8ddb1cfc09e163915e6c28fcb5fbb563bfef57201857e15288b67abbd91e444','hex'))
console.log(prvKey)

const pubKey = Uint8Array.from(Buffer.from('57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0','hex'))
console.log(pubKey)

function sharedSecret(prvKey,pubKey) {
 return ed25519.getSharedSecret(prvKey,pubKey)
     .then(result => {
             console.log(result); // Logs the result
             return response;
             }
           );
}
console.log(sharedSecret(prvKey,pubKey)); 

I always get Promise { <pending> } as the output.

Best regards, Martin

paulmillr commented 1 year ago

You have two logs. See how promises work.