Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-2098, which proposes a more compact representation of Ethereum signatures.
This article translates, summarizes, and supplements the material linked below.
I have also covered other ERCs.
Overview
Ethereum uses digital signatures based on the secp256k1 elliptic curve to authenticate transactions. A valid signature demonstrates authorization by the holder of the corresponding private key.
A conventional recoverable signature occupies 65 bytes. When represented as a dynamically sized byte array in ABI encoding, its contents are padded to 96 bytes to align with 32-byte words, excluding the surrounding ABI overhead.
The original proposal also discusses the overhead associated with encoding yParity in transaction representations, averaging around 1.5 bytes under the encoding assumptions it describes.
A compact signature reduces the signature representation to 64 bytes, which fits exactly into two ABI words without an additional padding word.
This reduces the amount of data needed to represent signatures and can lower calldata and storage costs in systems that support the compact representation.
Compact signatures can make applications more space-efficient. The actual savings depend on how signatures are encoded and used.
Motivation
There are several reasons to represent signatures more compactly.
Simpler Handling in Client Code
A compact representation can make signatures easier for developers to handle in applications and contracts, simplifying data structures.
Reduced Gas Costs
Ethereum transactions consume gas. Reducing the amount of signature data included in calldata can reduce the associated transaction costs.
Smaller Transaction Data
Smaller data representations can reduce the amount of information transmitted or stored by systems using the format.
A compact signature format can simplify implementation and reduce data costs, improving efficiency in applications that support it.
Specification
Recoverable secp256k1 ECDSA signatures are commonly represented using three parameters: r, s, and yParity.
-
r
- Derived from the x-coordinate of the ephemeral elliptic-curve point, reduced modulo the curve order.
- The point's possible y-coordinate can be reconstructed using the curve equation and relevant recovery information.
-
s
- A scalar calculated during signing using the message hash, private key, and ephemeral signing nonce.
- It is required to verify the signature.
-
yParity
- Identifies the parity of the relevant elliptic-curve point's y-coordinate.
- Its value is
0or1.
Ethereum's canonical low-s signature convention ensures that the highest bit of s is zero. ERC-2098 uses that otherwise unused bit to encode yParity.
The resulting signature representation is:
[256-bit r value][1-bit yParity value][255-bit s value]- A 256-bit
rvalue. - A one-bit
yParityvalue. - A 255-bit
svalue.
Combining the parity bit and s value reduces the signature representation without losing information, provided the input signature satisfies the canonical low-s requirement.
Example Implementation
# Assume yParity is 0 or 1, normalized from the canonical 27 or 28
def to_compact(r, s, yParity):
return {
"r": r,
"yParityAndS": (yParity << 255) | s
}
def to_canonical(r, yParityAndS):
return {
"r": r,
"s": yParityAndS & ((1 << 255) - 1),
"yParity": (yParityAndS >> 255)
}The Python example converts secp256k1 signatures between compact and conventional representations using two functions, to_compact and to_canonical.
to_compact
- Purpose
- Converts a signature to its compact representation.
- Inputs
r,s, andyParity, where parity is either 0 or 1.
- Processing
- Shifts
yParityleft by 255 bits and combines it with thesvalue.
- Shifts
- Result
- The original r value and the combined parity-and-s value.
to_canonical
- Purpose
- Converts the compact representation back to its conventional components.
- Inputs
rand the combinedyParityAndSvalue.
- Processing
- Applies a bitmask to extract the lowest 255 bits of s and shifts right by 255 bits to recover yParity.
- Result
- The original
r,s, andyParityvalues.
- The original
These functions allow applications to convert between formats while preserving the underlying signature information.
Smaller encoded signatures can reduce data overhead and gas costs.
Additional Notes
The compact representation makes Ethereum signature data smaller and easier to handle in client software and Solidity.
Developers can represent the signature as two 32-byte values, reducing the number of fields and the amount of encoded data in applications that adopt the format.
The compact representation offers a straightforward way to reduce signature data costs. Both developers and applications can benefit when the relevant signing and verification interfaces support it.
Backward Compatibility
The compact representation contains two values, r and yParityAndS, for a total of 64 bytes.
A conventional recoverable signature contains three components, r, s, and yParity, typically represented using 65 bytes.
Both forms contain equivalent information when the canonical signature requirements are satisfied. Applications can convert between them as needed.
The same signature information can be represented in fewer bytes, reducing encoding overhead without changing the underlying ECDSA signature.
Support for ERC-2098 must be provided by the relevant interface. The proposal does not mean that every Ethereum transaction format or signature verification API automatically accepts the compact encoding.
Tests
The following test cases illustrate the conventional and compact signature representations generated from a specified test private key and message.
Case 1
Private Key: 0x1234567890123456789012345678901234567890123456789012345678901234
Message: "Hello World"
Signature:
r: 0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90
s: 0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064
v: 27
Compact Signature:
r: 0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90
yParityAndS: 0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064- Test private key
0x1234567890123456789012345678901234567890123456789012345678901234
- Message
- "Hello World"
- Conventional signature
r- A signature component.
s- A signature component.
v- The value representing recovery parity under the applicable convention.
- Compact signature
r- The same r value as in the conventional signature.
yParityAndS- Combines s and the parity bit into one value.
Case 2
Private Key: 0x1234567890123456789012345678901234567890123456789012345678901234
Message: "It's a small(er) world"
Signature:
r: 0x9328da16089fcba9bececa81663203989f2df5fe1faa6291a45381c81bd17f76
s: 0x139c6d6b623b42da56557e5e734a43dc83345ddfadec52cbe24d0cc64f550793
v: 28
Compact Signature:
r: 0x9328da16089fcba9bececa81663203989f2df5fe1faa6291a45381c81bd17f76
yParityAndS: 0x939c6d6b623b42da56557e5e734a43dc83345ddfadec52cbe24d0cc64f550793- Test private key
0x1234567890123456789012345678901234567890123456789012345678901234
- Message
- "It's a small(er) world"
- Conventional signature
- Contains
r,s, andv.
- Contains
- Compact signature
r- The same r value as in the conventional signature.
yParityAndS- Combines s and the parity bit.
These examples demonstrate how the compact format preserves the same signature information using fewer bytes. The publicly known private key is a test vector and must never be used to hold real assets.
Security
The proposal identifies no additional security concerns arising from the representation itself. Implementations must still enforce the applicable canonical signature and verification requirements.
Citation
Richard Moore (@ricmoo), Nick Johnson nick@ethereum.org, "ERC-2098: Compact Signature Representation," Ethereum Improvement Proposals, no. 2098, March 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2098.
Conclusion
ERC-2098 proposes a 64-byte representation of Ethereum signatures by encoding yParity in the unused highest bit of a canonical low-s signature.
If you have questions, feel free to contact me on Twitter.
I also publish articles on the following platforms.


