-
Notifications
You must be signed in to change notification settings - Fork 461
Eosjs-ecc produced different signature comparing to eos with same parameters #121
Comments
Since I am signing only a 32-bit zero array, so this problem is surely not relative to ABI, structs or something else. |
Do you know of a easy way to run c++ code like you provided outside of the eos source tree? Every-time I hack something in eos source tree I end up deleting it or loosing it in my git stashes .. lol |
@jcalfee Why you want to run it out of the source tree? You can easily restore your code via git so you can just paste the code to eos's source code. Anyone who know the reason of the topic? Thanks. |
Have a look over here: |
@jcalfee Thanks. I know EOS use special technology to make the signature "canonical ", but I have read the code in while (true) {
ecsignature = ecdsa.sign(curve, dataSha256, privateKey.d, nonce++);
der = ecsignature.toDER();
console.log("der: " + der.toString('hex'))
lenR = der[3];
lenS = der[5 + lenR];
if (lenR === 32 && lenS === 32) {
i = ecdsa.calcPubKeyRecoveryParam(curve, e, ecsignature, privateKey.toPublic().Q);
i += 4; // compressed
i += 27; // compact // 24 or 27 :( forcing odd-y 2nd key candidate)
break;
}
if (nonce % 10 === 0) {
console.log("WARN: " + nonce + " attempts to find canonical signature");
}
} It seems to be fantastic. But the signature it returns is not the same as EOS chain does. So why is it? It is really strange. |
For example, when i signed 32-bit zeros, EOS produces Anyone who has ideas about this? |
Moving this ticket to here => EOSIO/eosjs-ecc#20 Transaction uniqueness is checked on the unsigned transaction, not the signed transaction. Additionally @arhag points out there are extra checks for superfluous signatures protecting bandwidth. So I will not re-add the high-priority label. That said, we do intend to closely followed RFC 6979 signature algorithm. |
Update license year 2021 - develop
I found eosjs-ecc will produce different signature with same data and same private key.
For example, when I generate signatures for byte[32] which is filled with zero from
EOS
like this (the private key below is just for test so it is safe to post it):And the output is different from generating signatures with same parameters from
eosio-ecc
:So I can not use the signature to call APIs of EOS. What is the problem?
PS: I have confirmed the signature signed by
eosjs-ecc
can be virefied succesful byverifyHash
as follow:The text was updated successfully, but these errors were encountered: