Skip to main content

Try it Live

Run Signature examples in the interactive playground

Signature Formats

Comprehensive comparison of signature encoding formats: compact, DER, and RSV.

Format Overview

FormatSizeComponentsUse Case
Compact64 bytesr ‖ sSpace-efficient, standard ECDSA
Compact+V65 bytesr ‖ s ‖ vEthereum transactions (with recovery)
DERVariable (~70-72 bytes)ASN.1 encodedBitcoin, X.509, legacy systems
RSV ObjectN/A (object)API structures, JSON
EIP-209864 bytesr ‖ (s + yParity)Compact with recovery (see EIP-2098)
RPCN/A (object) hexJSON-RPC responses
TupleN/A (array)[yParity, r, s]Transaction envelope serialization

Compact Format

Structure

Usage

Advantages

  • ✅ Fixed size (predictable memory)
  • ✅ Simple structure
  • ✅ Efficient for storage and transmission
  • ✅ Standard ECDSA format

Disadvantages

  • ❌ No self-describing (need external algorithm info)
  • ❌ No built-in validation
  • ❌ Recovery ID optional (separate byte)

Use Cases

  • Ethereum transactions
  • Blockchain signatures
  • High-performance applications
  • Fixed-size storage requirements

DER Format

Structure

Encoding Rules

Tags:
  • 0x30 - SEQUENCE tag
  • 0x02 - INTEGER tag
Length Encoding:
  • Short form: 0x00-0x7F (length fits in 1 byte)
  • Long form: 0x80 + n followed by n-byte length
Integer Padding:
  • Leading 0x00 added if high bit set (to indicate positive number)
  • Leading zeros stripped (minimal encoding)

Usage

Advantages

  • ✅ Self-describing format
  • ✅ Standard ASN.1 encoding
  • ✅ Widely supported (Bitcoin, TLS, X.509)
  • ✅ Built-in structure validation

Disadvantages

  • ❌ Variable size (70-72 bytes typical)
  • ❌ Parsing overhead
  • ❌ More complex than compact
  • ❌ Larger than necessary

Use Cases

  • Bitcoin transactions (legacy)
  • X.509 certificates
  • TLS connections
  • Legacy cryptographic systems

RSV Object Format

Structure

Usage

Advantages

  • ✅ Human-readable structure
  • ✅ Type-safe (with TypeScript)
  • ✅ Easy to work with in code
  • ✅ JSON serializable

Disadvantages

  • ❌ Not a binary format
  • ❌ Overhead for serialization
  • ❌ No standard wire format
  • ❌ Requires conversion for transmission

Use Cases

  • API responses (JSON)
  • Internal data structures
  • Testing and debugging
  • Configuration files

Format Comparison

Size Comparison

Conversion Matrix

From → ToCompactDERRSV
CompactIdentitytoDER()getR/S/V()
DERfromDER()toCompact()IdentityfromDER()getR/S/V()
RSVfrom()toCompact()from()toDER()Identity

Performance Comparison

Format Selection Guide

Choose Compact When:

  • ✅ Building Ethereum transactions
  • ✅ Storage space is critical
  • ✅ Fixed-size buffers required
  • ✅ High-performance needs

Choose DER When:

  • ✅ Bitcoin transaction signing
  • ✅ Interop with legacy systems
  • ✅ X.509 certificate operations
  • ✅ Standards compliance required

Choose RSV When:

  • ✅ Building APIs (JSON responses)
  • ✅ Internal data structures
  • ✅ Testing and debugging
  • ✅ Human-readable output needed

Real-World Examples

Ethereum Transaction

Bitcoin Transaction

JSON API Response

Format Validation

Compact Validation

DER Validation

RPC Format

Structure

Usage

Advantages

  • ✅ JSON-serializable (all hex strings)
  • ✅ Standard JSON-RPC format
  • ✅ Includes both yParity and v for compatibility

Use Cases

  • JSON-RPC responses (eth_getTransactionByHash)
  • REST API payloads
  • WebSocket message bodies

Tuple Format

Structure

Usage

Advantages

  • ✅ Minimal representation
  • ✅ Matches RLP encoding for typed transactions
  • ✅ Easy destructuring

Use Cases

  • EIP-2718 typed transaction envelopes
  • RLP serialization
  • Compact storage

Interoperability

Format Conversion Utilities

See Also