ERC-8111 · Review · ERC · 2025-12-23
ERC-8111: Bound Signatures
Shrinks ECDSA signatures for contracts to 64 bytes by always using v = 27 and flipping s when needed, so they stay directly usable with ecrecover and are non-malleable.
What problem does it solve?
An Ethereum ECDSA signature is usually passed as v, r, s. ABI-encoded, that is 96 bytes, even though v only carries one bit (27 or 28). On top of that, for every valid (v, r, s) there is a second valid signature (v', r, n - s) with the opposite v, so signatures are malleable unless a contract restricts them.
ERC-2098 already compresses signatures to 64 bytes by packing the parity bit into s, but the contract must unpack it before calling ecrecover. Bound Signatures get the same size with no unpacking.
How it works
Because (27, r, s) and (28, r, n - s) recover the same signer, any signature can be rewritten into an equivalent one whose v is 27. This is called binding the signature.
- Contracts that accept bound signatures must call
ecrecover(digest, 27, r, s)and must not accept any otherv. They then only needrands(64 bytes). - Signers (or the client submitting the signature) must bind it first: if
vis 28, replaceswithn - s(wherenis the secp256k1 group order). - Fixing
vremoves the second valid form, so bound signatures are not malleable. Allowing both 27 and 28 would reintroduce malleability. - 27 was chosen so the y-parity is "falsy".
Sample code
Binding a signature off-chain (ethers v6) and verifying it on-chain:
import { Wallet, Signature } from "ethers";
const N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
function bind(sig: Signature): { r: string; s: string } {
if (sig.v === 27) return { r: sig.r, s: sig.s };
const s = N - BigInt(sig.s);
return { r: sig.r, s: "0x" + s.toString(16).padStart(64, "0") };
}
const wallet = Wallet.createRandom();
const sig = wallet.signingKey.sign(digest); // digest: 32-byte hash
const { r, s } = bind(sig); // 64 bytes total
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.30;
library BoundSignatures {
function recover(bytes32 digest, bytes32 r, bytes32 s) internal pure returns (address signer) {
signer = ecrecover(digest, 27, r, s);
require(signer != address(0));
}
}
Things to know
- Status is Review; the interface may still change.
- Bound signatures often have a "high"
s, which EIP-2 forbids for transaction signatures. They are only for contracts that verify viaecrecover, not for signing transactions. - Libraries that reject high-
svalues (for example OpenZeppelin'sECDSA.recover) will reject bound signatures; callecrecoverdirectly as shown. - Always check that the recovered address is non-zero, and still use a proper digest scheme such as EIP-712 with nonces to prevent replay.