Card Security¶
UniVoucher's security model uses advanced cryptography to ensure that only the intended recipient can redeem a gift card. This page explains the technical details of the security mechanisms.
Security Overview
UniVoucher uses a combination of asymmetric cryptography, key encryption, and zero-knowledge proofs to create a secure tangible gifting mechanism that doesn't require pre-registration of recipients.
Cryptographic Model¶
Key Components¶
Each UniVoucher tangible gift card includes these cryptographic components:
- Key Pair: A unique Ethereum key pair (public and private key)
- Slot ID: The public key, used as the card's on-chain identifier
- User-Friendly Secret: A 20-character redemption code (format: XXXXX-XXXXX-XXXXX-XXXXX)
- Encrypted Private Key: The card's private key, encrypted with the user-friendly secret
Security Flow¶
The security model follows this flow:
- Generate a random Ethereum key pair
- Generate a user-friendly secret with sufficient entropy
- Encrypt the private key using the secret
- Store the encrypted private key and public key on the blockchain
- Share the card ID and secret with the recipient (off-chain)
- Recipient enters the card ID and secret
- System retrieves the encrypted private key from the blockchain
- System decrypts the private key using the provided secret
- System creates a cryptographic signature with the decrypted private key
- Smart contract verifies the signature against the stored public key
- If verified, funds are transferred to the recipient's address
Encryption Details¶
Secret Generation¶
The user-friendly secret is generated with these characteristics:
- Format: XXXXX-XXXXX-XXXXX-XXXXX (20 letters, 23 characters including hyphens)
- Character set: Uppercase English alphabet (A-Z)
- Entropy: At least 70 bits of entropy, providing sufficient security
- Generation method: Cryptographically secure random generation
Private Key Encryption¶
Private keys are encrypted using:
- Key Derivation: PBKDF2 with these parameters:
- Salt: 16 random bytes unique to each encryption
- Iterations: 310,000 rounds
- Hash function: SHA-256
-
Output key size: 256 bits
-
Encryption Algorithm: AES-GCM with these parameters:
- Key: The derived key from step 1
- IV: 12 random bytes unique to each encryption
-
Authentication tag: Included to verify decryption integrity
-
Storage Format: JSON with these fields:
Signature Verification¶
During redemption, the contract uses a signature verification process:
sequenceDiagram
participant User
participant Frontend
participant Contract
User->>Frontend: Enter Card ID & Secret
Frontend->>Contract: Query Card Data
Contract-->>Frontend: Return Encrypted Private Key
Frontend->>Frontend: Decrypt Private Key using Secret
Frontend->>Frontend: Sign Message with Private Key
Frontend->>Contract: Submit Signature & Destination Address
Contract->>Contract: Verify Signature
Contract-->>User: Transfer Funds
- The decrypted private key signs a specific message containing:
- A prefix: "Redeem card:"
- The card ID: Unique identifier
- A destination prefix: "to:"
-
The recipient address: Where funds will be sent
-
The smart contract:
- Constructs the same message
- Recovers the signer address from the provided signature
- Verifies that the recovered address matches the card's slot ID (public key)
- If verified, proceeds with the transfer
This proves that the redeemer knows the private key (via the secret) without revealing it.
Security Guarantees¶
Security Guarantees
This security model provides several guarantees:
- Secret Confidentiality: The card secret is never stored on-chain
- Zero Knowledge: The redemption proves knowledge of the secret without revealing it
- Non-Transferability: The signature is bound to a specific recipient address
- Tamper Resistance: Any change to the encrypted data would prevent successful decryption
- Brute Force Protection: The PBKDF2 key derivation is computationally expensive to brute force
Client-Side Security¶
The client-side application includes additional security features:
- Secure Key Handling:
- Private keys are only ever held in memory temporarily
- Keys are never sent to any server
-
All cryptographic operations happen in the user's browser
-
Secret Input Handling:
- Automatic formatting of secrets for better readability
- Case-insensitive handling
-
Validation before submission
-
Distribution Security:
- Generated cards are available for immediate download
- Cards can be downloaded as plain text or CSV files
- Clear instructions encourage secure distribution of secrets
Security Considerations¶
Security Considerations
While the cryptographic model is robust, users should be aware of these considerations:
- Secret Distribution: The security depends on the secret being shared securely
- Secret Storage: Recipients should store the secret securely until redemption
- Front-End Security: Users should always verify they're on the authentic UniVoucher website
- Phishing Risk: Attackers might create fake interfaces to steal card secrets
Smart Contract Security¶
The smart contract includes security features to prevent common attacks:
Feature | Description |
---|---|
Reentrancy Protection | Functions that modify state are protected against reentrancy |
Access Controls | Only card creators can cancel their cards |
Signature Replay Prevention | Each signature can only be used once |
Input Validation | All inputs are validated before processing |
Cancellation Security¶
Card cancellation requires:
- The transaction sender must be the original card creator
- The card must still be active (not redeemed)
- A signed transaction from the creator's wallet
Abandonment Protection¶
Abandonment Protection
To prevent permanent fund loss:
- Cards include a 5-year abandonment period
- After this period, the contract owner can intervene
- This appears as an "Abandoned On" date in the card details
- In normal circumstances, creators can cancel cards at any time
Security Recommendations¶
For maximum security, we recommend:
- Share card IDs and secrets through separate secure channels
- Use temporary/expiring messaging when possible
- Verify with recipients when they've successfully redeemed
- Cancel cards promptly if they're compromised or no longer needed
- Use a hardware wallet for creating high-value cards
Best Practice
When sending a gift card, consider sending the card ID and secret through different communication channels. For example, send the card ID via email and the secret via a messaging app.