Skip to main content

TupleChain

Struct TupleChain 

Source
pub struct TupleChain { /* private fields */ }
Expand description

The TupleChain semantic ledger.

Stores five-tuples as a DAG with automatic expiry pruning, SPARQL-inspired semantic queries, and Wyqcc L1 anchoring.

Implementations§

Source§

impl TupleChain

Source

pub fn new() -> Self

Source

pub fn insert(&mut self, tuple: PrivacyTuple) -> String

Insert a five-tuple into the ledger.

Generates a tuple ID from SHA-256(subject || predicate || expiry).

Source

pub fn query_by_subject(&self, subject: &str, now_ms: u64) -> Vec<&PrivacyTuple>

Query tuples by subject (SPARQL-inspired).

Returns non-expired tuples matching the subject.

Source

pub fn query_by_predicate( &self, predicate: &str, now_ms: u64, ) -> Vec<&PrivacyTuple>

Query tuples by predicate.

Source

pub fn get(&self, id: &str) -> Option<&PrivacyTuple>

Get a tuple by ID.

Source

pub fn prune_expired(&mut self, now_ms: u64) -> usize

Prune expired tuples via ZK proof of expiry.

Returns the number of tuples pruned.

Source

pub fn anchor_all(&mut self) -> String

Anchor all un-anchored tuples to Wyqcc L1.

Returns a Merkle root of all anchor hashes.

Source

pub fn homomorphic_add( &self, id_a: &str, id_b: &str, ) -> Result<Vec<u8>, PrivacyError>

Not actually homomorphic — XORs two object fields byte-for-byte. XOR-ing arbitrary ciphertext bytes does not correspond to addition of the underlying plaintexts under any scheme used elsewhere in this crate (AES-GCM, the real LWE scheme in crate::fhe). Kept for compatibility; do not rely on the result meaning “a + b.”

Source

pub fn active_count(&self, now_ms: u64) -> usize

Returns the total number of active (non-expired) tuples.

Source

pub fn total_count(&self) -> u64

Returns the total number of tuples ever inserted.

Trait Implementations§

Source§

impl Debug for TupleChain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TupleChain

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.