Skip to content

Commit 2fb2991

Browse files
committed
Fix readthedocs compilation
1 parent a0a1430 commit 2fb2991

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

Pyfhel/PyCtxt.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ cdef class PyCtxt:
9393

9494
@property
9595
def scheme(self):
96-
"""scheme: returns the scheme type.
96+
"""scheme: returns the FHE scheme of this ciphertext.
9797
9898
Can be set to: none, bfv, bgv (INTEGER) or ckks (FRACTIONAL).
9999

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#
7676
# This is also used if you do content translation via gettext catalogs.
7777
# Usually you set "language" from the command line for these cases.
78-
language = None
78+
language = 'en'
7979

8080
# List of patterns, relative to source directory, that match files and
8181
# directories to ignore when looking for source files.
@@ -232,7 +232,6 @@
232232
intersphinx_mapping = {
233233
'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None),
234234
'numpy': ('https://numpy.org/doc/stable/', None),
235-
'np': ('https://numpy.org/doc/stable/', None),
236235
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
237236
'Pyfhel': ('https://pyfhel.readthedocs.io/en/latest/', None),
238237
}

docs/source/getting_started/1_installation.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ To uninstall, just run:
2424
**Installing a C/C++ Compiler**
2525

2626
`Pyfhel` requires a C/C++ compiler with C++17 support. We have tested:
27-
- *gcc6* to *gcc12* in Linux/MacOS/Windows WSL. To install:
27+
- *gcc6* to *gcc14* in Linux/MacOS/Windows. To install:
28+
2829
- Ubuntu: `sudo apt install gcc g++`
2930
- MacOS: `brew install gcc`. MacOS users must also set several environment variables by running:
30-
```bash
31+
32+
.. code-block:: bash
33+
3134
# Brew installs GCC in /opt/homebrew/bin on Apple Silicon and /usr/local/bin on Intel.
3235
if [[ $(uname -m) = "arm64" ]]; then BREW_GCC_PATH="/opt/homebrew/bin"; else BREW_GCC_PATH="/usr/local/bin"; fi
3336
@@ -38,6 +41,7 @@ To uninstall, just run:
3841
# Set MACOSX_DEPLOYMENT_TARGET to avoid version mismatch warnings
3942
echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)" >> $GITHUB_ENV
4043
echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOSX_DEPLOYMENT_TARGET }}"
41-
```
44+
4245
- *MSVC2017* and *MSVC2019* in Windows. To install:
46+
4347
- Install Visual C++ Build tools (Download `here <https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170>`, guide in `here <https://stackoverflow.com/questions/40504552>`)

