Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated hdkey dependency from v1.1.1 to v2.0.1 #127

Merged
merged 2 commits into from
May 30, 2020

Conversation

holgerd77
Copy link
Member

$ npm ls secp256k1
[email protected] PATH/ethereumjs-wallet
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
  └── [email protected]  deduped

Yay. 😄 🎉

@ryanio
Copy link
Collaborator

ryanio commented May 29, 2020

hm that's not good, 3 tests failing (ci link):

  53 passing (3m)
  3 failing

  1) .derivePath()
       should work with m:

      AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual

- 'xprv9s21ZrQH143K4KqQx9Zrf1eN8EaPQVFxM2Ast8mdHn7GKiDWzNEyNdduJiQLetNUY7PDEYqnGLkhdzLLUSsrnzEMQBrJoTXMsbyAfkNJveM'
+ 'xprv9s21ZrQH143K4KqQx9Zrf1eN8EaPQVFxM2Ast8mdHn7GKiDWzNEyNdduJhWXToy8MpkGcKjxeFWd8oBSvsz4PCYamxR7TX49pSpp3bmHVAY'
      + expected - actual

      -xprv9s21ZrQH143K4KqQx9Zrf1eN8EaPQVFxM2Ast8mdHn7GKiDWzNEyNdduJiQLetNUY7PDEYqnGLkhdzLLUSsrnzEMQBrJoTXMsbyAfkNJveM
      +xprv9s21ZrQH143K4KqQx9Zrf1eN8EaPQVFxM2Ast8mdHn7GKiDWzNEyNdduJhWXToy8MpkGcKjxeFWd8oBSvsz4PCYamxR7TX49pSpp3bmHVAY
      
      at Context.<anonymous> (test/hdkey.spec.ts:78:12)

  2) .derivePath()
       should work with m/44'/0'/0/1:

      AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual

- 'xprv9zr2Dxaspc1uXaXjwifQSoiBysxq1Bf987enSQrJgAEYWbVLp9Rahgn8Yd2nXqdhjhNJqKE6D8RiqBpsSvpezEyMZg7ht7ByCmSmmTbsiUf'
+ 'xprvA1ErCzsuXhpB8iDTsbmgpkA2P8ggu97hMZbAXTZCdGYeaUrDhyR8fEw47BNEgLExsWCVzFYuGyeDZJLiFJ9kwBzGojQ6NB718tjVJrVBSrG'
      + expected - actual

      -xprv9zr2Dxaspc1uXaXjwifQSoiBysxq1Bf987enSQrJgAEYWbVLp9Rahgn8Yd2nXqdhjhNJqKE6D8RiqBpsSvpezEyMZg7ht7ByCmSmmTbsiUf
      +xprvA1ErCzsuXhpB8iDTsbmgpkA2P8ggu97hMZbAXTZCdGYeaUrDhyR8fEw47BNEgLExsWCVzFYuGyeDZJLiFJ9kwBzGojQ6NB718tjVJrVBSrG
      
      at Context.<anonymous> (test/hdkey.spec.ts:85:12)

  3) .getWallet()
       should work:

      AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual

- '0xc97a4a9ed38c8da3fde103e96465bc2542a5e40367df1aefd65b7d84fb0c70e9'
+ '0x26cc9417b89cd77c4acdbe2e3cd286070a015d8e380f9cd1244ae103b7d89d81'
      + expected - actual

      -0xc97a4a9ed38c8da3fde103e96465bc2542a5e40367df1aefd65b7d84fb0c70e9
      +0x26cc9417b89cd77c4acdbe2e3cd286070a015d8e380f9cd1244ae103b7d89d81
      
      at Context.<anonymous> (test/hdkey.spec.ts:94:12)

@alcuadrado
Copy link
Member

I had very similar errors lately. In my case, the problem was that in [email protected] some methods modify the buffers you pass them, while that doesn't happen in 3.x.

@alcuadrado
Copy link
Member

I fixed it upstream.

@coveralls
Copy link

coveralls commented May 30, 2020

Coverage Status

Coverage remained the same at 86.601% when pulling 5f504fd on update-hdkey-dependency into 23c7106 on master.

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

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

The upstream fix has already been published. We should just change the minimum version in the package.json.

