Try it Live
Run Authorization examples in the interactive playground
Validation
Authorization structure and signature validation.validate
Validate authorization structure and signature parameters.auth: Authorization to validate
Authorization.ValidationError if invalid
Validation Checks:
- Chain ID must be non-zero
- Address cannot be zero address
- yParity must be 0 or 1
- Signature r must be non-zero
- Signature s must be non-zero
- r must be < SECP256K1_N (curve order)
- s must be ≤ SECP256K1_HALF_N (prevents malleable signatures)
Basic Usage
Validation Errors
ValidationError
"Chain ID must be non-zero"- chainId is 0"Address cannot be zero address"- address is 0x0000…0000"yParity must be 0 or 1"- yParity not 0 or 1"Signature r cannot be zero"- r is 0"Signature s cannot be zero"- s is 0"Signature r must be less than curve order"- r >= SECP256K1_N"Signature s too high (malleable signature)"- s > SECP256K1_HALF_N
Validation Rules
Chain ID
Chain ID must be non-zero to indicate which chain authorization is valid on.Zero Address
Address cannot be zero address (0x0000…0000).yParity
yParity must be 0 or 1 (ECDSA signature parity bit).Signature r
Signature r must be non-zero and less than curve order.Signature s
Signature s must be non-zero and at most SECP256K1_HALF_N.Malleability Prevention
What is Signature Malleability?
ECDSA signatures have inherent malleability: given valid signature (r, s), signature (r, N - s) is also valid for same message. Without malleability protection:Protection
validate() rejects high s values:
Normalizing High s
If you receive signature with high s, normalize it:Validation Patterns
Validate Before Processing
Always validate before any operations:Batch Validation
Validate entire authorization list:Early Validation
Validate as soon as authorization is received:Validation with Type Guards
Combine type guards with validation:Error Handling
Handle specific validation errors:Performance
Validation Cost
Validation is O(1) with constant-time checks:Optimization
Validation is already optimized. For batch validation, consider:Testing
Valid Authorization
Invalid Cases
See Also
- Constructors - Type guards and creation
- Signing - Creating valid signatures
- Verification - Recovering signer
- Constants - SECP256K1_N and SECP256K1_HALF_N

