Open Jonas-Metzger opened 3 years ago
With some help from the @peculiar/webcrypto repo (which I have use to replace the webcrypto API given my bundle will not run in a browser), it seems that the error is coming from this line in their crypto.ts:
public static async verify(algorithm: EcdsaParams, key: EcPublicKey, signature: Uint8Array, data: Uint8Array): Promise<boolean> {
const cryptoAlg = (algorithm.hash as Algorithm).name.replace("-", "");
const signer = crypto.createVerify(cryptoAlg);
which is meant to call NodeJS crypto API, but now calls crypto-browserify. Tracing the call through browserify-sign/index.js, it probably arises on this line
function Verify (algorithm) {
stream.Writable.call(this)
var data = algorithms[algorithm]
if (!data) throw new Error('Unknown message digest')
Does this mean that ESCDA with SHA256 is not supported? Or is cryptoAlg
=algorithm
(I'm assuming a string?) formatted in the wrong way? How should it be formatted?
I'm trying to bundle the PageSigner pgsg-node.js (written in NodeJS) using browserify, such that I can run it via QuickJS and eventually compile it to WASM. (Not for a browser application however - I need to run it on a WASM VM).
After some necessary edits to the code of pgsg-node.js, I managed to successfully execute both
node bundle.js
and the QuickJS analogueqjs bundle.js
and log the final output to the console. However, that only works if I remove this crucial line:and replace it with
var result = true
. Otherwise I get the following error after executingnode bundle.js
:What's weird is that at least some of the
crypto.subtle
functionality works, the line right beforeworks flawlessly. Also, executing my modified unbundled file
node pgsg-node.js
does not produce this error.