Skip to content

Implement an IPFS compatible CID function in Elixir using Multihash SHA256 #11

@nelsonic

Description

@nelsonic

This issue/epic is dedicated exclusively to How i.e. implementation

For the reasoning behind Why we are writing this code, please see: #1
If anything is unclear as to Why, please comment on that issue.
(we all need to be 100% clear on Why we are doing this work if you aren't, Ask Questions!)

Todo

  • Read the JavaScript Implementation of CID: https://github.com/multiformats/js-cid
    to understand how it works. If you have questions, please ask them in: https://github.com/dwyl/learn-ipfs/issues

    • try out any examples in the docs on localhost and try to see if re-ordering elements in an Object or nested Array produces a different CID.
    • Document the process of trying out the JS cid implementation.
      (i.e. this is for everyone to learn, not just the one person!)
  • Read the "not working" Elixir version: https://github.com/nocursor/ex-cid

    • See if it's "salvageable" or if we need to write our own implementation from scratch.

    (obviously my preference is to use a module someone else has invested time in,
    to avoid "fragmenting" the ecosystem, but if the author does not respond to issues requesting help, then I am not left with much choice ...
    😢)

  • Implement an "offline" version of CID in Elixir that produces the exact same CID as the JS version.

    • cid of a String should always be the same for a given string.
    • cid of a Map should work regardless of the order of content.

    The way I did this was to order the keys of the Map but we need to check the JS implementation to ensure that's how they have done it.

    • What other types of content do we want/need to create CIDs for? (can we add them later?!)

MVP CID v1

for our MVP we only need a sha2-256 hash in Base58BTC which is URL-safe.
For this we can use the code from https://github.com/multiformats/ex_multihash (which is maintained) and https://github.com/nocursor/b58 (which is unresponsive) respectively.

  • Write comprehensive doctests that demonstrate that the code works as expected.
  • Create beginner-friendly examples. (we can split this out into separate repos later!)
  • Re-org the Readme of this repo so the "theory" & reasoning is lower down
    • and the "get started in 1 minute" is at the top.
  • Publish to Hex.pm :shipit:
  • PR to https://github.com/multiformats/multibase

@RobStallion I apologise for using the expression "deep dive" to describe this quest.
I sometimes forget that certain expressions aren't widely used outside of the tech community. 😕
(and sadly, we don't yet have a comprehensive glossary of common tech expressions/terms ...)
https://en.wikipedia.org/wiki/Deep_diving just means "diving to a depth beyond the norm".
i.e. diving into the code/examples/docs beyond the superficial.
We need to deeply understand everything about IPFS CIDs so that we can create compatible Elixir-lang implementation that we can use to create cids for all our content.
Deeply understanding the JS/Go-lang CID code requires "Deep Work" youtu.be/ZD7dXfdDPfg
This is a prereq to writing a CMS, a Learning Platform and a Time/Task Management app!
i.e. this is a "foundational piece" for the entire future of @dwyl (#NoPressure...)

Relevant Reading

Help Wanted

We really need help on getting this package built, documented and shipped so we can move forward with our "stack" dwyl/technology-stack#67 and "roadmap" https://github.com/dwyl/product-roadmap
If you have the curiosity, energy and time to help, please comment below! (Thanks!)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions