Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Bring core-js into erdjs. Browser tests improvements. #97

Merged
merged 42 commits into from
Jan 15, 2021

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Dec 2, 2020

  • Bring core-js into erdjs (user wallets & signing, validator signing).
  • Run all tests (unit and integration) in browser, as well.
  • Separate builds: erdjs with / without wallet components.

@andreibancioiu andreibancioiu self-assigned this Dec 2, 2020
@andreibancioiu andreibancioiu changed the title Bring core-js into erdjs. Run all tests (unit and integration) in browser as well. [WIP] Bring core-js into erdjs. Run all tests (unit and integration) in browser as well. Dec 2, 2020
Base automatically changed from tx-hash to development December 3, 2020 13:19
@andreibancioiu andreibancioiu changed the title [WIP] Bring core-js into erdjs. Run all tests (unit and integration) in browser as well. [WIP] Bring core-js into erdjs. Browser tests improvements. Dec 3, 2020
@andreibancioiu andreibancioiu changed the title [WIP] Bring core-js into erdjs. Browser tests improvements. Bring core-js into erdjs. Browser tests improvements. Jan 11, 2021
@andreibancioiu andreibancioiu marked this pull request as ready for review January 11, 2021 22:25
erdjs/src/walletcore/mnemonic.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/userKeys.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/userKeys.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/userKeys.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/pem.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/pem.ts Outdated Show resolved Hide resolved
erdjs/src/walletcore/userWallet.ts Outdated Show resolved Hide resolved
*/
private static generateDerivedKey(password: Buffer, salt: Buffer, kdfparams: ScryptKeyDerivationParams): Buffer {
// Question for review: @ccorcoveanu, why not this implementation?
// https://nodejs.org/api/crypto.html#crypto_crypto_scrypt_password_salt_keylen_options_callback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, because scryptsy works in the browser, does the scrypt in the crypto package work also? We can test/benchmark it and if it does, we can switch to it and remove some extra dependencies

Copy link
Contributor Author

@andreibancioiu andreibancioiu Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the original one, on a i3-8100 CPU @ 3.60GHz:

- 80-90 ms in Node.js
- 350-360 ms in browser (Firefox)

With the one from the crypto package:

 - 15-17 ms in Node.js
 - ... (not available) ...

... not added by the browserify pipeline: https://www.npmjs.com/package/crypto-browserify.

Therefore, left as it was, until the package mentioned in https://github.com/crypto-browserify/crypto-browserify/issues/181 is included in browserify by default. Currently, it isn't:

https://github.com/browserify/browserify/blob/master/package.json#L36

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@AdoAdoAdo
Copy link

erdjs/src/webSigner.ts can be removed as it is empty.

let pair = tweetnacl.sign.keyPair.fromSeed(this.buffer);
let signingKey = pair.secretKey;
let signature = tweetnacl.sign(new Uint8Array(message), signingKey);
signature = signature.slice(0, signature.length - message.length);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it return the concatenated message with sig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, tweetnacl.sign does that. I've added a comment.

@andreibancioiu
Copy link
Contributor Author

erdjs/src/webSigner.ts can be removed as it is empty.

Should not exist in this branch anymore:

https://github.com/ElrondNetwork/elrond-sdk/tree/core-js/erdjs/src

@andreibancioiu andreibancioiu merged commit e66c3cb into development Jan 15, 2021
@andreibancioiu andreibancioiu deleted the core-js branch January 15, 2021 14:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants