Created
June 19, 2020 09:29
-
-
Save dhuynh95/98f77211ca060240c3ec4c5182426931 to your computer and use it in GitHub Desktop.
Markdium-Introduction to encoding in CKKS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@patch_to(CKKSEncoder) | |
def pi(self, z: np.array) -> np.array: | |
"""Projects a vector of H into C^{N/2}.""" | |
N = self.M // 4 | |
return z[:N] | |
@patch_to(CKKSEncoder) | |
def pi_inverse(self, z: np.array) -> np.array: | |
"""Expands a vector of C^{N/2} by expanding it with its | |
complex conjugate.""" | |
z_conjugate = z[::-1] | |
z_conjugate = [np.conjugate(x) for x in z_conjugate] | |
return np.concatenate([z, z_conjugate]) | |
# We can now initialize our encoder with the added methods | |
encoder = CKKSEncoder(M) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment