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

Fix HDKey.sign method arguments types #50

Merged
merged 1 commit into from
Jun 17, 2022
Merged

Fix HDKey.sign method arguments types #50

merged 1 commit into from
Jun 17, 2022

Conversation

DDushkin
Copy link
Contributor

secp256k1.ecdsaSign() expects Uint8Arrays as arguments instead of Buffers

secp256k1.ecdsaSign() expects Uint8Arrays as arguments instead of Buffers
@RyanZim
Copy link
Member

RyanZim commented Jun 16, 2022

Buffer is a subclass of Uint8Array, so buffer instanceof Uint8Array === true. There's no point in casting it here.

@DDushkin
Copy link
Contributor Author

DDushkin commented Jun 17, 2022

Buffer is a subclass of Uint8Array, so buffer instanceof Uint8Array === true. There's no point in casting it here.

Yeah, I understand but I introduced this because I got such error on hdkey.sign()
[Error: Expected private key to be an Uint8Array]
And it also mimics the hdkey.verify() method, which already contains Uint8Array.from()

Uint8Array.from(this.publicKey)

@junderw
Copy link
Member

junderw commented Jun 17, 2022

Some front ends have Buffer polyfills that are not subclass of Uint8Array

@DDushkin
Copy link
Contributor Author

Some front ends have Buffer polyfills that are not subclass of Uint8Array

I'm on React Native, using rn-nodeify and shim like this

if (typeof Buffer === "undefined") global.Buffer = require("buffer").Buffer;

@RyanZim
Copy link
Member

RyanZim commented Jun 17, 2022

Some front ends have Buffer polyfills that are not subclass of Uint8Array

Was not aware of this; in that case, not opposed to the change; @junderw feel free to merge

@junderw junderw merged commit 62c25cc into cryptocoinjs:master Jun 17, 2022
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.

3 participants