Skip to content

Commit

Permalink
feat: use @noble and @Scure libraries for cryptography (#2273)
Browse files Browse the repository at this point in the history
Switch to using `@noble/hashes`, `@noble/curves`, `@scure/base`,
`@scure/bip32`, and `@scure/bip39`. This replaces `crypto` polyfills
(such as `crypto-browserify`), `create-hash`, `elliptic`, `hash.js`,
`bn.js` (both versions), and their many dependencies.  This also means
there are 33 less dependencies downloaded when running a fresh
`npm install` and will make the project much easier to maintain.

This reduces the bundle size by 44% (82kb minified and gzipped) over
the current 3.0 branch as well as reducing the amount of configuration
required to bundle.

Closes #1814, #1817, #2272, and #2306

Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
  • Loading branch information
sublimator and ckniffen committed Nov 30, 2023
1 parent 39d7516 commit f1585cf
Show file tree
Hide file tree
Showing 78 changed files with 2,981 additions and 2,691 deletions.
10 changes: 1 addition & 9 deletions UNIQUE_SETUPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ To use `xrpl.js` with React, you need to install shims for core NodeJS modules.
```shell
npm install --save-dev \
buffer \
crypto-browserify \
process \
stream-browserify
process
```

2. Modify your webpack configuration
Expand All @@ -41,8 +39,6 @@ To use `xrpl.js` with React, you need to install shims for core NodeJS modules.
module.exports = function override(config) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
ws: require.resolve("xrpl/dist/npm/client/WSWrapper"),
});
config.resolve.fallback = fallback;
Expand Down Expand Up @@ -152,8 +148,6 @@ build: {
resolve: {
alias: {
events: 'events',
crypto: 'crypto-browserify',
stream: 'stream-browserify',
ws: 'xrpl/dist/npm/client/WSWrapper',
},
}})
Expand All @@ -166,8 +160,6 @@ npm install --save-dev @esbuild-plugins/node-globals-polyfill \
rollup-plugin-polyfill-node \
&& npm install
events \
crypto-browserify \
stream-browserify \
xrpl
```
Expand Down
Loading

0 comments on commit f1585cf

Please sign in to comment.