Privacy by Design
Walnut leverages Fully Homomorphic Encryption (FHE) to ensure your financial data remains confidential. We don't just protect your privacy; we mathematically guarantee it.
Three-Layer
Confidential Stack
Walnut's architecture ensures that sensitive financial data never exists in plaintext on-chain, while maintaining full protocol functionality through encrypted computation.
Client-Side Encryption
All sensitive values encrypted before leaving user's wallet using Fhenix SDK
FHE Computation Layer
Smart contracts execute operations on encrypted data without decryption
Client-Driven Decryption Sync
Selective decryption verified via secure enclave ECDSA signatures
Encrypted
Computation Primitives
Walnut leverages Fhenix's FHE library to perform arithmetic and logical operations directly on encrypted data without ever exposing plaintext values.
FHE.add
euint128Homomorphic addition on encrypted integers
euint128 total = FHE.add(
userCollateral[wallet1],
userCollateral[wallet2]
);FHE.sub
euint128Homomorphic subtraction for balance updates
userDebt[msg.sender] = FHE.sub(
userDebt[msg.sender],
encryptedAmount
);FHE.mul
euint128Encrypted multiplication for interest calculations
euint128 interest = FHE.mul(
principal,
encryptedRate
);FHE.div
euint128Homomorphic division for ratio computation
euint128 healthFactor = FHE.div(
totalCollateral,
totalDebt
);FHE.select
euint128Conditional selection in ciphertext
euint128 minBid = FHE.select(
FHE.lt(bid1, bid2),
bid1,
bid2
);FHE.allowPublic
euint128Grant decryption permissions to public enclaves
FHE.allowPublic(mintedAmount);
uint256 ctHash = uint256(
euint128.unwrap(mintedAmount)
);End-to-End
Encrypted Execution
From client-side encryption to on-chain storage, sensitive data never exists in plaintext.
Client Encryption
Plaintext → CiphertextUser encrypts borrow amount using fhenixjs before transaction request
const encrypted = await fhenixClient.encrypt_uint128(
borrowAmount
);
await walnut.borrow(encrypted);On-Chain FHE Computation
Ciphertext → CiphertextContract performs LTV check and updates encrypted balances without decryption
// Compute encrypted health factor
euint128 hf = FHE.div(collateral, debt);
// Update encrypted debt
userDebt[msg.sender] = FHE.add(
userDebt[msg.sender],
encryptedAmount
);Encrypted State Persisted
Ciphertext StorageAll sensitive values remain encrypted in contract storage. No plaintext exposure.
// Storage layout
mapping(address => euint128) userCollateral;
mapping(address => euint128) userDebt;
mapping(address => euint128) repaymentCount;Encrypted State
Management
All sensitive protocol state is stored as encrypted integers (euint128). No plaintext financial data ever touches contract storage.
Encrypted Storage Layout
Core protocol state stored as FHE-encrypted integers
// User positions
mapping(address => euint128) userCollateral;
mapping(address => euint128) userDebt;
mapping(address => euint128) repaymentCount;
// Pool state
euint128 totalPoolCollateral;
euint128 totalPoolDebt;
// P2P offers
struct Offer {
euint128 apr;
euint128 size;
euint128 tenor;
bool active;
}
mapping(uint256 => Offer) offers;
// Liquidation bids
mapping(address => euint128[]) bids;Permit-Based Access Control
Users grant read permissions via FHE.allow for selective decryption
// Grant contract permission
FHE.allowThis(userCollateral[msg.sender]);
FHE.allowThis(userDebt[msg.sender]);
// Grant specific address permission
FHE.allow(
offers[offerId].apr,
borrower
);
// P2P: only lender and borrower can read
FHE.allow(encryptedTerms, lender);
FHE.allow(encryptedTerms, borrower);
// Third parties: no accessNo Plaintext Storage
All sensitive values stored as euint128 ciphertexts
Granular Permissions
Users control who can decrypt their encrypted data
Composable Privacy
Encrypted state can be used in other FHE operations
Selective Decryption
Through Enclave Verification
When protocol logic requires a plaintext value, Walnut coordinates decryption off-chain and validates ECDSA enclave signatures on-chain. Decrypted values exist only during transaction execution — never stored, never emitted in logs.
syncPositionGuardCheck
Set liquidatable flag based on decrypted health factor
function syncPositionGuardCheck(
euint128 ciphertext,
uint128 result,
bytes calldata signature
) external {
require(
FHE.verifyDecryptResultSafe(ciphertext, result, signature),
"Invalid signature"
);
address user = ciphertextToUser[ciphertext];
if (result == 1) {
isLiquidatable[user] = true;
emit LiquidationEligible(user);
}
}syncWinnerSelected
Reveal winning liquidator without exposing bid amounts
function syncWinnerSelected(
euint128 ciphertext,
uint128 winnerIndex,
bytes calldata signature
) external {
require(
FHE.verifyDecryptResultSafe(ciphertext, winnerIndex, signature),
"Invalid signature"
);
address user = auctionUser[ciphertext];
address winner = bidders[user][winnerIndex];
// Execute liquidation with winner
_executeLiquidation(user, winner);
}syncCreditCount
Map encrypted count to public credit tier
function syncCreditCount(
euint128 ciphertext,
uint128 count,
bytes calldata signature
) external {
require(
FHE.verifyDecryptResultSafe(ciphertext, count, signature),
"Invalid signature"
);
address user = ciphertextToUser[ciphertext];
uint8 tier = _computeTier(count);
creditTier[user] = tier;
emit CreditTierUpdated(user, tier);
}ECDSA Enclave Verification Principle
All client-driven sync actions are verified using the verifyDecryptResultSafe function on-chain, which validates that the decrypted value matches a valid ECDSA signature signed directly by FHE enclave nodes. Decrypted values exist solely in transaction execution scope and are never persisted to storage or emitted in events, ensuring maximum security and zero leak potential through indexers or chain history.
Privacy-Preserving
Lending Primitives
Walnut's FHE architecture enables lending features that are structurally impossible in traditional transparent DeFi.
Sealed-Bid Liquidations
Traditional DeFi: liquidation bids are public, enabling MEV extraction and unfair outcomes
Walnut: liquidators submit encrypted bids. FHE.select finds minimum in ciphertext. Only winner revealed.
Private Credit Scoring
On-chain credit history is fully public, exposing user financial behavior to everyone
Walnut: repayment count stored as euint128. CoFHE decrypts privately to compute tier. Only tier is public.
Confidential P2P Terms
Loan terms (APR, size, duration) are visible to all participants and indexers
Walnut: lender encrypts terms. Only matched borrower gets FHE.allow permission. Third parties see nothing.
ENS Wallet Aggregation
Linking wallets publicly reveals user's full portfolio and relationships
Walnut: aggregate encrypted collateral across wallets using FHE.add. No public wallet linking.
Infrastructure
Details
System Specifications
Developer Resources
Experience Confidential Lending
Walnut Protocol is live on Arbitrum Sepolia testnet. Try encrypted borrowing, sealed-bid liquidations, and private credit scoring.