Test vectors
voucher-ts/test-vectors/vouchers.json is the contract between implementations. Any library that encodes or signs vouchers, in TypeScript, Rust, Swift or Kotlin, must reproduce every vector byte for byte.
How they're checked today#
- TypeScript re-encodes, re-signs and verifies each vector. It also verifies the signatures with Node's own ed25519, independent of the library.
- Rust (the settlement program) re-encodes each body and signing message, recomputes the digest, and decodes the full voucher.
Run both:
npm run test:voucher
cd program && cargo test
Fields#
| Field | Contents |
|---|---|
name | Vector name |
signer_seed_hex | 32-byte ed25519 seed, derived as sha256("contingency-test-vector:<label>") |
signer | Signer public key (base58) |
voucher | Field values. Integers are decimal strings, keys are base58, memo_hex is hex |
body_hex | 163-byte Borsh body |
signing_message_hex | 183-byte message that is signed |
signature_hex | 64-byte ed25519 signature |
voucher_hex | 227-byte encoded voucher |
digest_hex | sha256(signing_message) |
Vectors#
| Name | Covers |
|---|---|
usdc_coffee | A typical USDC payment with a memo and a 50 bps tip. The vault is a real devnet PDA |
wsol_no_memo_no_tip | Wrapped SOL, an empty memo and no tip |
boundary_values | Maximum u64 values, minimum and maximum i64, and the maximum u16 tip |
boundary_values checks encoding only. Its values would fail settlement rules, such as the tip cap.
Example: usdc_coffee#
amount 4500000 (4.50 USDC)
seq 1
created_at 1767225600 (2026-01-01T00:00:00Z)
expires_at 1769817600 (+30 days)
memo "order-0001"
tip 50 bps
digest c6d2d976e15a4faaeb9e31084145ff0f19a0d1452b03f920148d99af9727e2ce
Regenerating#
Only regenerate the vectors for an intentional format change, since every implementation must then be updated:
npm run vectors -w @contingency/voucher