Files
zeekayandHanzo Dev c8bfbebc15 Keep ZAMA's copyright notices
This app is ZAMA's BSD 3-Clause Clear demo. The license requires its notices to
survive redistribution, and a rebrand had replaced every one of them with ours:
the LICENSE text, 66 source headers and the app's copyright string. They are
back, each with our line beside it for our changes.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-23 01:55:03 -07:00

39 lines
1.3 KiB
Swift

// Copyright © 2025 Zama. All rights reserved.
// Copyright © 2025 Lux Industries Inc.
import TFHE
extension FHEUInt16 {
// MARK: - COMPUTE (needs set_server_key() called) -
func addScalar(int: Int) throws -> FHEUInt16 {
var result: OpaquePointer? // FheUint16
try wrap { fhe_uint16_scalar_add(pointer, UInt16(int), &result) }
return FHEUInt16(pointer: result)
}
func addFHE(int: FHEUInt16) throws -> FHEUInt16 {
var result: OpaquePointer? // FheUint16
try wrap { fhe_uint16_add(pointer, int.pointer, &result) }
return FHEUInt16(pointer: result)
}
/// Warning: result is necessarily clipped (Int not Float)
func divScalar(int: Int) throws -> FHEUInt16 {
var result: OpaquePointer? // FheUint16
try wrap { fhe_uint16_scalar_div(pointer, UInt16(int), &result) }
return FHEUInt16(pointer: result)
}
func max(with int: FHEUInt16) throws -> FHEUInt16 {
var result: OpaquePointer? // FheUint16
try wrap { fhe_uint16_max(self.pointer, int.pointer, &result) }
return FHEUInt16(pointer: result)
}
func min(with int: FHEUInt16) throws -> FHEUInt16 {
var result: OpaquePointer? // FheUint16
try wrap { fhe_uint16_min(self.pointer, int.pointer, &result) }
return FHEUInt16(pointer: result)
}
}