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 32-byte hash reference to encrypted data in the content-addressable store.
use privora_sdk_program::prelude::*;
let price_ref: EncryptedRef<u8> = EncryptedRef::from_hash(hash_bytes);
let price: Encrypted<u8> = price_ref.load()?;
Type Parameters
T: EncryptedInt - The encrypted integer type (u8, u32, or u64)
Methods
from_hash
pub const fn from_hash(hash: [u8; 32]) -> Self
Create a new reference from a 32-byte SHA256 hash.
hash
pub const fn hash(&self) -> [u8; 32]
Get the hash as an owned array.
hash_ref
pub const fn hash_ref(&self) -> &[u8; 32]
Get a reference to the hash.
load
pub fn load(&self) -> Result<Encrypted<T>, ProgramError>
Load the encrypted value from the content-addressable store.
Traits
Clone, Copy, Debug, PartialEq, Eq
BorshSerialize, BorshDeserialize
Default (returns zero hash)
From<[u8; 32]>, Into<[u8; 32]>
AsRef<[u8; 32]>
Size
Always 32 bytes (SHA256 hash).
Example
#[derive(BorshSerialize, BorshDeserialize)]
pub struct Order {
pub price_ref: EncryptedRef<u8>, // 32 bytes
pub qty_ref: EncryptedRef<u8>, // 32 bytes
}
pub fn process(order: &Order) -> ProgramResult {
let price = order.price_ref.load()?;
let qty = order.qty_ref.load()?;
let total = price.mul(&qty)?;
Ok(())
}