I want to do this inside a precompile, so it is runtime and I don't have access to std.
1 Answer
Yes, you can convert an address in SS58 format into the 32-byte public key. The process of encoding a public key to an SS58 format address is fully reversible since it just implies adding a prefix, a checksum and a bidirectional encoding of the bytes (like in Bitcoin's base-58).
The tool Subkey allows you to get the SS58 address from the public key and viceversa. This is done with the command:
subkey inspect --public < pubkey | address >
Finally, you can do this "manually" with the account transformation tool provided by Subscan. And there are some public tools to do this conversion but they may not be fully tested and maintained.
-
-
Good point. I would say the important part here is the first paragraph in my answer. For proper implementation of the encoding function they can check this other answer for guidance and implement their own in the precompile: substrate.stackexchange.com/questions/2311/…– IkerCommented Mar 20, 2023 at 11:26