package.json Outdated Show resolved Hide resolved
@ryanio ryanio changed the title Updated hdkey dependency from v1.1.1 to v2.0.0 Updated hdkey dependency from v1.1.1 to v2.0.1 May 30, 2020
Copy link
Collaborator

@ryanio ryanio left a comment

Choose a reason for hiding this comment

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

great, passing! ✅

Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

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

LGTM

@ryanio
Copy link
Collaborator

ryanio commented May 30, 2020

great, I'll merge in

@ryanio ryanio merged commit 35df952 into master May 30, 2020
@alcuadrado
Copy link
Member

I didn't know that GH prevented merges until reviewers that requested changes approve a PR, sorry about that 😅

@ryanio
Copy link
Collaborator

ryanio commented May 30, 2020

haha no worries, yeah i think it is a repo setting

@holgerd77 holgerd77 deleted the update-hdkey-dependency branch June 1, 2020 09:30
@holgerd77
Copy link
Member Author

@alcuadrado @ryanio Great guys that you figured this out here, Patricio special thanks for the upstream fix, think these things are always the ones where the ecosystem benefits most at the end! 👍

this we are now really closing in on the v1.0.0 release. 😄

@holgerd77
Copy link
Member Author

I had very similar errors lately. In my case, the problem was that in [email protected] some methods modify the buffers you pass them, while that doesn't happen in 3.x.

I will circle in @fanatid here since I wonder if this should this really be the case? And woudn't the root-addressing fix rather be in the secp256k1 library not modifying the buffer values?

@fanatid
Copy link

fanatid commented Jun 1, 2020

Hi. Which methods modify buffers?

@holgerd77
Copy link
Member Author

Likely @alcuadrado can give an answer (or a hint) here, you'll have to wait for Argentinian time zone morning though! 😄

@fanatid
Copy link

fanatid commented Jun 1, 2020

ok, just checked code/readme, probably I'll not need wait morning in Argentinian time zone :D

This 4 functions do in-place operations:

  • privateKeyNegate
  • privateKeyTweakAdd
  • privateKeyTweakMul
  • signatureNormalize

I changed these functions for 4.x because bitcoin-core/secp256k1 do in-place. API.md have note about this. Such functions can be filtered from list by searching output and functions which will not match but change data included in list above.

Should I make API.md more clear about this? Should I put some dangerous note to README.md? (Not sure how much people read API.md)

@holgerd77
Copy link
Member Author

Thanks for the quick check 😄 , I'll nevertheless let an answer open to @alcuadrado since he normally has some deeper rooted opinion than me on questions like these.

@alcuadrado
Copy link
Member

I'd modify this part of API.md "In place operations. Some functions doing in place operations" to include a list of all of them.

In general, I'd try to avoid changing the semantics of a function without changing its name and/or type, as people tend to just bump version numbers without much care.

@alcuadrado
Copy link
Member

alcuadrado commented Jun 1, 2020

In general, I'd try to avoid changing the semantics of a function without changing its name and/or type, as people tend to just bump version numbers without much care.

This can still be done by deprecating the functions with a warning, and expose them with another name. Something like:

import * as secp256k1 from  "secp256k1";

export function privateKeyTweakAdd(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array {
  console.warn("privateKeyTweakAdd is deprecated. Please use privateKeyTweakAddInPlace");
  return privateKeyTweakAddInPlace(privateKey, tweak);
}

export function privateKeyTweakAddInPlace(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array {
  return secp256k1.privateKeyTweakAddInPlace(privateKey, tweak);
}

@holgerd77
Copy link
Member Author

Yes, I would also agree that it is a good suggestion to deprecate the existing functions, otherwise this can easily lead to serious problems if people do their usual upgrading and don't have a close-enough look.

@holgerd77
Copy link
Member Author

Eventually I would even be a bit more explicit on the warning message, like:

import * as secp256k1 from  "secp256k1";

export function privateKeyTweakAdd(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array {
  console.warn("privateKeyTweakAdd() is deprecated. Please use privateKeyTweakAddInPlace().");
  console.warn("Attention: both versions of the function changed to do operations in-place.");
  return privateKeyTweakAddInPlace(privateKey, tweak);
}

export function privateKeyTweakAddInPlace(privateKey: Uint8Array, tweak: Uint8Array): Uint8Array {
  return secp256k1.privateKeyTweakAddInPlace(privateKey, tweak);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants