Closed tiero closed 3 years ago
I can go to bed now :) That's only node, hope the gains will be the same for the browser tho
To run test checkout my branch which adapts current master to run the test/ecdh.browser.js
I would wait to merge this. Since liquidjs-lib (both provable and vulpem fork) depends on master, this would break them.
So I would first make a patch for liquidjs using my branch and merge when ready to do at the same time
Update: index.d.ts
now defines interfaces instead of modules and export as default a function returning a Promise.
This is a substantial refactor in the secp256k1-zkp JS bindings module.
You can find comparisons for node and browser environments in the following comments in this PR thread. I don't see wht holding back on this refactor, we should move to WASM as soon as possible.
secp256k1-zkp
submodule has been checked out to latest commit of masterThe building pipeline has been simplified (non-docker procedure has been dropped):
npm run compile
will callscripts/compile_wasm_docker
wich will inject thebuild_wasm
script, the secp256k1-zkp folder along with the main.c wrapper and will build with emscripten inside the docker container and move out the artifacts at the endartifacts now live in
dist
, notsrc
which seems much more semantically correctmain.c
goes tolib
folderwe use
-s SINGLE_FILE
which bundles.wasm
and the.js
"glue" together to allow easy exporting for browser and node. This targets both node and the web, so no need for browser switch.Browser suite has been added (only for ecdh at the moment, because this it needs to rewrite the test for browsers specifically)
Breaking changes
secp256k1-zkp
. This is equivalent of passing the callbackonRuntimeInitialized
Ref: Emscripten DocAs documented in test and README we must do as the following:
This adds a little overhead from 30 to 80 milliseconds in browsers (depending if Chorme or Firefox, Chrome's V8 runtime is always faster), negligible ~0-1 ms in node
ecdh
method is not wrapped in an object, but exposed directly as function in the root exported object. Ie.const { ecdh } = await secp256k1(); => ecdh(...)
Improvements for the future
embind
instead of custom C wrappermain.c
lib/index.js
should be rewritten to use cross-platform data structures as much as possible (between node and browser)