Presigning
Presigning creates cryptographic material (nonces) that are required before creating a signature. Each signature consumes one presign, so you need to manage a pool of presigns for your contract.
Overview
Presigns:
- Must be created before signing
- Are consumed when used (one presign = one signature)
- Go through verification before use
- Can be pooled for future use
Presign Types
Global Presigns
Not tied to a specific dWallet. Use for Schnorr, EdDSA, and Taproot signatures.
When to use: Most cases, especially for Taproot (Bitcoin), EdDSA, Schnorr signatures.
dWallet-Specific Presigns
Tied to a specific dWallet ID. Required for ECDSA with imported keys.
When to use: ECDSA signatures with imported key dWallets.
Presign Lifecycle
Presign Lifecycle
Requesting Presigns
Basic Global Presign Request
dWallet-Specific Presign Request
Verifying Presigns
Before using a presign, you must verify it's been completed by the network:
Verification Timing
verify_presign_cap() will fail if the network hasn't completed the presign yet. Either check
with is_presign_valid() first, or ensure enough time has passed.
Presign Pool Management
Contract Structure
Pool Management Functions
Auto-Replenishment Pattern
Automatically replenish presigns when pool gets low:
Complete Example: Bitcoin Multisig Presign Management
From the multisig-bitcoin example:
Algorithm and Curve Compatibility
| Signature Algorithm | Presign Type | Curve |
|---|---|---|
| Taproot | Global | SECP256K1 |
| Schnorr | Global | SECP256K1 |
| EdDSA | Global | ED25519 |
| SchnorrkelSubstrate | Global | RISTRETTO |
| ECDSASecp256k1 | Global | SECP256K1 |
| ECDSASecp256k1 (Imported) | dWallet-specific | SECP256K1 |
Best Practices
- Maintain a Pool: Keep multiple presigns ready to avoid delays
- Auto-Replenish: Add new presigns when pool gets low
- Use Global Presigns: When possible, as they're more flexible
- Check Before Verify: Use
is_presign_valid()to check network completion - Handle Failures: If verification fails, the presign might not be ready yet
Next Steps
- Learn about Signing to use your presigns
- See Future Signing for two-phase signing workflows