Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect multibase of a CID #15

Open
1 task
SimonLab opened this issue Jan 21, 2019 · 1 comment
Open
1 task

How to detect multibase of a CID #15

SimonLab opened this issue Jan 21, 2019 · 1 comment
Assignees

Comments

@SimonLab
Copy link
Member

Given a CID the first step when decoding the CID is to determine which multibase is used
see https://github.com/multiformats/multibase

The CID(v1) encode this information on the first byte (ie the first 8 bits), see https://github.com/multiformats/cid#decoding-algorithm where:

image

  • So the first step is to extract the first byte and to get a representation in hexadecimal. Then we can match with the multibase table to determine which encoding is used (the 0x is an indication to tell us that the text is in base16 which is hexadecimal)

image

@SimonLab SimonLab self-assigned this Jan 21, 2019
@SimonLab
Copy link
Member Author

Knowing the encoding is in fact simple.

  • Get the first byte/letter
  • match this first letter with the multibase table with the code column
  • check the encoding column

see
image

SimonLab added a commit that referenced this issue Jan 22, 2019
@SimonLab SimonLab mentioned this issue Jan 22, 2019
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant