The load() method fetches the ciphertext from the content-addressable store using the hash reference. This is a syscall that the Privora sequencer handles.
// Calculate fill quantity using SDK's min methodmsg!("Calculating fill quantity using FHE min...");let fill_qty = buy_qty .min(&sell_qty) .map_err(|_| ProgramError::InvalidArgument)?;msg!("FHE min calculation completed");
// Use sell price as fill price (standard orderbook matching)let fill_price_ref = sell_order.price_ref;// Store the computed fill_qtymsg!("Submitting fill quantity to data store...");let fill_qty_ref = fill_qty .store() .map_err(|_| ProgramError::InvalidArgument)?;msg!("Fill quantity submitted with hash");
You cannot conditionally execute code based on encrypted values. The comparison result is encrypted.
Copy
// This is NOT possible - can_match is encrypted!if can_match.decrypt() { // ERROR: No decrypt in program execute_trade();}
Instead, use select to compute both outcomes and pick the right one:
Copy
// Both outcomes computed, select chooses which to uselet matched_status = /* encrypted matched status */;let open_status = /* encrypted open status */;let new_status = can_match.select(&matched_status, &open_status)?;