Try it Live
Run Signature examples in the interactive playground
Signature Formats
Comprehensive comparison of signature encoding formats: compact, DER, and RSV.Format Overview
| Format | Size | Components | Use Case |
|---|---|---|---|
| Compact | 64 bytes | r ‖ s | Space-efficient, standard ECDSA |
| Compact+V | 65 bytes | r ‖ s ‖ v | Ethereum transactions (with recovery) |
| DER | Variable (~70-72 bytes) | ASN.1 encoded | Bitcoin, X.509, legacy systems |
| RSV Object | N/A (object) | API structures, JSON | |
| EIP-2098 | 64 bytes | r ‖ (s + yParity) | Compact with recovery (see EIP-2098) |
| RPC | N/A (object) | hex | JSON-RPC responses |
| Tuple | N/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 tag0x02- INTEGER tag
- Short form:
0x00-0x7F(length fits in 1 byte) - Long form:
0x80 + nfollowed by n-byte length
- Leading
0x00added 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 → To | Compact | DER | RSV |
|---|---|---|---|
| Compact | Identity | toDER() | getR/S/V() |
| DER | fromDER() → toCompact() | Identity | fromDER() → getR/S/V() |
| RSV | from() → 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
- Signature Constructors - Creating signatures from different formats
- Signature Conversions - Converting between formats
- EIP-2098 - Compact signature format with embedded recovery
- DER Encoding - ASN.1 Distinguished Encoding Rules

