You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Describe the bug
sign() function in eosjs-ecc-migration returns wrong signature (basically Signature.sign()) in the browser. The signature can be verified by eosjs correctly but verification fails in the old eosjs-ecc module or in a smart contract, so it seems wrong.
To Reproduce
Steps to reproduce the behavior:
Private Key: PVT_K1_z6FmcRrEYH5MMK4Htfvo1y6cDf3MpnBkvTSmcBsr6KfaAoSXB
Signing value: pink
Expected and verifiable signature by eosjs-ecc: SIG_K1_KWejfkk6FefopiaSsfBJnjn2XK2L1zVBF5ZWaq3YkVpbmK2voCXDPcnKfm79RU12bepm7yDqit8xxZnFm3ydfTr5PReRsW
Actual signature: SIG_K1_KA1PzVjXmwaQApnrdaV7cZqoakGunT7jyNde3f9Fs759EtXCWGcWtLeSCmu5Dpzm4tTMy4gLZiavsY1DbbyGemx2M2k12u
Create signature with eosjs 21 (actual signature)
Verify / Recover signature in eosjs-ecc or a smart contract will fail
const{ecc}=require('eosjs/dist/eosjs-ecc-migration')consteccLegacy=require('eosjs-ecc')const{PrivateKey}=require('eosjs/dist/eosjs-jssig');constprivateKey=PrivateKey.fromString('PVT_K1_z6FmcRrEYH5MMK4Htfvo1y6cDf3MpnBkvTSmcBsr6KfaAoSXB');constpublicKey=privateKey.getPublicKey();constsigningValue='pink';constactualSignature=ecc.sign(signingValue,privateKey,'utf8');constexpectedSignature=eccLegacy.sign(signingValue,privateKey.toLegacyString(),'utf8');constactualRecoveredKey=eccLegacy.recover(actualSignature,signingValue,'utf8');constexpectedRecoveredKey=eccLegacy.recover(expectedSignature,signingValue,'utf8');// different keysconsole.log('Public Key',publicKey.toLegacyString());console.log('')console.log('Actual Recovered Key',actualRecoveredKey);console.log('Expected Recovered Key',expectedRecoveredKey);console.log('')// different signatures (not a problem in general but actual signature cant be verified)console.log('Actual Signature',actualSignature);console.log('Expected Signature',expectedSignature);
Version of EOSJS
21.0.2
Describe the bug
sign() function in eosjs-ecc-migration returns wrong signature (basically Signature.sign()) in the browser. The signature can be verified by eosjs correctly but verification fails in the old eosjs-ecc module or in a smart contract, so it seems wrong.
To Reproduce
Steps to reproduce the behavior:
Private Key: PVT_K1_z6FmcRrEYH5MMK4Htfvo1y6cDf3MpnBkvTSmcBsr6KfaAoSXB
Signing value: pink
Expected and verifiable signature by eosjs-ecc: SIG_K1_KWejfkk6FefopiaSsfBJnjn2XK2L1zVBF5ZWaq3YkVpbmK2voCXDPcnKfm79RU12bepm7yDqit8xxZnFm3ydfTr5PReRsW
Actual signature: SIG_K1_KA1PzVjXmwaQApnrdaV7cZqoakGunT7jyNde3f9Fs759EtXCWGcWtLeSCmu5Dpzm4tTMy4gLZiavsY1DbbyGemx2M2k12u
Environment