pryvx 2.4.8__tar.gz → 2.5.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.4.8
3
+ Version: 2.5.0
4
4
  Summary: A comprehensive package for privacy-enhancing technologies
5
5
  Home-page: UNKNOWN
6
6
  Author: PryvX (Jayesh Kenaudekar)
@@ -34,5 +34,7 @@ def send_params(serialized_model, connection_url, client_id):
34
34
 
35
35
  response = stub.SendModelParams(model_params, metadata=metadata)
36
36
 
37
+ print(f"✅ Model Params sent to server from {client_id}")
38
+
37
39
  return f"✅ Model Params sent to server from {client_id}"
38
40
 
@@ -1,6 +1,7 @@
1
1
  import random
2
2
  from sympy import mod_inverse, isprime, nextprime
3
3
  import math
4
+ import hashlib
4
5
 
5
6
  def generate_prime(bits=512):
6
7
  while True:
@@ -29,6 +30,11 @@ class PHE:
29
30
  @staticmethod
30
31
  def encode(value, scale_factor=1000):
31
32
  return int(round(value * scale_factor))
33
+
34
+ @staticmethod
35
+ def hash_to_bigint(data: str) -> int:
36
+ digest = hashlib.sha256(data.encode()).hexdigest()
37
+ return int(digest, 16)
32
38
 
33
39
  @staticmethod
34
40
  def decode(value, scale_factor=1000):
@@ -0,0 +1,34 @@
1
+ import random
2
+ import hashlib
3
+
4
+ def getAdditiveShares(secret, N, fieldSize):
5
+ shares = [random.randrange(fieldSize) for _ in range(N-1)]
6
+ shares.append((secret - sum(shares)) % fieldSize )
7
+ return shares
8
+
9
+ class SMPC:
10
+ def __init__(self) -> None:
11
+ self.fieldSize = 293973345475167247070445277780365744413
12
+
13
+ def encode(self, secret, scale_factor=1000):
14
+ return int(secret * scale_factor)
15
+
16
+ def decode(self, upscaled, scale_factor=1000):
17
+ return upscaled / scale_factor
18
+
19
+ def get_field_size(self):
20
+ return self.fieldSize
21
+
22
+ def get_secret_shares(self, secret, N):
23
+ shares = getAdditiveShares(secret, N, self.fieldSize)
24
+ return shares
25
+
26
+ def hash_to_bigint(self, data: str) -> int:
27
+ digest = hashlib.sha256(data.encode()).hexdigest()
28
+ return int(digest, 16)
29
+
30
+ def reconstruct(self, share):
31
+ return share % self.fieldSize
32
+
33
+ def additive_reconstruct(self, shares):
34
+ return sum(shares) % self.fieldSize
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pryvx
3
- Version: 2.4.8
3
+ Version: 2.5.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.4.8'
3
+ VERSION = '2.5.0'
4
4
 
5
5
 
6
6
  # Setting up
pryvx-2.4.8/pryvx/smpc.py DELETED
@@ -1,59 +0,0 @@
1
- import random
2
-
3
- def getAdditiveShares(secret, N, fieldSize):
4
- shares = [random.randrange(fieldSize) for i in range(N-1)]
5
- shares.append((secret - sum(shares)) % fieldSize )
6
- return shares
7
-
8
- def reconstructSecret(shares, fieldSize):
9
- return sum(shares) % fieldSize
10
-
11
-
12
- class SMPC:
13
- def __init__(self) -> None:
14
- self.BASE = 10
15
- self.PRECISION_INTEGRAL = 8
16
- self.PRECISION_FRACTIONAL = 8
17
- self.fieldSize = 293973345475167247070445277780365744413
18
-
19
- self.PRECISION = self.PRECISION_INTEGRAL + self.PRECISION_FRACTIONAL
20
- assert(self.fieldSize > self.BASE**self.PRECISION)
21
-
22
- def encode(self, rational):
23
- upscaled = int(rational * self.BASE**self.PRECISION_FRACTIONAL)
24
- field_element = upscaled % self.fieldSize
25
- return field_element
26
-
27
- def decode(self, field_element):
28
- upscaled = field_element if field_element <= self.fieldSize/2 else field_element - self.fieldSize
29
- rational = upscaled / self.BASE**self.PRECISION_FRACTIONAL
30
- return rational
31
-
32
- def get_secret_shares(self, m, N):
33
- N = N + 1
34
- shares = getAdditiveShares(self.encode(m), N, self.fieldSize)
35
- return shares
36
-
37
- def addition(self, shares_list):
38
- aggregate_shares = [sum(x) % self.fieldSize for x in shares_list]
39
- return self.decode(reconstructSecret(aggregate_shares, self.fieldSize))
40
-
41
- def multiplication(self):
42
- pass
43
-
44
- def difference(self, shares_a, shares_b):
45
- difference_shares = [(a - b) % self.fieldSize for a, b in zip(shares_a, shares_b)]
46
- return self.decode(reconstructSecret(difference_shares, self.fieldSize))
47
-
48
- def compare(self, shares_a, shares_b):
49
- difference_shares = [(a - b) % self.fieldSize for a, b in zip(shares_a, shares_b)]
50
- reconstructed_difference = self.decode(reconstructSecret(difference_shares, self.fieldSize))
51
-
52
- if reconstructed_difference == 0:
53
- comparison_result = "a is equal to b"
54
- elif reconstructed_difference > 0:
55
- comparison_result = "a is greater than b"
56
- else:
57
- comparison_result = "a is less than b"
58
-
59
- return comparison_result
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
File without changes