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(ecsda): return ecdsa signature with a normalized s value #2888

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/cryptography/src/primitive/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ export function sign(keydata, message) {
const msg = hex.encode(message);
const data = hex.decode(keccak256(`0x${msg}`));
const keypair = secp256k1.keyFromPrivate(keydata);
const signature = keypair.sign(data);
const signature = keypair.sign(data, {
// the elliptic library generates a non-normalized s value by-default
// this seems to be legacy behavior that they are loathe to change
// as its pretty silent if someone was depending on it
// most every other client I can normalizes the s value, passing `true`
// here will return a normalized s value
canonical: true,
});

const r = signature.r.toArray("be", 32);
const s = signature.s.toArray("be", 32);
Expand Down
Loading