examples/Demo_9_Integer_BGV.py

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
"""
22
Integer FHE with BGV scheme
33
========================================
4-
//TODO
5-
"""
6-
7-
# %%
8-
# 1. Imports
9-
# ---------------------------
10-
# We start by importing the library
11-
12-
import numpy as np
13-
from Pyfhel import Pyfhel
144
15-
print("\n1. Pyfhel Import")
5+
This demo showcases the use of the BGV scheme for integer FHE operations.
6+
"""
167

178

189
# %%
19-
# 2. BGV context and key setup
10+
# 1. BGV context and key setup
2011
# ------------------------------------------------------------------------------
2112
# We take a look at the different parameters that can be set for the BGV scheme.
13+
import numpy as np
14+
from Pyfhel import Pyfhel
2215
HE = Pyfhel() # Creating empty Pyfhel object
2316

2417
# HE.contextGen(scheme='bgv', n=2**14, t_bits=20) # Generate context for 'bfv'/'bgv'/'ckks' scheme
@@ -42,12 +35,12 @@
4235
HE.rotateKeyGen() # Rotate key generation --> Allows rotation/shifting
4336
HE.relinKeyGen() # Relinearization key generation
4437

45-
print("\n2. Pyfhel FHE context generation")
38+
print("\n1. Pyfhel FHE context generation")
4639
print(f"\t{HE}")
4740

4841

4942
# %%
50-
# 3. BGV Integer Encryption
43+
# 2. BGV Integer Encryption
5144
# ---------------------------
5245
# we will define two integers and encrypt them using `encryptBGV`:
5346
integer1 = np.array([127], dtype=np.int64)
@@ -63,20 +56,20 @@
6356
print(ctxt2)
6457

6558
# %%
66-
# 4. Operating with encrypted integers in BGV
59+
# 3. Operating with encrypted integers in BGV
6760
# ---------------------------------------------
6861
# Relying on the context defined before, we will now operate
6962
# (addition, substaction, multiplication) the two ciphertexts:
7063
ctxtSum = ctxt1 + ctxt2 # `ctxt1 += ctxt2` for inplace operation
7164
ctxtSub = ctxt1 - ctxt2 # `ctxt1 -= ctxt2` for inplace operation
7265
ctxtMul = ctxt1 * ctxt2 # `ctxt1 *= ctxt2` for inplace operation
73-
print("\n4. Operating with encrypted integers")
66+
print("\n3. Operating with encrypted integers")
7467
print(f"Sum: {ctxtSum}")
7568
print(f"Sub: {ctxtSub}")
7669
print(f"Mult:{ctxtMul}")
7770

7871
# %%
79-
# 5. Decrypting BGV integers
72+
# 4. Decrypting BGV integers
8073
# ------------------------------
8174
# Once we're finished with the encrypted operations, we can use
8275
# the Pyfhel instance to decrypt the results using `decryptBGV`:
@@ -85,14 +78,14 @@
8578
resSub = HE.decrypt(ctxtSub) # `decrypt` function detects the scheme and
8679
# calls the corresponding decryption function.
8780
resMul = HE.decryptBGV(ctxtMul)
88-
print("\n5. Decrypting result:")
81+
print("\n4. Decrypting BGV result:")
8982
print(" addition: decrypt(ctxt1 + ctxt2) = ", resSum)
9083
print(" substraction: decrypt(ctxt1 - ctxt2) = ", resSub)
9184
print(" multiplication: decrypt(ctxt1 + ctxt2) = ", resMul)
9285

9386

9487
# %%
95-
# 6. Integer Array Encoding & Encryption
88+
# 5. BGV Integer Array Encoding & Encryption
9689
# ------------------------------------------------------------------------------
9790
# we will define two 1D integer arrays, encode and encrypt them:
9891
# arr1 = [0, 1, ... n-1] (length n)
@@ -121,7 +114,7 @@
121114
print("->\tarr2 ", arr2,'\n\t==> ptxt2 ', ptxt2,'\n\t==> ctxt2 ', ctxt2)
122115

123116
# %%
124-
# 7. Securely operating on encrypted ingeger arrays
117+
# 6. BGV Integer Array Encoding & Encryption
125118
# ------------------------------------------------------------------------------
126119
# We try all the operations supported by Pyfhel.
127120
# Note that, to operate, the ciphertexts/plaintexts must be built with the same
@@ -157,7 +150,7 @@
157150
# `ctxt1 *= ctxt2` for inplace operation
158151

159152

160-
print("\n7. Secure operations")
153+
print("\n6. Secure BGV operations")
161154
print(" Ciphertext-ciphertext: ")
162155
print("->\tctxt1 + ctxt2 = ccSum: ", ccSum)
163156
print("->\tctxt1 - ctxt2 = ccSub: ", ccSub)
@@ -175,7 +168,7 @@
175168

176169

177170
# %%
178-
# 8. BGV Relinearization: What, why, when
171+
# 7. BGV Relinearization: What, why, when
179172
# ------------------------------------------------------------------------------
180173
# Ciphertext-ciphertext multiplications increase the size of the polynoms
181174
# representing the resulting ciphertext. To prevent this growth, the
@@ -188,14 +181,14 @@
188181
#
189182
# Note that HE.power performs relinearization after every multiplication.
190183

191-
print("\n8. Relinearization-> Right after each multiplication.")
184+
print("\n7. Relinearization-> Right after each multiplication.")
192185
print(f"ccMul before relinearization (size {ccMul.size()}): {ccMul}")
193186
~ccMul # Equivalent to HE.relinearize(ccMul). Relin always happens in-place.
194187
print(f"ccMul after relinearization (size {ccMul.size()}): {ccMul}")
195188
print(f"cPow after 2 mult&relin rounds: (size {cPow.size()}): {cPow}")
196189

197190
# %%
198-
# 9. Decrypt & Decode results
191+
# 8. Decrypt & Decode results
199192
# ------------------------------------------------------------------------------
200193
# Time to decrypt results! We use HE.decryptBGV for this.
201194
# HE.decrypt() could also be used, in which case the decryption type would be
@@ -214,7 +207,7 @@
214207
rcpSub = HE.decryptBGV(cpSub)
215208
rcpMul = HE.decryptBGV(cpMul)
216209

217-
print("\n9. Decrypting results")
210+
print("\n8. Decrypting results")
218211
print(" Original ciphertexts: ")
219212
print(" ->\tctxt1 --(decr)--> ", r1)
220213
print(" ->\tctxt2 --(decr)--> ", r2)

0 commit comments

Comments
 (0)