Skip to main content

prism_fhe/
verbs.rs

1//! Layer-3 substrate-Term verb bodies per [Wiki ADR-054][09-adr-054]
2//! decision 4 (canonical axis impl body discipline).
3//!
4//! Per ADR-054 (4) every canonical axis impl in the standard library
5//! carries a substrate-Term `verb!` body composing prism operators
6//! over substrate `PrimitiveOp`s; the verb body is the structural
7//! witness the catamorphism's fold-fusion reach extends into.
8//!
9//! [`add_ciphertexts_verb`] is the substrate-Term realization of
10//! `OneTimePadFhe<32>::add_ciphertexts` at the canonical
11//! 32-byte block width: a single `Term::Application { operator:
12//! PrimitiveOp::Xor }` at W256 over the partition-product of two
13//! ciphertext blocks. Per ADR-050's width-parametric arithmetic
14//! fold-rules the substrate evaluates this Xor at the full block
15//! width without truncation. Byte-output equivalence with the
16//! hand-written kernel is locked by `tests/conformance.rs`.
17//!
18//! The one-line substrate-Term form is what ADR-054 commits to: no
19//! opaque axis-kernel boundary inside the substrate's structural
20//! reach. The hand-written kernel in `fhe.rs` is retained for
21//! existing-API compatibility and inlining-friendly LLVM codegen per
22//! the three-way responsibility split in ADR-024 (structural
23//! correctness foundation-owned via the substrate-Term form;
24//! algorithm-strategy implementation-owned).
25//!
26//! [09-adr-054]: https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions
27
28#![allow(missing_docs)]
29
30use uor_foundation_sdk::{partition_product, verb};
31
32use crate::CiphertextShape;
33
34/// Concrete 32-byte ciphertext alias for partition-product
35/// composition. `partition_product!` parses operands as bare type
36/// paths; generic types like `CiphertextShape<32>` need a type
37/// alias for the macro's tokenizer to accept them.
38pub type Ciphertext32 = CiphertextShape<32>;
39
40partition_product!(CiphertextPair32, Ciphertext32, Ciphertext32);
41
42verb! {
43    pub fn add_ciphertexts_verb(input: CiphertextPair32) -> Ciphertext32 {
44        xor(input.0, input.1)
45    }
46}