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

feat: replace keypair and ursa-optional with web-crypto for node #218

Closed
wants to merge 2 commits into from

Conversation

achingbrain
Copy link
Member

Removes native module ursa-optional and js fallback library keypair in favour of using web-crypto which is available in node 15+

Also adds benchmark suite similar to Ed25519:

$ node index.js
ursa-optional x 323 ops/sec ±2.84% (70 runs sampled)
keypair x 55.33 ops/sec ±11.75% (59 runs sampled)
node.js web-crypto x 300 ops/sec ±2.29% (74 runs sampled)
fastest is ursa-optional

BREAKING CHANGE: requires node 15+

Removes native module `ursa-optional` and js fallback library `keypair`
in favour of using web-crypto which is available in node 15+

Also adds benchmark suite similar to Ed25519:

```console
$ node index.js
ursa-optional x 323 ops/sec ±2.84% (70 runs sampled)
keypair x 55.33 ops/sec ±11.75% (59 runs sampled)
node.js web-crypto x 300 ops/sec ±2.29% (74 runs sampled)
fastest is ursa-optional
```

BREAKING CHANGE: requires node 15+
@hugomrdias
Copy link
Member

We have an issue with webcrypto not supporting our RSA algo for encryption, i will find some refs on this tomorrow

@hugomrdias
Copy link
Member

#205 (comment)

Found it

@achingbrain
Copy link
Member Author

That's interesting, so in the browser we fall back to node-forge for RSA encryption/decryption because it supports PKCS1 padding, which we've hard coded in the node.js version. As it stands this PR will make node do the same thing which will be slower than using ursa-optional.

Perhaps we could use node crypto for encrypt/decrypt to retain the performance but keypair generation and sign/verify with web crypto? They we can still get rid of the extra deps.

@achingbrain
Copy link
Member Author

achingbrain commented Dec 1, 2021

Or just crypto.generateKeyPair instead of ursa-optional?

@achingbrain
Copy link
Member Author

Superseded by #219

@achingbrain achingbrain closed this Dec 1, 2021
@achingbrain achingbrain deleted the feat/replace-ursa-with-web-crypto branch December 1, 2021 17:45
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.

2 participants