eosjs icon indicating copy to clipboard operation
eosjs copied to clipboard

can't get the same publickey from api.signatureProvider.getAvailableKeys() as cleos

Open clockknock opened this issue 8 years ago • 2 comments

Version of EOSJS ^20.0.0-beta1

Describe the bug when i using the api.signatureProvider.getAvailableKeys() with default private key 5KPRRKtJmKEcVifeLd8mGGdtKP855HDDQ97sWG1wM4EGCDpyB8m,it retrurns PUB_K1_8QPw89hqrzohK6gKTHG8bVCte3thbwceE7rFN25k8GdPhTY43L,but when i use cleos wit h command cleos wallet private_keys,i can get :

[
    "EOS8QPw89hqrzohK6gKTHG8bVCte3thbwceE7rFN25k8GdPgsBJuu",
    "5KPRRKtJmKEcVifeLd8mGGdtKP855HDDQ97sWG1wM4EGCDpyB8m"
  ]

the last few chars from these two string are diffrent. and i can get right account names from RPC with the cleos publickey, but the publickey from eosjs can not. have i do something wrong?

public key from eosjs:

PUB_K1_8QPw89hqrzohK6gKTHG8bVCte3thbwceE7rFN25k8GdPhTY43L from_eosjs

public key from cleos:

EOS8QPw89hqrzohK6gKTHG8bVCte3thbwceE7rFN25k8GdPgsBJuu from_cleos

using the key from eosjs to get account names:

js_publickey

using the key from cleos to get account names:

cl_publickey

clockknock avatar Oct 20 '18 05:10 clockknock

K1 Public keys have two different ascii representations of the same underlying binary data. The EOS prefix is the prefix for the legacy format. The /v1/ rpc api uses it for backwards compatibility. Future rpc apis won’t produce that format. The PUB_K1_ prefix is the prefix for the current format. The checksum bytes at the end are different. Both the /v1/ api and eosjs2 understand either format on input.

tbfleming avatar Oct 20 '18 16:10 tbfleming

K1 Public keys have two different ascii representations of the same underlying binary data. The EOS prefix is the prefix for the legacy format. The /v1/ rpc api uses it for backwards compatibility. Future rpc apis won’t produce that format. The PUB_K1_ prefix is the prefix for the current format. The checksum bytes at the end are different. Both the /v1/ api and eosjs2 understand either format on input.

Wow!got it!perhaps the PUB_K1_prefix i used at first time has something wrong,i try it agian and it works, thanks a lot 😄 😄

clockknock avatar Oct 22 '18 02:10 clockknock