Spaces:
Runtime error

dnasafe commited on
Commit
ca4d4cf
·
verified ·
1 Parent(s): e00bc68

fix count

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -27,23 +27,24 @@ def secure_encoding(input_data):
27
  print("Encrypted Ciphertext of the First Element:", encrypted_data[0].ciphertext())
28
 
29
  # Perform homomorphic addition to count smokers
30
- encrypted_sum = encrypted_data[0]
31
- for enc_value in encrypted_data[1:]:
32
- encrypted_sum = paillier.ciphertext_add(encrypted_sum, enc_value)
 
33
 
34
  # Output encrypted count
35
  print("Result is also encrypted")
36
  print("========================")
37
- print("Encrypted Count:", encrypted_sum)
38
-
39
  # Send result to the data owner
40
- decrypted_count = private_key.decrypt(encrypted_sum)
41
  print("Send result to the data owner")
42
  print("Decrypted Count:", decrypted_count)
43
 
44
  return (
45
  f"Encrypted Ciphertext of the First Element: {encrypted_data[0].ciphertext()}",
46
- f"Encrypted Count: {encrypted_sum}",
47
  f"Decrypted Count: {decrypted_count}",
48
  "Data processing is complete. The encrypted data and count have been generated."
49
  )
 
27
  print("Encrypted Ciphertext of the First Element:", encrypted_data[0].ciphertext())
28
 
29
  # Perform homomorphic addition to count smokers
30
+ encrypted_count = encrypted_data[0]
31
+
32
+ for i in range(1, len(encrypted_data)):
33
+ encrypted_count += encrypted_data[i]
34
 
35
  # Output encrypted count
36
  print("Result is also encrypted")
37
  print("========================")
38
+ print("Encrypted Count:", encrypted_count)
39
+
40
  # Send result to the data owner
41
+ decrypted_count = private_key.decrypt(encrypted_count)
42
  print("Send result to the data owner")
43
  print("Decrypted Count:", decrypted_count)
44
 
45
  return (
46
  f"Encrypted Ciphertext of the First Element: {encrypted_data[0].ciphertext()}",
47
+ f"Encrypted Count: {encrypted_count}",
48
  f"Decrypted Count: {decrypted_count}",
49
  "Data processing is complete. The encrypted data and count have been generated."
50
  )