Shielded Spending Key
BN254 scalar field element serving as the core secret for zero-knowledge proof generation and UTXO spending
Overview
The Shielded Spending Key is the core secret required to generate Zero-Knowledge Proofs (ZKPs) for spending UTXOs within the Umbra shielded pool. Unlike the L1 Interaction Key which operates on the L1's transparent layer, the Shielded Spending Key operates entirely within the ZK circuit domain.
This key represents full spending authority over all shielded UTXOs associated with the corresponding User Commitment. Loss of this key results in permanent, irrecoverable loss of funds.
Technical Specification
| Property | Value |
|---|---|
| Type | BN254 Scalar Field Element |
| Field Modulus | |
| Bit Length | ~254 bits |
| Constraint | Must be strictly less than the field modulus |
| Cryptographic Role | Private input to ZK spend circuits |
Why BN254?
The BN254 curve (also known as alt_bn128) is chosen for its:
| Property | Benefit |
|---|---|
| Pairing-Friendly | Enables efficient zkSNARK constructions |
| EVM Precompiles | Native support in Ethereum-compatible chains |
| Mature Tooling | Well-supported by circom, snarkjs, and other ZK frameworks |
| ~128-bit Security | Sufficient security level for cryptographic applications |
Purpose
The Shielded Spending Key serves two critical functions in the Umbra protocol:
- Claiming Ownership of a UTXO - Proving you have the right to spend a specific UTXO
- Creating Nullifier Hashes - Preventing double-spending while preserving privacy
Both functions are essential and work together to enable private, secure transactions.
Purpose 1: Claiming Ownership of a UTXO
Every UTXO in the Unified Mixer Pool is cryptographically locked to a specific User Commitment. The User Commitment is a hash that binds together three keys: the L1 Interaction Key, the Shielded Spending Key, and the Master Viewing Key (see User Commitment Tree).
To spend a UTXO, you must prove-without revealing any secrets-that you know the preimages that hash to the User Commitment embedded in that UTXO.
The Ownership Problem
When you want to spend a UTXO, you face a fundamental challenge:
- The UTXO contains a commitment (a hash) that identifies the owner
- You need to prove you are the owner
- But you cannot reveal your Shielded Spending Key (or it could be stolen)
- And you cannot reveal which specific UTXO you're spending (or you lose privacy)
The Zero-Knowledge Solution
The Shielded Spending Key enables a zero-knowledge proof that demonstrates:
- "I know a Shielded Spending Key..." - You possess the secret key
- "...that, when combined with the other commitment preimages..." - Together with L1 key and MVK
- "...hashes to a User Commitment..." - Following the Poseidon hash tree structure
- "...that matches one of the UTXOs in the global set" - The UTXO exists and belongs to you
What the Proof Reveals
| Revealed | Not Revealed |
|---|---|
| A valid proof exists | The actual Shielded Spending Key |
| The nullifier (for double-spend prevention) | Which specific UTXO is being spent |
| The transaction outputs | The User Commitment |
| Any link between sender and recipient |
Why This Matters
Similar to Tornado Cash or ZCash, the specific UTXO being claimed is never revealed on-chain. An observer sees:
- A zero-knowledge proof (valid/invalid)
- A nullifier (to prevent double-spending)
- New output commitments
But they cannot determine:
- Which UTXO was spent
- Who the sender was
- Any transaction history or patterns
Without the Shielded Spending Key, it is cryptographically impossible to claim a UTXO. Even if you know a UTXO belongs to a specific User Commitment, you cannot spend it without the corresponding Shielded Spending Key.
Purpose 2: Creating Nullifier Hashes
The second critical function of the Shielded Spending Key is nullifier generation. Nullifiers are the mechanism that prevents double-spending in privacy-preserving systems.
The Double-Spend Problem
In a transparent blockchain, preventing double-spends is straightforward: each UTXO is explicitly marked as spent or unspent. But in a privacy-preserving system:
- You cannot reveal which UTXO you're spending
- So you cannot mark a specific UTXO as "spent"
- How do you prevent someone from spending the same UTXO twice?
The Nullifier Solution
A nullifier is a deterministic, unique identifier for each UTXO that:
- Can only be computed by the UTXO's owner (who knows the Shielded Spending Key)
- Is unique to each UTXO (no two UTXOs produce the same nullifier)
- Reveals nothing about which UTXO it corresponds to
- Is published on-chain when the UTXO is spent
Nullifier Computation
The nullifier is computed using the Poseidon PRF with the Shielded Spending Key as the secret:
Where:
- SpendingKey - Your Shielded Spending Key (the PRF secret)
- UTXOCommitment - The commitment hash of the UTXO being spent
- LeafIndex - The position of the UTXO in the global commitment tree
Why This Construction Works
| Property | How It's Achieved | Why It Matters |
|---|---|---|
| Uniqueness | Different UTXO data produces different nullifier | Each UTXO can only be spent once |
| Determinism | Same inputs always produce same output | Attempting to re-spend produces the same nullifier |
| Secrecy | Requires knowledge of Spending Key | Only the owner can compute the nullifier |
| Unlinkability | PRF output reveals nothing about inputs | Nullifier cannot be linked back to UTXO or user |
| Binding | Cryptographically bound to specific UTXO | Cannot use one UTXO's nullifier for another |
The Nullifier Set
The protocol maintains an on-chain nullifier set-a record of all nullifiers that have been published:
- When you spend a UTXO, your nullifier is included in the transaction
- The protocol checks if this nullifier has been seen before
- If yes: reject (this is a double-spend attempt)
- If no: accept and add the nullifier to the set
Privacy Preservation
The key insight is that the nullifier:
- Is deterministic: The same UTXO always produces the same nullifier
- Is unlinkable: No one can determine which UTXO the nullifier corresponds to
- Requires the secret: Only the owner can compute it
This means:
- If someone tries to spend the same UTXO twice, they produce the same nullifier → rejected
- But observers cannot tell which UTXOs have been spent (only that some UTXOs have been)
- The anonymity set remains intact
Example: Double-Spend Prevention
Scenario: Alice owns a UTXO and tries to spend it twice.
- First spend: Alice computes nullifier from her UTXO and Spending Key
- Transaction accepted, added to nullifier set
- Second spend attempt: Alice tries to spend the same UTXO
- She must compute the nullifier again: it's deterministic, so she gets again
- Protocol checks: already in nullifier set → Transaction rejected
Alice cannot produce a different nullifier for the same UTXO because:
- The nullifier is deterministically derived from the UTXO data and her Spending Key
- She cannot change the UTXO data (it's fixed)
- She cannot change her Spending Key (or the ownership proof would fail)
Key Generation
The Shielded Spending Key can be generated randomly or derived deterministically from a master seed. Both approaches are valid as long as the key is a cryptographically secure random value within the BN254 scalar field.
| Method | Description |
|---|---|
| Random | Sample uniformly from using a CSPRNG |
| Deterministic | Derive via KDF: |
All Umbra keys (Shielded Spending Key, Master Viewing Key, L1 Keypair, and X25519 Keypair) can either be derived deterministically from a single master seed or managed as fully independent keys-both approaches provide equivalent cryptographic security.
Spending a UTXO: Complete Flow
To spend a UTXO, the owner must provide a zero-knowledge proof that demonstrates both purposes simultaneously:
The ZK circuit verifies:
- Ownership: The provided preimages (including Spending Key) hash to a valid User Commitment that matches a UTXO in the global set
- Nullifier Correctness: The nullifier was correctly computed from the Spending Key and UTXO data
- No Double-Spend: The nullifier is not in the nullifier set (checked on-chain)
All of this is proven without revealing:
- The Shielded Spending Key
- Which UTXO is being spent
- The User Commitment
- Any linkage between transactions
Both Keys Required
Spending a UTXO requires both the Shielded Spending Key and the Master Viewing Key:
| Key | Role in Spending |
|---|---|
| Shielded Spending Key | Proves ownership, generates nullifier |
| Master Viewing Key | Creates linkers required for valid ZK proofs |
Without either key, spending is impossible. This is enforced at the cryptographic level-the ZK circuit requires both as private inputs.
Summary
| Aspect | Details |
|---|---|
| Type | BN254 Scalar Field Element |
| Purpose 1 | Prove UTXO ownership via ZK proofs |
| Purpose 2 | Generate nullifiers to prevent double-spending |
| Generation | Random or derived from master seed |
| Required With | Master Viewing Key (both needed to spend) |
| Loss Impact | Permanent, irrecoverable fund loss |
| Compromise Impact | Full spending authority (if attacker can also find UTXOs) |
| Binding | Linked to identity via User Commitment Tree |