Recently, I was trying to do something with the code of ECDSA. I want to change the key length of it but in vain. I checked the internet and found some source code of ECDSA, but somehow it only allows 32 bytes.
For example, I found this:
var crypto = require("crypto");
var eccrypto = require("eccrypto");
// A new random 32-byte private key.
var privateKey = crypto.randomBytes(32);
// Corresponding uncompressed (65-byte) public key.
var publicKey = eccrypto.getPublic(privateKey);
var str = "message to sign";
// Always hash you message to sign!
var msg = crypto.createHash("sha256").update(str).digest();
eccrypto.sign(privateKey, msg).then(function(sig) {
console.log("Signature in DER format:", sig);
eccrypto.verify(publicKey, msg, sig).then(function() {
console.log("Signature is OK");
}).catch(function() {
console.log("Signature is BAD");
});
});
from this website. I tried to change the privateKey from 32 bytes to 16 bytes and other values. It ended up giving me errors.
Recently I discovered that to have different key length you need different curves. Does anybody know how to change the curve in the above code? If not, would someone provide source code that can use different key lengths of ECDSA?
(I'm quite new to ECC, so if I used wrong terms or I completely misunderstood the concept of it, please forgive).