node.js – crypto.generateKeyPairSync (‘ed25519’) does not check simple test, which an ‘ec’ key pair checks without problem. What is the error?

[ad_1]

I played with the crypto module in Nodejs and used crypto.generateKeyPairSync. When running a short verification test with “ec” keys it evaluates as expected, but when testing with generated keys “ed25519” it never returns true.

const crypto = require (‘crypto’) let identity = {} identity.identifierKeys__ = wait crypto.generateKeyPairSync (‘ec’, {namedCurve: ‘secp256k1’, // Options publicKeyEncoding: {type: ‘spki’, format: ‘pem ‘}, privateKeyEncoding: {type:’ pkcs8 ‘, format:’ pem ‘}}) identity.identifierKeys = wait crypto.generateKeyPairSync (‘ ed25519 ‘, {publicKeyEncoding: {type:’ spki ‘, format:’ pem ‘}, privateKeyEncoding: {type: ‘pkcs8’, format: ‘pem’}}) // console.log (identity.identifierKeys) // test keys let key = identity.identifierKeys__ // if I switch to .identifierKeys, don’t evaluate never true let msg = ‘testingInformation’ let v = wait crypto.createSign (‘SHA256’) v.write (msg) v.end () let sig = wait v.sign (key.privateKey, ‘base64’) let t = wait crypto .createVerify (‘SHA256’) t.write (msg) t.end () let r = wait t.verify (key.publicKey, sig, ‘base64’) console.log (sig) console.log (r )

Sources

1/ https://Google.com/

2/ https://stackoverflow.com/questions/70408080/crypto-generatekeypairsynced25519-does-not-verify-simple-test-which-an-ec

The mention sources can contact us to remove/changing this article

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts