-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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 Secp256k1 Signature in typescript to be 65-bytes recoverable format #4776
Conversation
💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/3117243828#artifacts |
|
||
secp.utils.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => { | ||
const h = hmac.create(sha256, key); | ||
msgs.forEach(msg => h.update(msg)); | ||
msgs.forEach((msg) => h.update(msg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some unrelated lint, they are generated with npx prettier --write .
@@ -87,11 +87,11 @@ export class Secp256k1Keypair implements Keypair { | |||
const signData = encoder.encode('sui validation'); | |||
const msgHash = sha256(signData); | |||
const signature = secp.signSync(msgHash, secretKey); | |||
if (!secp.verify(signature, msgHash, publicKey)) { | |||
if (!secp.verify(signature, msgHash, publicKey, { strict: true })) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strict = true rejects s value if it is higher than 1/2 prime order.
secp.signSync(msgHash, this.keypair.secretKey) | ||
); | ||
const [sig, rec_id] = secp.signSync(msgHash, this.keypair.secretKey, { | ||
canonical: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canonical = true means a signature s should be no more than 1/2 prime order.
rust sdk example:
sui keytool:
typescript test: