Spaces:
Runtime error
Runtime error
fix count
Browse files
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 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
# Output encrypted count
|
| 35 |
print("Result is also encrypted")
|
| 36 |
print("========================")
|
| 37 |
-
print("Encrypted Count:",
|
| 38 |
-
|
| 39 |
# Send result to the data owner
|
| 40 |
-
decrypted_count = private_key.decrypt(
|
| 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: {
|
| 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 |
)
|