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: schnorrSign return type and type and signature #176

Merged
merged 3 commits into from
Nov 16, 2024

Conversation

fboucquez
Copy link
Contributor

@fboucquez fboucquez commented Nov 15, 2024

This PR adds the missing schnorrSign ts type and fixes the return type to be Buffer rather than just Uint8Array for consistency

@@ -49,7 +49,7 @@ export const create = ({ getPrivateHDKey }) => {
)
const hdkey = getPrivateHDKey({ seedId, keyId })
const privateKey = tweak ? tweakPrivateKey({ hdkey, tweak }) : hdkey.privateKey
return secp256k1.schnorrSign({ data, privateKey, extraEntropy })
return Buffer.from(await secp256k1.schnorrSign({ data, privateKey, extraEntropy }))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return Buffer.from(await secp256k1.schnorrSign({ data, privateKey, extraEntropy }))
return secp256k1.schnorrSign({ data, privateKey, extraEntropy, format: 'buffer' })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice, i didn't know about that param

@@ -34,6 +34,7 @@ export interface KeychainApi {
secp256k1: {
signBuffer(params: { data: Buffer } & KeySource): Promise<Buffer>
signBuffer(params: { data: Buffer; enc: 'der' } & KeySource): Promise<Buffer>
signSchnorr(params: { data: Buffer; extraEntropy?: Buffer } & KeySource): Promise<Buffer>
Copy link
Contributor

Choose a reason for hiding this comment

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

I added this already in #174.
But, if we want to use this one, for consistency we should not add the extraEntropy param (or add for all), and we need the tweak?: Buffer param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

your PR can land too, it adds other api types

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I merged so you will have to rebase here. I think if we're adding extraEntropy? we should add for the other signBuffer signatures too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebased

andrewtoth
andrewtoth previously approved these changes Nov 15, 2024
Copy link
Contributor

@andrewtoth andrewtoth left a comment

Choose a reason for hiding this comment

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

utACK

@fboucquez fboucquez enabled auto-merge (squash) November 15, 2024 15:32
feri42
feri42 previously approved these changes Nov 15, 2024
@fboucquez fboucquez merged commit 7e8d8bb into master Nov 16, 2024
7 checks passed
@fboucquez fboucquez deleted the fboucquez/fix/keychain-signSchnorr-type branch November 16, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants