Documentation Index
Fetch the complete documentation index at: https://docs.privora.xyz/llms.txt
Use this file to discover all available pages before exploring further.
A loaded encrypted value ready for FHE computation.
use privora_sdk_program::prelude::*;
let a: Encrypted<u8> = a_ref.load()?;
let b: Encrypted<u8> = b_ref.load()?;
let sum = a.add(&b)?;
Type Parameters
T: EncryptedInt - The encrypted integer type (u8, u32, or u64)
Arithmetic Methods
add
pub fn add(&self, other: &Self) -> Result<Self, ProgramError>
Add two encrypted values.
sub
pub fn sub(&self, other: &Self) -> Result<Self, ProgramError>
Subtract other from self.
mul
pub fn mul(&self, other: &Self) -> Result<Self, ProgramError>
Multiply two encrypted values.
Comparison Methods
pub fn ge(&self, other: &Self) -> Result<EncryptedBool, ProgramError>
Check if self >= other.
pub fn gt(&self, other: &Self) -> Result<EncryptedBool, ProgramError>
Check if self > other.
pub fn le(&self, other: &Self) -> Result<EncryptedBool, ProgramError>
Check if self <= other.
pub fn lt(&self, other: &Self) -> Result<EncryptedBool, ProgramError>
Check if self < other.
eq_enc
pub fn eq_enc(&self, other: &Self) -> Result<EncryptedBool, ProgramError>
Check if self == other.
Min/Max Methods
min
pub fn min(&self, other: &Self) -> Result<Self, ProgramError>
Return the minimum of two values.
max
pub fn max(&self, other: &Self) -> Result<Self, ProgramError>
Return the maximum of two values.
Storage Methods
store
pub fn store(self) -> Result<EncryptedRef<T>, ProgramError>
Store the value and return a hash reference.
Utility Methods
from_raw
pub fn from_raw(data: Vec<u8>) -> Self
Create from raw ciphertext bytes.
as_bytes
pub fn as_bytes(&self) -> &[u8]
Get the ciphertext bytes.
into_bytes
pub fn into_bytes(self) -> Vec<u8>
Consume and return the ciphertext bytes.
Operator Overloads
// Using references
let sum = &a + &b;
let diff = &a - &b;
let prod = &a * &b;
Example
let buy_price = buy_price_ref.load()?;
let sell_price = sell_price_ref.load()?;
let buy_qty = buy_qty_ref.load()?;
let sell_qty = sell_qty_ref.load()?;
let can_match: EncryptedBool = buy_price.ge(&sell_price)?;
let fill_qty: Encrypted<u8> = buy_qty.min(&sell_qty)?;
let fill_qty_ref = fill_qty.store()?;