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
Projects
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 created this issue from a note in M4, M5 (Bugs) Jul 21, 2020
@siman siman added this to the M4 (current) milestone Jul 21, 2020
@F3Joule F3Joule moved this from Bugs to In progress in M4, M5 Jul 22, 2020
@F3Joule F3Joule moved this from In progress to Bugs in M4, M5 Jul 22, 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
@subsocialdev subsocialdev removed this from Bugs in M4, M5 Nov 6, 2020
@subsocialdev subsocialdev added this to To do in Backlog via automation Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Backlog
  
To do
Development

No branches or pull requests

3 participants