[IPLD] CID for Stellar objects / custom binary types?

My goal is to store all the XDR representing each ledger (aka blocks) and each transaction in IPFS via an IPLD resolver, similar to https://github.com/ipld/js-ipld-ethereum. The problem I’m having is that I’m not sure what multiformats need to be added (if any), given that the hashes within these XDR objects are themselves base32 and “stellar-key” encoded before being written into and linked to each ledger.

I can see that a CID is <multibase-prefix><cid-version><multicodec-content-type><multihash-content-address> of some given content.

In the Stellar-verse:

  • the base objects are all stored as XDR
  • the hashes (used when referencing transactions or ledger headers) of any XDR objects are encoded like this:
    base32(<version-byte><raw-data><CRC16-XModem-checksum>). As you can see here, the version-byte in base32 is either a:
    • G for ed25519 public keys
    • S for ed25519 secret seeds
    • T for pre-authorized transactions
    • or X for SHA2-256 hashes

My questions are:

  • Do I need to write an equivalent of https://github.com/ipld/js-ipld-dag-cbor for XDR?
  • Do I need a new multihash (to represent the encoded hashes)?
  • Do I need a new multicodec for each version-byte, or can one that encompasses the 4 types of stellar-keys be enough?
  • Do I need a new multicodec for each hash-linkable XDR object?

Any help would be appreciated!

2 Likes

This is an interesting idea. I am actually looking into using IPFS for the history archive itself. That should be rather straightforward though as it is stored in JSON.

Sorry for the long delay.

I would say rather something like js-ipld-ethereum or js-ipls-bitcoin (the Bitcoin implementation is a bit simpler).

Yes

I don’t know, someone with more experience needs to answer this.

I don’t understand that question.

1 Like