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
impl TupleChain
pub fn new() -> Self
Sourcepub fn insert(&mut self, tuple: PrivacyTuple) -> String
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).
Sourcepub fn query_by_subject(&self, subject: &str, now_ms: u64) -> Vec<&PrivacyTuple>
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.
Sourcepub fn query_by_predicate(
&self,
predicate: &str,
now_ms: u64,
) -> Vec<&PrivacyTuple>
pub fn query_by_predicate( &self, predicate: &str, now_ms: u64, ) -> Vec<&PrivacyTuple>
Query tuples by predicate.
Sourcepub fn get(&self, id: &str) -> Option<&PrivacyTuple>
pub fn get(&self, id: &str) -> Option<&PrivacyTuple>
Get a tuple by ID.
Sourcepub fn prune_expired(&mut self, now_ms: u64) -> usize
pub fn prune_expired(&mut self, now_ms: u64) -> usize
Prune expired tuples via ZK proof of expiry.
Returns the number of tuples pruned.
Sourcepub fn anchor_all(&mut self) -> String
pub fn anchor_all(&mut self) -> String
Anchor all un-anchored tuples to Wyqcc L1.
Returns a Merkle root of all anchor hashes.
Sourcepub fn homomorphic_add(
&self,
id_a: &str,
id_b: &str,
) -> Result<Vec<u8>, PrivacyError>
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.”
Sourcepub fn active_count(&self, now_ms: u64) -> usize
pub fn active_count(&self, now_ms: u64) -> usize
Returns the total number of active (non-expired) tuples.
Sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Returns the total number of tuples ever inserted.