Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -129,7 +129,7 @@ def encode_quantize(test_file, eval_key, encodings):
|
|
129 |
|
130 |
return encodings
|
131 |
|
132 |
-
def encrypt_encoded_quantize(encodings):
|
133 |
fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
|
134 |
fhe_api.load()
|
135 |
|
@@ -138,7 +138,7 @@ def encrypt_encoded_quantize(encodings):
|
|
138 |
encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
|
139 |
|
140 |
numpy.save(
|
141 |
-
f"tmp/tmp_encrypted_quantized_encoding_{
|
142 |
encrypted_quantized_encoding,
|
143 |
)
|
144 |
|
@@ -349,7 +349,7 @@ if __name__ == "__main__":
|
|
349 |
"The encrypted scan result is sent back to the client, who can finally decrypt it with their private key. Only the client is aware of the original file content and the scan result."
|
350 |
)
|
351 |
b_decrypt_result = gr.Button("π Decrypt scan result")
|
352 |
-
|
353 |
scan_result = gr.Textbox(label="Scan Result:")
|
354 |
|
355 |
eval_key_input = gr.Textbox(value=eval_key)
|
@@ -367,11 +367,10 @@ if __name__ == "__main__":
|
|
367 |
# Button to encrypt file
|
368 |
b_encrypt_file.click(
|
369 |
fn=encrypt_encoded_quantize,
|
370 |
-
inputs=[extracted_vector],
|
371 |
outputs=[encrypted_file],
|
372 |
)
|
373 |
|
374 |
-
user_id_input = gr.Textbox(value=user_id)
|
375 |
# Button to run FHE-based malware scan
|
376 |
b_run_fhe_scan.click(fn=run_fhe, inputs=[user_id_input], outputs=[encrypted_scan_result])
|
377 |
|
|
|
129 |
|
130 |
return encodings
|
131 |
|
132 |
+
def encrypt_encoded_quantize(encodings, user_id, eval_key):
|
133 |
fhe_api = FHEModelClient(f"fhe_model", f".fhe_keys/{eval_key}")
|
134 |
fhe_api.load()
|
135 |
|
|
|
138 |
encrypted_quantized_encoding = fhe_api.quantize_encrypt_serialize(encodings)
|
139 |
|
140 |
numpy.save(
|
141 |
+
f"tmp/tmp_encrypted_quantized_encoding_{user_id}.npy",
|
142 |
encrypted_quantized_encoding,
|
143 |
)
|
144 |
|
|
|
349 |
"The encrypted scan result is sent back to the client, who can finally decrypt it with their private key. Only the client is aware of the original file content and the scan result."
|
350 |
)
|
351 |
b_decrypt_result = gr.Button("π Decrypt scan result")
|
352 |
+
user_id_input = gr.Textbox(value=user_id)
|
353 |
scan_result = gr.Textbox(label="Scan Result:")
|
354 |
|
355 |
eval_key_input = gr.Textbox(value=eval_key)
|
|
|
367 |
# Button to encrypt file
|
368 |
b_encrypt_file.click(
|
369 |
fn=encrypt_encoded_quantize,
|
370 |
+
inputs=[extracted_vector, user_id_input, eval_key_input],
|
371 |
outputs=[encrypted_file],
|
372 |
)
|
373 |
|
|
|
374 |
# Button to run FHE-based malware scan
|
375 |
b_run_fhe_scan.click(fn=run_fhe, inputs=[user_id_input], outputs=[encrypted_scan_result])
|
376 |
|