Branching
What is confidential branching?
Using FHE.select for conditional logic
FHE.select for conditional logicFHE.select(condition, valueIfTrue, valueIfFalse);Example: Auction Bidding Logic
function bid(externalEuint64 encryptedValue, bytes calldata inputProof) external onlyBeforeEnd {
// Convert the encrypted input to an encrypted 64-bit integer
euint64 bid = FHE.asEuint64(encryptedValue, inputProof);
// Compare the current highest bid with the new bid
ebool isAbove = FHE.lt(highestBid, bid);
// Update the highest bid if the new bid is greater
highestBid = FHE.select(isAbove, bid, highestBid);
// Allow the contract to use the updated highest bid ciphertext
FHE.allowThis(highestBid);
}How Does It Work?
Key Considerations
How to branch to a non-confidential path?
Example: Auction Bidding Logic: Item Release
Summary
Last updated