Skip to main content
An encrypted boolean value from comparison operations.
use privora_sdk_program::prelude::*;

let can_match: EncryptedBool = buy_price.ge(&sell_price)?;
let fill_price = can_match.select(&sell_price, &buy_price)?;

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 bytes.

select

pub fn select<T: EncryptedInt>(
    &self,
    true_val: &Encrypted<T>,
    false_val: &Encrypted<T>,
) -> Result<Encrypted<T>, ProgramError>
Select between two values based on the condition.
  • If condition is true, returns true_val
  • If condition is false, returns false_val

store

pub fn store(self) -> Result<EncryptedBoolRef, ProgramError>
Store and return a hash reference.

Example

// Compare prices
let can_match: EncryptedBool = buy_price.ge(&sell_price)?;

// Conditional selection
let fill_price = can_match.select(&sell_price, &buy_price)?;
// Equivalent to: if (buy >= sell) { sell_price } else { buy_price }

EncryptedBoolRef

A 32-byte hash reference to an encrypted boolean.

Methods

from_hash

pub const fn from_hash(hash: [u8; 32]) -> Self

hash

pub const fn hash(&self) -> [u8; 32]

load

pub fn load(&self) -> Result<EncryptedBool, ProgramError>