Comments (8)
I don't see how tiny-secp256k1 compilation step is related to browsers, since we fallback to pure JS when packaging for browsers. If the compilation fails you will use pure JS in node environment too.
I'm leading an effort to remove native dependencies (except N-API based ones) from the Ethereum js ecosystem. Why?
- They are degrade the development experience by being slow to install.
- They tend to break with new Node.js major versions
- Many people, especially Windows users, don't have a proper setup to use them. This is incredibly common in educational contexts (e.g. a workshop at a conference). In those cases, many people just desist.
As part of this process, I'm also making sure that the dependencies being used work well with web bundlers and don't produce unnecessarily large bundles.
The problems with the crypto
module are:
Why hdkey
and not bip32
? hdkey
is more popular in the Ethereum ecosystem, so migrating to a portable version of it is easier than migrating to bip32
. This is especially important because this effort requires the buy-in of multiple open source projects.
from hdkey.
bip32
library works with browsers.
Is there any functionality that bip32 doesn't offer that you need? Besides not having bitcoin in the name... lol
from hdkey.
My main issue with bip32 is that it depends on tiny-secp256k1 which needs to be recompiled every time you install it. I used it in my main project until very recently.
Besides that, I don't see how your comment is related. I'm proposing a small change that would improve this lib's portability.
from hdkey.
I don't see how your comment is related.
I don't see how tiny-secp256k1 compilation step is related to browsers, since we fallback to pure JS when packaging for browsers. If the compilation fails you will use pure JS in node environment too.
Since you were talking about browsers, I suggested a bip32 library that works in browsers out of the box. Asking why you don't use that helps me understand exactly what you are aiming for with this suggestion to hdkey library.
I don't know why hdkey doesn't use browser friendly dependencies, but by asking you why you didn't use one that did (bip32), it gives us more context and information for considering your request.
from hdkey.
In package.json
you can specify a broswer
key and then put your replacements in it. This is the de facto solution for this problem and supported by virtually every bundler system.
Example:
{
"main": "hdkey.js",
"browser": {
"./lib/thingy.js": "./lib-browser/thingy.js",
"foo-dep": "foo-browser-dep"
}
}
Anything that installs this as a dependency would get the correct bundle for that bundle system.
from hdkey.
@alcuadrado Also FYI tiny-secp256k1 has since moved to WASM, no more compilation, but now you have to deal with bundlers WASM support. (webpack works pretty well in my experience)
from hdkey.
Thanks for the heads up, @junderw!
from hdkey.
New Breaking Version 3.0
I'm rewriting this today, in about 10 minutes (for probably 4-6 hours).
$DASH Code Hangout #6: WebCrypto & ArrayBuffers for HD Keys. Full Send.
The stream will be live at https://twitch.tv/dashincubator and stored at https://youtube.com/@dashincubator.
Changes I'm making include:
- use Prettier, which adheres to JavaScript best practices
(rather than feross' personal preferences - though genius to call it "standard style") - removing use of
prototype
,this
,defineProperty
privateKey
=>getPrivateKey()
,setPrivateKey()
privateExtendedKey
=>getPrivateExtendedKey()
publicExtendedKey
=>getPublicExtendedKey()
- cleanup redundant properties (_identifier, identifier, pubKeyHash)
- and adding types - as in jsdoc + tsc (https://jsjwithtypes.com), NOT ts
- update tests
- remove dependency on node
assert
- update
var
tolet
- we need to switch
forEach
tofor
due toasync
WebCrypto
- we need to switch
- Replacing legacy node Buffer with current Node LTS Uint8Array, ArrayBuffer, DataView
- update
ripemd160
to work in browsers (Uint8Array)
(fork is@dashincubator/ripemd160
) - update
bs58check
to work in browsers (Uint8Array)
(rewrite is @dashincubator/base58check)
Node v18-only changes
- Replacing the legacy node crypto with current Node LTS WebCrypto
-
secp256k1
=>@noble/secp256k1
- works in Node and Browsers no transpiling
- works in modern Bundlers (Vite, WebPack), but should work in all that follow the specs
These defineProperty / prototype changes are necessary because they don't work with async
functions, which are required by the current-gen APIs.
I have the prerequisite PR up at dashhive/DashHD.js#4.
I'm considering wether to try to get the old mocha tests going or to migrate them to modern table-driven tests.
I will submit the PRs here too, but we'll be maintaining our own fork either way.
from hdkey.
Related Issues (20)
- Please push a release which includes the safe-buffer changes HOT 2
- hdkey.fromPrivateKey HOT 1
- Including options for exporting public and private key for toJson() function HOT 1
- How do I export a hardened key ? HOT 1
- Unable to sign transaction and get privkey object HOT 1
- Document `deriveChild` HOT 1
- Getting same output for any input to "fromMasterSeed" HOT 2
- Deriving from hardened extended keys HOT 1
- Remove cionstring dependency HOT 3
- Add files field to package.json
- Clean dirty derivePath check HOT 1
- [ERROR] : TypeError: "list" argument must be an Array of Buffers __ERROR HOT 2
- Same value when calling .toJSON() HOT 2
- TypeError [ERR_INVALID_ARG_TYPE] HOT 3
- What is the case for publicKeyTweakAdd ? HOT 2
- Peer Dependency issue HOT 1
- readme.MD is old HOT 3
- Docs: bad derive(path) example? HOT 1
- secp256r1 instead of secp256k1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hdkey.