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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipns address #10

Merged
merged 7 commits into from Jun 10, 2023
Merged

ipns address #10

merged 7 commits into from Jun 10, 2023

Conversation

0xc0de4c0ffee
Copy link
Contributor

@0xc0de4c0ffee 0xc0de4c0ffee commented May 28, 2023

resolves #9

  • missing base36 support
  • keygen only, missing IPNS records signing as it's more complicated using cbor.

I've some questions commented out on codes for review 馃檹


- [`ed25519-keygen/ssh`](#sshseed-username) for SSH key generation
- [`ed25519-keygen/pgp`](#pgpseed-user-password) for [RFC 4880](https://datatracker.ietf.org/doc/html/rfc4880) + [RFC 6637](https://datatracker.ietf.org/doc/html/rfc6637)
- [`ed25519-keygen/tor`](#torseed) for TOR onion addresses
- [`ed25519-keygen/ipns`](#ipnsseed) for IPNS addresses
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPNS (ed25519/libp2p-key)

src/ipns.ts Outdated
//b58/ old format, not recommended
//base58: `${base58.encode(pubKeyBytes)}`,
//b36/ subdomain safe,recommended, ??scure/base36?
//base36: `k${base36.encode(pubKeyBytes).toLowerCase()}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base36: k51qzi5uqu5dgnfwbc46une4upw1vc9hxznymyeykmg6rev1513yrnbyrwmmql

@paulmillr
Copy link
Owner

You can implement base36 by yourself. It should be straightforward, maybe 10 lines of code. Check out source code of scure-base for base32 implementation. It makes it really easy.

@paulmillr
Copy link
Owner

paulmillr commented May 29, 2023

That base36 implementation doesn't seem right.

See this: https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L283

@0xc0de4c0ffee
Copy link
Contributor Author

That base36 implementation doesn't seem right.

See this: https://github.com/paulmillr/scure-base/blob/b266c73dde977b1dd7ef40ef7a23cc15aab526b3/index.ts#L283

I tried scure-base but I'm not sure about radix2 and padding for base36?

base36 k active base36 [0-9a-z] case-insensitive - no padding
https://www.ietf.org/archive/id/draft-multiformats-multibase-04.html

const base36 = utils.chain(utils.radix2(<??>), utils.alphabet('0123456789abcdefghijklmnopqrstuvwxyz'), utils.padding(<??>), utils.join(''));

// throw new Error('radix2: bits should be in (0..32]');
// convertRadix2: invalid data word=35 from=5

@paulmillr
Copy link
Owner

it's not radix2 -- it's radix

for padding maybe no padding

* natspec + minor re-factoring

* linted + formatted

* formatted with prettier

* sync and stash

* compact comments & code

* reinstate ?question

* remove extra at top

* Use scure-base for base36

* Forgot to format

---------

Co-authored-by: 0xc0de4c0ffee <43116881+0xc0de4c0ffee@users.noreply.github.com>
@0xc0de4c0ffee
Copy link
Contributor Author

For future we'll try to explore multi-sig keys and full IPNS records signing features.

+I've learn more from scure-base as we need max optimized base-x encoder/decoder in Solidity contracts for our deeper ENS+IPFS integration. Our current base36 decoder function is ticking ~350k gas *(view only) without overflowing.
Base36 decoder : https://github.com/namesys-eth/ipfs2-eth-resolver/blob/main/src/IPFS2ETH.sol#L166
ENS based IPFS gateway : https://k51qzi5uqu5dhhcu1pop9pynjg2g3l6vrlt379x6huzy2zhyg54o1u6csnuwi3.ipfs2.eth.limo/

@0xc0de4c0ffee
Copy link
Contributor Author

0xc0de4c0ffee commented May 30, 2023

Err, sorry..
I mixed up pubkey with prefixed pubkeybytes, & then forgot to run test as it was simple one line edit. 馃檹

Update IPNS example
@paulmillr paulmillr merged commit 7273352 into paulmillr:main Jun 10, 2023
1 check passed
@paulmillr
Copy link
Owner

thanks @0xc0de4c0ffee

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

Successfully merging this pull request may close these issues.

IPNS keygen support
3 participants