RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
37 stars 13 forks source link

How are public keys encoded? #58

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago

If my public key is hyper://sw8dj5y9cs5nb8dzq1h9tbjt3b4u3sci6wfeckbsch9w3q7amipy/, I am able to successfully send requests to hyper://sw8dj5y9cs5nb8dzq1h9tbjt3b4u3sci6wfeckbsch9w3q7amipb/ (the final character y replaced with b) as if I had send those requests to my actual public key.

Is this behavior expected?

RangerMauve commented 1 year ago

The encoding uses z32 https://github.com/mafintosh/z32

Not sure whether the last byte can be encoded differently.

josephmturner commented 1 year ago

According to Mathias, this behavior is expected "because each char is 5bits so you are changing bits that are ignored when decoding as it’s truncated". All good!