4

Let's say I have a public key hash, is it possible to get the address corresponding to that hash using the CLI?

1
  • An address is made of of 3 components: Network + Payment Credentials/ Validator Credentials + Optional Staking Credentials (can be StakeValidator Hash or StakingKeys).
    – Will
    Commented Apr 15, 2022 at 6:38

2 Answers 2

2

No, as that would sort of defeat the purpose of having a key hash in the first place (Hashing is, by definition, a one-way operation). Also, addresses can be built using different combinations of payment and staking keys, so a single key hash can be indicative of a key with ownership over multiple addresses.

1
  • 1
    In the question it is assumed that we have an pubkeyhash. If we look at the defenition of an address it consists of a credential and maybe a stakingcredential. The former is in the case of a normal shelley address given by a pubkeyHash. If it is a script, then its the validator hash. So it is definitly possible to construct an address from a pubkeyhash. What is not possible is deriving the pubkey from the pubkeyhash (as you state). See playground.plutus.iohkdev.io/doc/haddock/plutus-ledger/html/…
    – Fermat
    Commented Apr 14, 2022 at 18:39
0

You might want to investigate cardano-serialization-lib or cardano-addresses for this.

echo addr1gqtnpvdhqrtpd4g424fcaq7k0ufuzyadt7djygf8qdyzevuph3wczvf2dwyx5u | ./cardano-address address inspect

{
"stake_reference": "by pointer",
"spending_key_hash_bech32": "addr_vkh1zuctrdcq6ctd29242w8g84nlz0q38t2lnv3zzfcrfqktx0c9tzp",
"pointer": {
    "slot_num": 24157,
    "output_index": 42,
    "transaction_index": 177
},
"address_style": "Shelley",
"spending_key_hash": "1730b1b700d616d51555538e83d67f13c113ad5f9b22212703482cb3",
"network_tag": 0 }

But that is a movement in an opposite direction, getting a pkh from address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.