Skip to content

Conversation

@wjmelements
Copy link

@wjmelements wjmelements commented Dec 20, 2025

Reviewer @ricmoo
This adds support for ERC-8111 (Bound Signatures).
Bound signatures provide a good compression mechanism for signatures because the compressed form can be passed directly to ecrecover without transformation.
They utilize signature malleability to eliminate v.
Consumers of bound signatures would expect a specific v (usually 27).
See EIP-2.

Test Plan

  • npm exec mocha --trace-warnings --reporter ./reporter.cjs ./lib.esm/_tests/test-crypto.js

Changes

  • add Signature.bind(v) with default v=27
  • add test for recoverAddress for bound signatures

@wjmelements wjmelements changed the title [WIP] Bound Signatures feat: Bound Signatures Dec 20, 2025
@wjmelements wjmelements changed the title feat: Bound Signatures feat(crypto): Bound Signatures Dec 20, 2025
const sig = Signature.from(signature);

let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat([ sig.r, sig.s ])));
let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat([ sig.r, sig._s ])));
Copy link
Author

Choose a reason for hiding this comment

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

Without this change, recoverAddress fails with TypeError: non-canonical s; use ._s. I don't think recoverAddress should assert the signature has low-S ("canonical", EIP-2), because that restriction only applies to transaction signatures. recoverAddress should also succeed for non-canonical signatures.

An alternative fix would be to have Signature.from make the signature canonical, but this change makes more sense to me.

@wjmelements
Copy link
Author

@ricmoo this is ready for review

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.

1 participant