How to pass shelly address to binary format?

The document at https://hydra.iohk.io/build/3553697/download/1/ledger-spec.pdf explains the content of the different binary addresses but I haven’t able to extract that information from an address like this one:

addr1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5eg0yu80w

This is an enterprise addres that should contain 29 bytes but I don’t know how to extract these bytes from the 59 bytes addres string above. I have tried decoding in some different ways without any success.

Does anybody know how to decode the new cardano addresses?

Use the bech32 or the cardano-address utilities comes from the cardano-wallet package see here https://github.com/input-output-hk/cardano-wallet/releases

1 Like

I tried that but when “addr1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5eg0yu80w” is decoded the result is 47 bytes long instead 29:

[“addr”, [12, 1, 28, 20, 12, 31, 3, 9, 21, 6, 22, 6, 12, 10, 0, 1, 14,
19, 8, 9, 26, 24, 18, 23, 11, 14, 20, 21, 10, 29, 4, 11, 4, 7, 15, 12,
7, 13, 4, 3, 21, 5, 3, 9, 20, 25, 8]]

For bech32 each number at returned array represents 5bits. So 5 * 47 = 235bits
The size the result should give is 29 bytes = 232bits. As 232/5 is 46.4 (it has a decimal part) the last 3 bits should be ignored

Cos you decoded it as base32 and not base64

$ echo addr1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5eg0yu80w| ./cardano-address address inspect
{
    "stake_reference": "none",
    "address_style": "Shelley",
    "spending_key_hash": "79467c69a9ac66280174d09d62575ba955748b21dec3b483a9469a65",
    "network_tag": 0
}
$ echo 79467c69a9ac66280174d09d62575ba955748b21dec3b483a9469a65 | wc -c 
57

$ echo addr1vpu5vlrf4xkxv2qpwngf6cjhtw542ayty80v8dyr49rf5eg0yu80w | ./bech32
6079467c69a9ac66280174d09d62575ba955748b21dec3b483a9469a65

60 means enterprise address the 79.... is the hash28 of the payment verification key.
And the public key is only revealed/exposed when it is used as witness of an UtxO in an input of a tx.

Means blake2b_224 hash of the public key which is expected.

1 Like