pryvx 2.1.0__py3-none-any.whl → 2.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pryvx/phe.py CHANGED
@@ -43,10 +43,22 @@ class PHE:
43
43
  x = pow(ciphertext, lambda_n, n2)
44
44
  Lx = (x - 1) // n
45
45
  plaintext = (Lx * mu) % n
46
+
47
+ # Adjust for negative results
48
+ if plaintext > n // 2: # If the result is greater than n/2, it's negative
49
+ plaintext -= n
50
+
46
51
  return plaintext
47
52
 
48
53
  @staticmethod
49
54
  def homomorphic_add(c1, c2, public_key):
50
55
  n, _ = public_key
51
56
  n2 = n * n
52
- return (c1 * c2) % n2
57
+ return (c1 * c2) % n2
58
+
59
+ @staticmethod
60
+ def homomorphic_sub(c1, c2, public_key):
61
+ n, _ = public_key
62
+ n2 = n * n
63
+ c2_inv = mod_inverse(c2, n2)
64
+ return (c1 * c2_inv) % n2
pryvx/psi.py CHANGED
@@ -4,7 +4,7 @@ import hmac
4
4
 
5
5
  # OPRF-related functions
6
6
  def generate_key():
7
- return random.getrandbits(256).to_bytes(32, byteorder='big')
7
+ return random.getrandbits(256)
8
8
 
9
9
  def oprf(key, value):
10
10
  return hmac.new(key, value.encode(), hashlib.sha256).digest()
@@ -25,10 +25,12 @@ class OPRF:
25
25
 
26
26
  @staticmethod
27
27
  def get_hash(element, server_key):
28
+ server_key = server_key.to_bytes(32, byteorder='big')
28
29
  return hash_element(element, server_key)
29
30
 
30
31
  @staticmethod
31
32
  def get_batch_hash(X, batch_size, server_key):
33
+ server_key = server_key.to_bytes(32, byteorder='big')
32
34
  elements = list(set(X))
33
35
  batches_a = [elements[i:i + batch_size] for i in range(0, len(elements), batch_size)]
34
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pryvx
3
- Version: 2.1.0
3
+ Version: 2.3.0
4
4
  Summary: A comprehensive package for privacy-enhancing technologies
5
5
  Home-page: UNKNOWN
6
6
  Author: PryvX (Jayesh Kenaudekar)
@@ -2,13 +2,13 @@ pryvx/__init__.py,sha256=A6GcpkYgwgf_HOrneIhGs3iTsiEyvd9vYEMsmrMUqWQ,89
2
2
  pryvx/fl_client.py,sha256=p8QPlv5-CjTCwfzN0QkPr7bjKJEbU3c9Aa3HhpvZNJE,677
3
3
  pryvx/fl_server.py,sha256=9fUqZfA9RZOe0fM7FYnk_8qLNw6VMj-x8tzeGXZpgKA,890
4
4
  pryvx/gdp.py,sha256=-HK3Xml-huOdfz2SSmBvpgca0iU9-RwCiaD6ZyMq7bY,408
5
- pryvx/phe.py,sha256=CQN15AGXq_tkvDlhs8eHjqxmMMSqBtUPOn2_joKcRX0,1351
5
+ pryvx/phe.py,sha256=o7vVax6WtbYMUKUEP1eVf3vskO7i9rEpIOFrd6Kp868,1709
6
6
  pryvx/pryvx_pb2.py,sha256=-ce40VMW0nQcjyhAJy1BvI32wtWNm425LSIExspK_qg,1200
7
7
  pryvx/pryvx_pb2_grpc.py,sha256=pRQKblTNIVEwHsMQmhC-HGJFzsLh0sdOzQ-ksFYVK-A,2437
8
- pryvx/psi.py,sha256=cFL9qFn6UK2nArFxcwTmOHPgJE6RFIbN5esKTo1Lm04,1250
8
+ pryvx/psi.py,sha256=V0BUJwYfiFWhKtEL27q45yxY7U-I7B4olKQhaGbgN50,1346
9
9
  pryvx/smpc.py,sha256=FZcE3gZo8WUVPmcBHSgP8iOkWt3AKcBLSLCtKczy8hs,2247
10
- pryvx-2.1.0.dist-info/LICENSE,sha256=pbIMXbaorAIVW-fDch2tvtZRkVA3mz-UnXQqeCf4LDg,1086
11
- pryvx-2.1.0.dist-info/METADATA,sha256=BfuQeIOB7c4ioIv7Xq-zroJyfaSrVp3KEP4y_Tj56X8,1066
12
- pryvx-2.1.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
13
- pryvx-2.1.0.dist-info/top_level.txt,sha256=1iHoeevu_FoFjdPg8HyMlgvHNUm1--9QEpFMaJEa4hw,6
14
- pryvx-2.1.0.dist-info/RECORD,,
10
+ pryvx-2.3.0.dist-info/LICENSE,sha256=pbIMXbaorAIVW-fDch2tvtZRkVA3mz-UnXQqeCf4LDg,1086
11
+ pryvx-2.3.0.dist-info/METADATA,sha256=NSKPdhcl_dlB9FCuEMr2YHct8qd3iItn7kLfTrPU4Bo,1066
12
+ pryvx-2.3.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
13
+ pryvx-2.3.0.dist-info/top_level.txt,sha256=1iHoeevu_FoFjdPg8HyMlgvHNUm1--9QEpFMaJEa4hw,6
14
+ pryvx-2.3.0.dist-info/RECORD,,
File without changes
File without changes