Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Key exchange with jsrsasign #115

Merged
merged 11 commits into from
Dec 20, 2017
Merged

Key exchange with jsrsasign #115

merged 11 commits into from
Dec 20, 2017

Conversation

richardschneider
Copy link
Contributor

@richardschneider richardschneider commented Dec 14, 2017

This uses the jsrsasign package to create password protected private keys.

Currently, it only works with RSA key types.

See issue #114

PR libp2p/js-libp2p-keychain#18 is dependent upon this PR

@ghost ghost added the status/in-progress In progress label Dec 14, 2017
@richardschneider
Copy link
Contributor Author

@richardschneider richardschneider changed the title Key exchange jsrsasign Key exchange with jsrsasign Dec 14, 2017
mBdkD5r+ixWF174naw53L8U9wF8kiK7pIE1N9TR4USEeovLwX6Ni/2MMDZedOfof
2f77eUdLsK19/5/lcgAAYaXauXWhy2d2r3SayFrC9woy0lh2VLKRMBjcx1oWb7dp
0uxzo5Y=
-----END ENCRYPTED PRIVATE KEY-----
Copy link
Member

Choose a reason for hiding this comment

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

Can you put these in files as text data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure can, but why? They are only used in one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to use fs to read the file. Or wrap them in module.export with back tick and then require them.

Copy link
Member

Choose a reason for hiding this comment

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

You can have a file with these pem keys and do fs.readFileSync once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can do. But why. Tests should be easy to read. Why the indirection and requiring file support.

Will fs.readFileSync be supported in browser tests?

Copy link
Member

Choose a reason for hiding this comment

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

@richardschneider fs.readFileSync is supported (thanks to the bundler).

Tests should be easy to read.

Agreed and that is why having 40 lines of a string that has no other information that is human readable than the fact that it is a private key is better kept in a file that has that name so that in the test code you just have one line to refer to the private key.

Copy link
Member

Choose a reason for hiding this comment

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

If you feel really strongly about leaving them here, we can deal with it. It might just be my personal preference. No need for bikeshedding :)

@daviddias
Copy link
Member

@victorbjelkholm Circle is having issues again? It would be great if you could create a doc on explaining why these issues happen and what you do to fix them.

@victorb
Copy link
Member

victorb commented Dec 18, 2017

@diasdavid sure, I can add a document about it, where you want me to add it?

TLDR is that if you see NSS >= 3.26 is required errors when running browser tests, you'll need to upgrade the build environments Ubuntu version from 12.04 to 14.04, and then do a push again to the same branch. The setting can be found here for this repository: https://circleci.com/gh/libp2p/js-libp2p-crypto/edit#build-environment

@ghost ghost assigned daviddias Dec 18, 2017
@daviddias
Copy link
Member

thanks @victorbjelkholm ! just updated it :)

Is there any repo to track CI stuff? I feel that info belongs there, even if just in a issue for now.

@victorb
Copy link
Member

victorb commented Dec 18, 2017

@diasdavid perfect! I created a issue in ipfs/ci-sync (which holds bunch of scripts for CI-related things) for now, here: ipfs-inactive/ci-sync#3 Eventually, that repository will be folded into ipfs/jenkins to create a new ipfs/ci repository where we can keep everything.

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

Overall LGTM. One last request. @richardschneider mind checking the new bundle size vs the previous one? Run npm run build to get it.

@richardschneider
Copy link
Contributor Author

@diasdavid npm run build fails on my windows machine. PS: thanks for getting Circle CI to work.

> [email protected] build C:\Users\Owner\Documents\GitHub\js-libp2p-crypto
> aegir build

 √ Clean ./dist
 × Webpack Build
   →    Please use output.path to specify absolute path and output.filename for the file name.
   Minify
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.filename: A relative path is expected. However the provided value "C:\\Users\\Owner\\Documents\\GitHub\\js-libp2p-crypto\\src\\index.js" is an absolute path!
   -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.
   Please use output.path to specify absolute path and output.filename for the file name.
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.filename: A relative path is expected. However the provided value "C:\\Users\\Owner\\Documents\\GitHub\\js-libp2p-crypto\\src\\index.js" is an absolute path!
   -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.
   Please use output.path to specify absolute path and output.filename for the file name.
    at webpack (C:\Users\Owner\Documents\GitHub\js-libp2p-crypto\node_modules\webpack\lib\webpack.js:19:9)
    at P (C:\Users\Owner\Documents\GitHub\js-libp2p-crypto\node_modules\pify\index.js:49:6)
    at new Promise (<anonymous>)
    at C:\Users\Owner\Documents\GitHub\js-libp2p-crypto\node_modules\pify\index.js:11:9
    at ret (C:\Users\Owner\Documents\GitHub\js-libp2p-crypto\node_modules\pify\index.js:72:32)
    at config.then (C:\Users\Owner\Documents\GitHub\js-libp2p-crypto\node_modules\aegir\src\build\browser.js:17:25)
    at <anonymous>

@richardschneider
Copy link
Contributor Author

@diasdavid RTM. Provides all the primitives required by keychain to implement ipfs key.

@daviddias
Copy link
Member

daviddias commented Dec 19, 2017

@richardschneider Did you manage to get npm run build to run? Can I get that bundle size comparison?

@richardschneider
Copy link
Contributor Author

@diasdavid No,, did not get build working. Can you do it.

@richardschneider
Copy link
Contributor Author

@diasdavid https://unpkg.com/[email protected]/lib/ reports that the package is 259 kB

@daviddias daviddias merged commit b342128 into master Dec 20, 2017
@daviddias daviddias deleted the jsrsasign branch December 20, 2017 08:11
@ghost ghost removed the status/in-progress In progress label Dec 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants