pryvx 2.1.0__tar.gz → 2.3.0__tar.gz

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.
@@ -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)
@@ -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
@@ -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)
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- VERSION = '2.1.0'
3
+ VERSION = '2.3.0'
4
4
 
5
5
 
6
6
  # Setting up
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes