How to convert public key string to eosio::public_key type in the system contract?
I have a public key string, but I don't know how to convert eosio::public_key type in the system contract
You can take a look at function DecodeBase58 in /eos/libraries/fc/src/crypto/base58.cpp to convert the public key string into binary format. However, porting the big math library into smart contract doesn't seem to be a good idea. I guess a better way is to convert the public key into binary format off-chain then push its hex format as data into smart contract, so that you only need a simple conversion from hex string to binary in your smart contract. So, public key string(base58) => binary => hex string(base 16) => push into smart contract => binary
You can take a look at function
DecodeBase58in/eos/libraries/fc/src/crypto/base58.cppto convert the public key string into binary format. However, porting the big math library into smart contract doesn't seem to be a good idea. I guess a better way is to convert the public key into binary format off-chain then push its hex format as data into smart contract, so that you only need a simple conversion from hex string to binary in your smart contract. So,public key string(base58) => binary => hex string(base 16) => push into smart contract => binary
Can be converted to eosio::public_key type?
Yes. eosio::public_key includes a constructor explicit public_key(const string& base58str); which invokes ``std::vectorwhich invokesinline bool DecodeBase58(const char* psz, std::vector
Note that eosio::public_key is not provided by eosiolib, so you will need to copy it into your contract as well.
If you still need help and wish to discuss further, please post it in https://eosio.stackexchange.com. To keep things organized, Github issues are intended for bug reporting and feature tracking, and Stack Exchange is the right place for any technical support discussions. Thanks!