Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Improve CID validation in Rust #48

Open
2 tasks
siman opened this issue Jul 21, 2020 · 2 comments
Open
2 tasks

Improve CID validation in Rust #48

siman opened this issue Jul 21, 2020 · 2 comments
Assignees
Milestone

Comments

@siman
Copy link
Member

siman commented Jul 21, 2020

Don't check for CID length, use cid lib:

https://github.com/multiformats/rust-cid#usage

use cid::Cid;
use std::convert::TryFrom;

let out = Cid::try_from(data).unwrap();
  • Update in pre-2
  • Update in rc4
@siman siman added this to the M4 (current) milestone Jul 21, 2020
@F3Joule
Copy link
Member

F3Joule commented Jul 22, 2020

Since rust-cid has no no_std support, there was suggested to custom verify CID's.
For CIDv0 verify length and .starts_with("Qm").
For CIDv1 extend with:

  • decode the hash to sha
  • check to see if it's a valid SHA-256

@F3Joule
Copy link
Member

F3Joule commented Jul 22, 2020

Check out deeper Substrate IPFS integration.
Useful link: Substrate-IPFS Tutorial

@subsocialdev subsocialdev modified the milestones: M4 (current), M5 Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants