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

IPFS addrs should use multihashes, not CIDs. #9

Open
Stebalien opened this issue Jul 17, 2018 · 10 comments
Open

IPFS addrs should use multihashes, not CIDs. #9

Stebalien opened this issue Jul 17, 2018 · 10 comments

Comments

@Stebalien
Copy link
Member

The QmId part is actually just a bare base58 encoded multihash (for now). It's a direct hash of the peer's public key.

@ianopolous
Copy link
Member

I assume you mean "Ipfs addrs should use Cids, not Multihashes"? And are you referring to the constructor?
In Java we've made Cid a subclass of Multihash, consistent with the v0-v1 move. So I think it is correct.

@Stebalien Stebalien changed the title IPFS addrs should't use multihash's, not CIDs. IPFS addrs should use CIDs, not multihashes Aug 7, 2018
@Stebalien Stebalien changed the title IPFS addrs should use CIDs, not multihashes IPFS addrs should use multihashes, not CIDs. Aug 7, 2018
@Stebalien
Copy link
Member Author

I assume you mean

Wow, that title was a train wreck.


But no, I meant multihases. The QmId in /ipfs/QmId... (or /p2p/QmId, the new version) is not a CID, it's a raw multihash. We have plans to make it a CID but have to think carefully about the upgrade path because, as it is, QmId... is a valid v0 CID but the "object" it points to (is a hash of) is a libp2p-crypto public key, not a merkledag node.

@ianopolous
Copy link
Member

What about things like
https://ipfs.io/ipfs/zDMZof1kyVsgbhuNGjcSNSEeKTsgxsA3MArZm7BAogkC1iGRixef
I thought the part after the domain is a multiaddr?

@ianopolous
Copy link
Member

As it stands the Java constructor for a Multiaddr already takes a Multihash (which could be a Cid or not)

@Stebalien
Copy link
Member Author

What about things like
https://ipfs.io/ipfs/zDMZof1kyVsgbhuNGjcSNSEeKTsgxsA3MArZm7BAogkC1iGRixef
I thought the part after the domain is a multiaddr?

It's a path. Multiaddrs are for network/process addresses.


As it stands the Java constructor for a Multiaddr already takes a Multihash (which could be a Cid or not)

Note: arbitrary multihashes aren't valid CIDv0. Really, CIDv0 is defined to be a 256bit long base58 encoded sha2-256 multihash. Unfortunately, allowing arbitrary multihashes would cause conflicts with some multibase prefixes.

@ianopolous
Copy link
Member

Not allowing Cids here is a problem, because Cid is a Multihash in Java (which I think was the right choice). And changing that is a significant rework of many projects. If you're going to upgrade to allow Cids, then we can just wait for that.

@Stebalien
Copy link
Member Author

A CID may contain a multihash but they aren't the same thing (a CID isn't a type of multihash). Regardless, while we'll eventually likely allow CIDs in /ipfs/ multiaddrs, a /ipfs/ multiaddr is not the same thing as an /ipfs/ path.

@ianopolous
Copy link
Member

I'm aware of that. I'm saying that I chose to make the Cid class a subclass of Multihash, so in Java a Cid is a Multihash in the type sense (This still seems like the right thing to do given my understanding of things).

To make things concrete, are there places in the http api (apart from things that take a multiaddr) where one can use a Multihash, but not a Cid?

@Stebalien
Copy link
Member Author

To make things concrete, are there places in the http api (apart from things that take a multiaddr) where one can use a Multihash, but not a Cid?

Currently, everything that expects a peer ID expects a raw sha2-256 multihash. However, those'll still technically look like CIDs.

The primary issue here is that we're switching /ip4/.../tcp/.../ipfs/QmId multiaddrs to /ip4/.../tcp/.../p2p/QmId as the former is confusing (e.g., the issue here) and implies some relation to ipfs (which makes no sense when implementing other libp2p apps).

I'm aware of that. I'm saying that I chose to make the Cid class a subclass of Multihash, so in Java a Cid is a Multihash in the type sense (This still seems like the right thing to do given my understanding of things).

That's probably fine, for now at least. However, I can't guarantee that that'll always hold true. For example, I've considered CIDs with multiple multihashes (probably too big but still valid in theory).

@ianopolous
Copy link
Member

We don't have a concept of peerId yet in Java so I suspect all those methods (equivalently) take MultiAddress in Java.

Switching to p2p sounds like a very good idea.

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

2 participants