Improve CID validation in Rust
siman opened this issue · 2 comments
siman commented
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
F3Joule commented
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 commented
Check out deeper Substrate IPFS integration.
Useful link: Substrate-IPFS Tutorial