pub struct PredicateCompiler { /* private fields */ }Expand description
Compiles query predicates into executable FHE circuits
The PredicateCompiler transforms high-level query predicates (like age > 18)
into FHE circuits that can evaluate these conditions on encrypted data.
The result is always an encrypted boolean indicating whether the predicate
matches or not.
§Example
use amaters_core::compute::{PredicateCompiler, EncryptedType};
use amaters_core::types::{Predicate, col, CipherBlob};
let mut compiler = PredicateCompiler::new();
// Compile: age > 18
let predicate = Predicate::Gt(col("age"), encrypted_18);
let circuit = compiler.compile(&predicate, EncryptedType::U8)?;
// The circuit can now be executed on encrypted age valuesImplementations§
Source§impl PredicateCompiler
impl PredicateCompiler
Sourcepub fn compile(
&mut self,
predicate: &Predicate,
value_type: EncryptedType,
) -> Result<Circuit>
pub fn compile( &mut self, predicate: &Predicate, value_type: EncryptedType, ) -> Result<Circuit>
Compile a predicate into an FHE circuit
The resulting circuit will have inputs for:
value: The encrypted column value to testrhs: The encrypted comparison value (right-hand side)
The circuit output is an encrypted boolean indicating the predicate result.
§Arguments
predicate- The predicate to compilevalue_type- The encrypted type of the values being compared
§Returns
A Circuit that evaluates the predicate on encrypted data
§Errors
Returns an error if:
- The predicate references undefined columns
- Type inference fails
- The circuit construction is invalid
Sourcepub fn extract_rhs_value(predicate: &Predicate) -> Result<CipherBlob>
pub fn extract_rhs_value(predicate: &Predicate) -> Result<CipherBlob>
Extract the RHS (right-hand side) value from a predicate
This walks the predicate tree to find comparison values. For composite predicates (And/Or/Not), it extracts from the first comparison it encounters.
§Arguments
predicate- The predicate to extract from
§Returns
The encrypted value used in the predicate comparison
§Errors
Returns an error if the predicate contains no comparison operations
Sourcepub fn extract_all_rhs_values(predicate: &Predicate) -> Vec<CipherBlob>
pub fn extract_all_rhs_values(predicate: &Predicate) -> Vec<CipherBlob>
Extract all RHS values from a predicate
For composite predicates, this returns all comparison values.
This is useful for complex predicates like age > 18 AND age < 65
which have multiple RHS values.
§Arguments
predicate- The predicate to extract from
§Returns
A vector of all encrypted values used in comparisons
Sourcepub fn infer_value_type(_predicate: &Predicate) -> Option<EncryptedType>
pub fn infer_value_type(_predicate: &Predicate) -> Option<EncryptedType>
Get the required encrypted type for a predicate’s values
This analyzes the predicate to determine what type of encrypted values it operates on. This is useful for automatic type inference.
§Arguments
predicate- The predicate to analyze
§Returns
The encrypted type hint, or None if it cannot be determined
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PredicateCompiler
impl RefUnwindSafe for PredicateCompiler
impl Send for PredicateCompiler
impl Sync for PredicateCompiler
impl Unpin for PredicateCompiler
impl UnwindSafe for PredicateCompiler
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.