paulmillr / micro-key-producer

Produces secure keys and passwords. Supports SSH, PGP, BLS, OTP and many other formats
MIT License
34 stars 9 forks source link

ipns address #10

Closed 0xc0de4c0ffee closed 1 year ago

0xc0de4c0ffee commented 1 year ago

resolves #9

I've some questions commented out on codes for review 🙏

paulmillr commented 1 year ago

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 commented 1 year ago

That base36 implementation doesn't seem right.

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

0xc0de4c0ffee commented 1 year ago

Check this CID explorer

https://cid.ipfs.tech/#k51qzi5uqu5dhhcu1pop9pynjg2g3l6vrlt379x6huzy2zhyg54o1u6csnuwi3 https://cid.ipfs.tech/#bafzaajaiaejcaewifgpmfri57654wt47zsw45ykcjszdp2ntbu6nolkhygaqg2e5

0xc0de4c0ffee commented 1 year ago

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 commented 1 year ago

it's not radix2 -- it's radix

for padding maybe no padding

0xc0de4c0ffee commented 1 year ago

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 commented 1 year ago

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

paulmillr commented 1 year ago

thanks @0xc0de4c0ffee