pryvx 2.2.0__py3-none-any.whl → 2.4.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,6 +43,11 @@ 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
@@ -56,4 +61,16 @@ class PHE:
56
61
  n, _ = public_key
57
62
  n2 = n * n
58
63
  c2_inv = mod_inverse(c2, n2)
59
- return (c1 * c2_inv) % n2
64
+ return (c1 * c2_inv) % n2
65
+
66
+ @staticmethod
67
+ def homomorphic_scalar_mult(ciphertext, scalar, public_key):
68
+ n, g = public_key
69
+ n2 = n * n
70
+ return pow(ciphertext, scalar, n2)
71
+
72
+ @staticmethod
73
+ def homomorphic_div(ciphertext, divisor, public_key):
74
+ n, g = public_key
75
+ divisor_inv = mod_inverse(divisor, n) # Find the modular inverse of the divisor modulo n
76
+ return PHE.homomorphic_scalar_mult(ciphertext, divisor_inv, public_key)
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.2.0
3
+ Version: 2.4.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=FSwACSG7ZIQLY_MCPc99Vq8Msw_3xlwMLzJc6AKQ-c8,1542
5
+ pryvx/phe.py,sha256=NLYaLFCNN5aQfL0kC1YTUi962e930p2ae5dw3flJ0qo,2178
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.2.0.dist-info/LICENSE,sha256=pbIMXbaorAIVW-fDch2tvtZRkVA3mz-UnXQqeCf4LDg,1086
11
- pryvx-2.2.0.dist-info/METADATA,sha256=TNPB876sPd1sdWTYssOUsukdydF8BWfSJ4NhOo725S4,1066
12
- pryvx-2.2.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
13
- pryvx-2.2.0.dist-info/top_level.txt,sha256=1iHoeevu_FoFjdPg8HyMlgvHNUm1--9QEpFMaJEa4hw,6
14
- pryvx-2.2.0.dist-info/RECORD,,
10
+ pryvx-2.4.0.dist-info/LICENSE,sha256=pbIMXbaorAIVW-fDch2tvtZRkVA3mz-UnXQqeCf4LDg,1086
11
+ pryvx-2.4.0.dist-info/METADATA,sha256=PhZ10Rw7ngp_mhVp2Au9YED-g_KMVKtHmUpDp4e0Zqg,1066
12
+ pryvx-2.4.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
13
+ pryvx-2.4.0.dist-info/top_level.txt,sha256=1iHoeevu_FoFjdPg8HyMlgvHNUm1--9QEpFMaJEa4hw,6
14
+ pryvx-2.4.0.dist-info/RECORD,,
File without changes
File without changes