|
|
| ALUOptimized (ComputeFHE *cfhe) |
| |
|
virtual BinaryDigit | FHE_MAJ (const BinaryDigit &a, const BinaryDigit &b, const BinaryDigit &c) |
| |
|
virtual BinaryDigit | FHE_XOR3 (const BinaryDigit &a, const BinaryDigit &b, const BinaryDigit &c) |
| |
|
virtual BinaryDigit | FHE_MulAdd (const BinaryDigit &m, const BinaryDigit &a, const BinaryDigit &b, BinaryDigit *carry_out=nullptr) |
| |
| virtual BinaryDigit | FHE_MUX (const BinaryDigit &s, const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_DigitSum (const BinaryDigit &e1, const BinaryDigit &e0, const BinaryDigit &s0) |
| |
| virtual BinaryDigit | Gate_MAJ (const BinaryDigit &a, const BinaryDigit &b, const BinaryDigit &c) |
| | Majority gate: returns true if at least two inputs are true.
|
| |
| virtual BinaryDigit | Gate_XOR3 (const BinaryDigit &a, const BinaryDigit &b, const BinaryDigit &c) |
| | 3-input XOR gate.
|
| |
| virtual BinaryDigit | Gate_MulAdd (const BinaryDigit &m, const BinaryDigit &a, const BinaryDigit &b, BinaryDigit *carry_out=nullptr) |
| | Multiplies two digits and adds a third, optionally returning carry out.
|
| |
| virtual BinaryDigit | Gate_DigitSum (const BinaryDigit &e1, const BinaryDigit &e0, const BinaryDigit &s0) |
| | Performs bitwise digit summation logic.
|
| |
| virtual void | FullAdder (const BinaryDigit &a, const BinaryDigit &b, const BinaryDigit &c, BinaryDigit &sum, BinaryDigit &carry_out) |
| | 1-bit full adder with explicit carry-in.
|
| |
| virtual BinaryDigit | CmpLTEq_U (const FixedPoint &a, const FixedPoint &b) |
| | Unsigned Less-Than or Equal.
|
| |
| virtual BinaryDigit | CmpGT_U (const FixedPoint &a, const FixedPoint &b) |
| | Unsigned Greater-Than.
|
| |
| virtual FixedPoint | FullMul (const FixedPoint &a, const FixedPoint &b) |
| | Performs full multiplication resulting in potentially larger bit-width.
|
| |
| virtual FixedPoint | Mul (const FixedPoint &a, const FixedPoint &b) |
| | Standard multiplication (truncated to input width).
|
| |
| virtual void | Swap_if (const BinaryDigit &cond, BinaryDigit &a, BinaryDigit &b) |
| | Conditional swap of two bits if 'cond' is true.
|
| |
| virtual FixedPoint | PAdd (const FixedPoint &a, const FixedPoint &pb) |
| | Plaintext addition: result = a + pb.
|
| |
| virtual FixedPoint | PAddC (const FixedPoint &a, const FixedPoint &pb) |
| | Plaintext addition with carry.
|
| |
| virtual FixedPoint | PAddNC (const FixedPoint &a, const FixedPoint &pb) |
| | Plaintext addition without updating internal carry.
|
| |
| virtual FixedPoint | PAddCNC (const FixedPoint &a, const FixedPoint &pb) |
| | Plaintext addition with carry, but no update to internal state.
|
| |
| virtual FixedPoint | PSub (const FixedPoint &pa, const FixedPoint &b) |
| | Plaintext subtraction: result = pa - b.
|
| |
| virtual FixedPoint | PSubC (const FixedPoint &pa, const FixedPoint &b) |
| | Plaintext subtraction with carry.
|
| |
| virtual FixedPoint | PSubNC (const FixedPoint &pa, const FixedPoint &b) |
| | Plaintext subtraction without updating internal carry.
|
| |
| virtual FixedPoint | PSubCNC (const FixedPoint &pa, const FixedPoint &b) |
| | Plaintext subtraction with carry, but no update to internal state.
|
| |
| virtual FixedPoint | Neg (const FixedPoint &a) |
| | Arithmetic negation: result = -a.
|
| |
| virtual uint | Get_CtCtAdd_Cost (size_t n_bits) |
| |
| virtual uint | Get_CtCtAddNC_Cost (size_t n_bits) |
| |
| virtual uint | Get_CtCtSubC_Cost (size_t n_bits) |
| |
| virtual uint | Get_CtPtAddC_Cost (size_t n_bits) |
| |
| virtual uint | Get_PtCtSub_Cost (size_t n_bits) |
| |
| virtual uint | Get_CtPtSubCNC_Cost (size_t n_bits) |
| |
| virtual uint | Get_CtNeg_Cost (size_t n_bits) |
| |
Public Member Functions inherited from computefhe::ALUStandard |
|
| ALUStandard (ComputeFHE *cfhe) |
| |
| virtual FixedPoint | Mux (const BinaryDigit &s, const FixedPoint &a, const FixedPoint &b) |
| | Multiplexer for FixedPoint values: returns 'a' if 's' is true, else 'b'.
|
| |
| virtual FixedPoint | ToggleMSB (const FixedPoint &a) |
| | Toggles the Most Significant Bit (useful for sign manipulation).
|
| |
| virtual FixedPoint | ShiftLeft (const FixedPoint &a, size_t shift) |
| | Logical shift left.
|
| |
| virtual FixedPoint | ShiftRight (const FixedPoint &a, size_t shift, bool is_arithmetic=false) |
| | Shift right (supports both logical and arithmetic/signed shifts).
|
| |
| virtual void | Swap_if (const BinaryDigit &cond, FixedPoint &a, FixedPoint &b) |
| | Conditional swap of two FixedPoint values if 'cond' is true.
|
| |
| virtual void | HalfAdder (const BinaryDigit &a, const BinaryDigit &b, BinaryDigit &sum, BinaryDigit &carry_out) |
| | 1-bit half adder.
|
| |
| virtual void | HalfSubtractor (const BinaryDigit &a, const BinaryDigit &b, BinaryDigit &sum, BinaryDigit &carry_out) |
| | 1-bit half subtractor.
|
| |
| virtual FixedPoint | Add (const FixedPoint &a, const FixedPoint &b) |
| | Addition: result = a + b.
|
| |
| virtual FixedPoint | AddC (const FixedPoint &a, const FixedPoint &b) |
| | Addition with Carry: result = a + b + carry.
|
| |
| virtual FixedPoint | AddNC (const FixedPoint &a, const FixedPoint &b) |
| | Addition without updating internal carry.
|
| |
| virtual FixedPoint | AddCNC (const FixedPoint &a, const FixedPoint &b) |
| | Addition with Carry, but without updating internal carry.
|
| |
| virtual FixedPoint | Sub (const FixedPoint &a, const FixedPoint &b) |
| | Subtraction: result = a - b.
|
| |
| virtual FixedPoint | SubC (const FixedPoint &a, const FixedPoint &b) |
| | Subtraction with Borrow (!Carry): result = a - b - !carry.
|
| |
| virtual FixedPoint | SubNC (const FixedPoint &a, const FixedPoint &b) |
| | Subtraction without updating internal carry.
|
| |
| virtual FixedPoint | SubCNC (const FixedPoint &a, const FixedPoint &b) |
| | Subtraction with Carry, but without updating internal carry.
|
| |
| virtual FixedPoint | Not (const FixedPoint &a) |
| | Bitwise NOT.
|
| |
| virtual BinaryDigit | CmpNotEq (const FixedPoint &a, const FixedPoint &b) |
| | Not-Equal.
|
| |
| virtual BinaryDigit | CmpEq (const FixedPoint &a, const FixedPoint &b) |
| | Equal.
|
| |
| virtual BinaryDigit | CmpGTEq_U (const FixedPoint &a, const FixedPoint &b) |
| | Unsigned Greater-Than or Equal.
|
| |
| virtual BinaryDigit | CmpLT_U (const FixedPoint &a, const FixedPoint &b) |
| | Unsigned Less-Than.
|
| |
| virtual BinaryDigit | CmpLTEq (const FixedPoint &a, const FixedPoint &b) |
| | Signed Less-Than or Equal.
|
| |
| virtual BinaryDigit | CmpGT (const FixedPoint &a, const FixedPoint &b) |
| | Signed Greater-Than.
|
| |
| virtual BinaryDigit | CmpGTEq (const FixedPoint &a, const FixedPoint &b) |
| | Signed Greater-Than or Equal.
|
| |
| virtual BinaryDigit | CmpLT (const FixedPoint &a, const FixedPoint &b) |
| | Signed Less-Than.
|
| |
| virtual void | DivU (const FixedPoint &a, const FixedPoint &b, FixedPoint &q, FixedPoint &r) |
| | Unsigned division, calculating quotient (q) and remainder (r).
|
| |
| virtual FixedPoint | CPSub (const FixedPoint &a, const FixedPoint &pb) |
| | Ciphertext-Plaintext subtraction: result = a - pb.
|
| |
| virtual FixedPoint | CPSubC (const FixedPoint &a, const FixedPoint &pb) |
| | Ciphertext-Plaintext subtraction with carry.
|
| |
| virtual FixedPoint | CPSubNC (const FixedPoint &a, const FixedPoint &pb) |
| | Ciphertext-Plaintext subtraction without updating internal carry.
|
| |
| virtual FixedPoint | CPSubCNC (const FixedPoint &a, const FixedPoint &pb) |
| | Ciphertext-Plaintext subtraction with carry, no update.
|
| |
| virtual FixedPoint | PFullMul (const FixedPoint &a, const FixedPoint &pb) |
| | Full multiplication by a plaintext constant.
|
| |
| virtual FixedPoint | PFullMulFast (const FixedPoint &a, const FixedPoint &pb) |
| | Optimized full multiplication by a plaintext constant.
|
| |
| virtual FixedPoint | PBoothsMul (const FixedPoint &a, const FixedPoint &pb) |
| | Multiplication using Booth's algorithm with a plaintext constant.
|
| |
| virtual FixedPoint | PMul (const FixedPoint &a, const FixedPoint &pb) |
| | Standard multiplication by a plaintext constant.
|
| |
| virtual FixedPoint | PMulFast (const FixedPoint &a, const FixedPoint &pb) |
| | Optimized standard multiplication by a plaintext constant.
|
| |
|
virtual uint | Get_CtCtSubNC_Cost (size_t n_bits) |
| |
|
virtual uint | Get_PtFullMul_Cost (const FixedPoint &pt, size_t ct_n_bits, size_t &out_n_bits) |
| |
|
virtual uint | Get_Pt2sCompFullMul_Cost (const FixedPoint &pt, size_t ct_n_bits) |
| |
|
virtual uint | Get_PtMul_Cost (const FixedPoint &pt) |
| |
|
virtual uint | Get_Pt2sCompMul_Cost (const FixedPoint &pt) |
| |
|
virtual uint | Get_BoothsMul_Cost (const FixedPoint &pt, size_t ct_n_bits) |
| |
| | BaseALU (ComputeFHE *cfhe) |
| | Construct a new BaseALU object.
|
| |
|
virtual | ~BaseALU () |
| | Destroy the BaseALU object.
|
| |
|
virtual BinaryDigit | GetCarry () |
| | Returns the current internal carry state.
|
| |
|
virtual void | SetCarry (BinaryDigit value) |
| | Manually sets the internal carry to a specific value.
|
| |
|
virtual void | SetCarry () |
| | Sets the internal carry to an encrypted 'True' value.
|
| |
|
virtual void | ResetCarry () |
| | Resets the internal carry to an encrypted 'False' value.
|
| |
|
virtual BinaryDigit | FHE_False () |
| |
|
virtual BinaryDigit | FHE_True () |
| |
|
virtual BinaryDigit | FHE_AND (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_NAND (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_OR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_NOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_XOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_XNOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | FHE_NOT (const BinaryDigit &a) |
| |
|
virtual BinaryDigit | Constant0 () |
| | Returns encrypted constant 0 (false).
|
| |
|
virtual BinaryDigit | Constant1 () |
| | Returns encrypted constant 1 (true).
|
| |
|
virtual BinaryDigit | Gate_AND (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_NAND (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_OR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_NOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_XOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_XNOR (const BinaryDigit &a, const BinaryDigit &b) |
| |
|
virtual BinaryDigit | Gate_NOT (const BinaryDigit &a) |
| |
|
virtual BinaryDigit | Gate_MUX (const BinaryDigit &s, const BinaryDigit &a, const BinaryDigit &b) |
| |
Optimized ALU implementation using specialized multi-input FHE gates.
This class extends ALUStandard to provide faster arithmetic operations by utilizing 3-input kernels like MAJ and XOR3, and reduces bootstrapping overhead.