Simon Warta

Results 376 comments of Simon Warta

@josh-hemphill did you make some benchmarks to compare the pure JS implementation and a Wasm implementation, e.g. https://github.com/MyEtherWallet/scrypt-wasm or https://github.com/indutny/dumb-scrypt-wasm? It should not be too hard to create a wrapper...

There is also an implementation of [scryptsalsa208sha256 in libsodium](https://libsodium.gitbook.io/doc/advanced/scrypt), which is [wasm compiled and wrapped in JS as libsodium.js](https://github.com/jedisct1/libsodium.js/) and distributed as [libsodium-wrappers-sumo](https://www.npmjs.com/package/libsodium-wrappers-sumo).

In https://github.com/CosmWasm/cosmwasm-js/pull/181 I played around with the JS implementation from here and the Wasm implementation from https://github.com/MyEtherWallet/scrypt-wasm/pull/2. The benchmark results on Node.js 12 are not that convincing: ``` Jasmine started...

After further investigation it turned out that for browsers the speedup of Wasm is between 1.5x and 4x: https://github.com/CosmWasm/cosmwasm-js/pull/181#issuecomment-636478818 Wasm execution is very stable across different environments. JS execution speed...

> Did you add progress callbacks to the wasm implementation? Nope. The main issue I see with a Wasm implementation is that you can hardly use it on the main...

As far as I can see at https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto#Using_SubtleCrypto (scroll down a little to the table), there is no scrypt support in the WebCrypto API.

I tried replacing PBKDF2_HMAC_SHA256_OneIter with a WebCrypto implementation in https://github.com/ricmoo/scrypt-js/pull/26. It seems to work in Chrome but does not help performance.

> ... we should probably section this off to a browser section... > People in Node should not have to suffer even a 2x slowdown because of the browser. I...

Sure, me neither. But you can have an implementation that uses 1., 2. or 3. depending on availability.

So my current thinking given your input is reimplementing pbkdf2 - in TypeScript - supporting SHA2 only - targeting reasonabily modern JS environments(native async/await and Uint8Array support) - removal of...