multiformats / cid

Self-describing content-addressed identifiers for distributed systems
Other
426 stars 79 forks source link

Create cid from signature #46

Closed golnarmordadi closed 2 years ago

golnarmordadi commented 3 years ago

I can not create a cid with signature of a signed message. Is it possible get cid from a signed message?

rvagg commented 3 years ago

It depends on how it's signed. CIDs include a "codec" identifier that says what the format is. If the codec is in https://github.com/multiformats/multicodec/blob/master/table.csv and you're hashing with one of the hash functions listed there then yes, you can make a CID for it. If the format and/or hash function are standard but not included in that table, then they could be added.

But it's this format thing that's the catch I think. If you're just doing GPG message signing then there's not really a format per se, it's all just raw data. But even there, you could make a CID that has a format raw, you're just not embedding the information "this is signed, and the signing data can be extracted in a particular way".

The DAG-JOSE IPLD codec has signing capabilities, it's a standard format that can wrap any kind of arbitrary data that conforms to the IPLD data model, has its own multicodec code and implementations in Go and JavaScript: https://ipld.io/specs/codecs/dag-jose/spec/ - it might serve your purpose?