-
Notifications
You must be signed in to change notification settings - Fork 52
Support ed25519
and secp256k1
in the import method
#145
Comments
That would be amazing if you could get that in. I didn't know that |
After checking To do this properly, we would need to support PKCS8 either by implementing in |
The library is almost finished, here's a glimpse of it: https://github.com/ipfs-shipyard/js-crypto-key-composer/tree/initial-impl It would be integrated like so:
|
@satazor I think this is good step forward. Any chance you could drop the dependency on node-forge though? Depending on it as little as possible seems to make the most sense for the long term. |
Here're the things we are depending on: import pem from 'node-forge/lib/pem';
import { createBuffer } from 'node-forge/lib/util';
import sha1 from 'node-forge/lib/sha1';
import sha256 from 'node-forge/lib/sha256';
import sha512 from 'node-forge/lib/sha512';
import md5 from 'node-forge/lib/md5';
import pbkdf2 from 'node-forge/lib/pbkdf2';
import aes from 'node-forge/lib/aes';
import des from 'node-forge/lib/des';
import rc2 from 'node-forge/lib/rc2';
import random from 'node-forge/lib/random'; As you can see, we are depending on concrete files with functionality that we use 100%, except for To completely remove the dependency, we could either find equivalent libraries or copy them over, removing and refactoring whatever necessary. Note that this is something we can do now or down the road, as this package is part of |
Seems like there is at least some duplication there, we already have randomness, and aes defined in a way that doesn't require node-forge and is good in the browser and node in this repo. For hashing we have everything outside of node-forge as well: the sha family is available from webcrypto, asmcrypto.js and node.js and md5 is available as a standalone version and available natively in node.js This way we should only need |
Hi @AlbertoElias , what ever happened to PR#16 libp2p/js-libp2p-crypto-secp256k1#16 addressing this issue? Did it get merged into libp2p-crypto? Looks like everything stopped last April... but was nearly ready? |
Getting support for PEM exporting/import is a bit painful at the moment due to lack of support in forge. Node.js To get around these issues in the short term, so we can get support sooner rather than later, the plan is to add support for export/import with the libp2p key format (serialized protobuf). We can still encrypt these with a password if provided to keep consistency there. The plan is to eventually support PEM and a variety of other formats, but that will require a significant effort to ensure everything is done properly (node support/browser support/bundle size constraints). We can add support to each of the key types and still have RSA default to PEM to avoid breaking things. Later, we could include a breaking change to have RSA also default to libp2p key encodings. I'm planning on moving forward with this approach as we want to support exporting/importing libp2p key encoding's anyway. If you have concerns/issues let me know. I'm hoping to land a PR this week. |
I'm going to close this. We now support exporting/importing all 3 keys. PEM is only supported for RSA atm, but I will make sure we have an issue to track adding support to the other keys in the future. This will be bubbled up to js-ipfs shortly. |
PEM interop story continues in #244 |
Hello!
I was trying to publish a IPNS record using a
ed25519
key after seeing that support fored25519
andsecp256k1
keys was added here. I know that peer-id has to be changed to account for different key types, but I still decided to give it a try.After trying, I concluded that
js-ipfs
callscrypto.keys.import
and fails because the import method assumes only RSA keys.I can make a PR that adds support for
ed25519
andsecp256k1
keys by first extracting the private key info stored in the pem and react accordingly.The text was updated successfully, but these errors were encountered: