Commit
·
0287aa5
1
Parent(s):
fbe9775
Merge keygen, encrypt and send inputs button
Browse files
app.py
CHANGED
|
@@ -159,6 +159,8 @@ def encrypt(user_id, input_image, filter_name):
|
|
| 159 |
representation.
|
| 160 |
|
| 161 |
"""
|
|
|
|
|
|
|
| 162 |
if user_id == "":
|
| 163 |
raise gr.Error("Please generate the private key first.")
|
| 164 |
|
|
@@ -181,6 +183,8 @@ def encrypt(user_id, input_image, filter_name):
|
|
| 181 |
# Create a truncated version of the encrypted image for display
|
| 182 |
encrypted_image_short = shorten_bytes_object(encrypted_image)
|
| 183 |
|
|
|
|
|
|
|
| 184 |
return (input_image, encrypted_image_short)
|
| 185 |
|
| 186 |
|
|
@@ -336,50 +340,8 @@ with demo:
|
|
| 336 |
)
|
| 337 |
|
| 338 |
gr.Markdown("## Client side")
|
| 339 |
-
gr.Markdown("### Step 1: Keygen. ")
|
| 340 |
-
gr.Markdown("#### Notes")
|
| 341 |
-
gr.Markdown(
|
| 342 |
-
"""
|
| 343 |
-
- The private key is used to encrypt and decrypt the data and will never be shared.
|
| 344 |
-
- No public key is required for these filter operators.
|
| 345 |
-
"""
|
| 346 |
-
)
|
| 347 |
-
|
| 348 |
-
with gr.Row():
|
| 349 |
-
with gr.Column():
|
| 350 |
-
gr.Markdown("### Client ")
|
| 351 |
-
keygen_button_1 = gr.Button("Generate the private key.")
|
| 352 |
-
|
| 353 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 354 |
-
with gr.Row():
|
| 355 |
-
keygen_checkbox_1 = gr.Checkbox(label="Private key generated:", interactive=False)
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
client_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
| 359 |
-
|
| 360 |
-
with gr.Column():
|
| 361 |
-
gr.Markdown("### Bank ")
|
| 362 |
-
keygen_button_2 = gr.Button("Generate the private key.")
|
| 363 |
-
|
| 364 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 365 |
-
with gr.Row():
|
| 366 |
-
keygen_checkbox_2 = gr.Checkbox(label="Private key generated:", interactive=False)
|
| 367 |
-
|
| 368 |
-
bank_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
| 369 |
-
|
| 370 |
-
with gr.Column():
|
| 371 |
-
gr.Markdown("### Third Party ")
|
| 372 |
-
keygen_button_3 = gr.Button("Generate the private key.")
|
| 373 |
-
|
| 374 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 375 |
-
with gr.Row():
|
| 376 |
-
keygen_checkbox_3 = gr.Checkbox(label="Private key generated:", interactive=False)
|
| 377 |
-
|
| 378 |
-
party_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
gr.Markdown("### Step 2: Infos. ")
|
| 382 |
|
|
|
|
| 383 |
with gr.Row():
|
| 384 |
with gr.Column():
|
| 385 |
gr.Markdown("### Client ")
|
|
@@ -397,50 +359,37 @@ with demo:
|
|
| 397 |
# TODO : change infos
|
| 398 |
radio_1 = gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?")
|
| 399 |
|
| 400 |
-
|
|
|
|
| 401 |
with gr.Row():
|
| 402 |
with gr.Column():
|
| 403 |
gr.Markdown("### Client ")
|
| 404 |
-
encrypt_button_1 = gr.Button("Encrypt the inputs
|
| 405 |
encrypted_input_1 = gr.Textbox(
|
| 406 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 407 |
)
|
| 408 |
|
|
|
|
|
|
|
| 409 |
|
| 410 |
with gr.Column():
|
| 411 |
gr.Markdown("### Bank ")
|
| 412 |
-
encrypt_button_2 = gr.Button("Encrypt the inputs
|
| 413 |
encrypted_input_2 = gr.Textbox(
|
| 414 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 415 |
)
|
| 416 |
|
|
|
|
|
|
|
|
|
|
| 417 |
with gr.Column():
|
| 418 |
gr.Markdown("### Third Party ")
|
| 419 |
-
encrypt_button_3 = gr.Button("Encrypt the inputs
|
| 420 |
encrypted_input_3 = gr.Textbox(
|
| 421 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 422 |
)
|
| 423 |
|
| 424 |
-
|
| 425 |
-
with gr.Row():
|
| 426 |
-
with gr.Column():
|
| 427 |
-
gr.Markdown("### Client ")
|
| 428 |
-
send_input_button_1 = gr.Button("Send the encrypted inputs to the server.")
|
| 429 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 430 |
-
send_input_checkbox_1 = gr.Checkbox(label="Encrypted inputs sent.", interactive=False)
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
with gr.Column():
|
| 434 |
-
gr.Markdown("### Bank ")
|
| 435 |
-
send_input_button_2 = gr.Button("Send the encrypted inputs to the server.")
|
| 436 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 437 |
-
send_input_checkbox_2 = gr.Checkbox(label="Encrypted inputs sent.", interactive=False)
|
| 438 |
-
|
| 439 |
-
with gr.Column():
|
| 440 |
-
gr.Markdown("### Third Party ")
|
| 441 |
-
send_input_button_3 = gr.Button("Send the encrypted inputs to the server.")
|
| 442 |
-
# TODO : change the button name (add check emoji) instead maybe
|
| 443 |
-
send_input_checkbox_3 = gr.Checkbox(label="Encrypted inputs sent.", interactive=False)
|
| 444 |
|
| 445 |
gr.Markdown("## Server side")
|
| 446 |
gr.Markdown(
|
|
@@ -469,6 +418,10 @@ with demo:
|
|
| 469 |
)
|
| 470 |
get_output_button = gr.Button("Receive the encrypted output from the server.")
|
| 471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
gr.Markdown("### Step 8: Decrypt the output.")
|
| 473 |
decrypt_button = gr.Button("Decrypt the output")
|
| 474 |
|
|
|
|
| 159 |
representation.
|
| 160 |
|
| 161 |
"""
|
| 162 |
+
user_id = keygen
|
| 163 |
+
|
| 164 |
if user_id == "":
|
| 165 |
raise gr.Error("Please generate the private key first.")
|
| 166 |
|
|
|
|
| 183 |
# Create a truncated version of the encrypted image for display
|
| 184 |
encrypted_image_short = shorten_bytes_object(encrypted_image)
|
| 185 |
|
| 186 |
+
send_input()
|
| 187 |
+
|
| 188 |
return (input_image, encrypted_image_short)
|
| 189 |
|
| 190 |
|
|
|
|
| 340 |
)
|
| 341 |
|
| 342 |
gr.Markdown("## Client side")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
| 344 |
+
gr.Markdown("### Step 1: Infos. ")
|
| 345 |
with gr.Row():
|
| 346 |
with gr.Column():
|
| 347 |
gr.Markdown("### Client ")
|
|
|
|
| 359 |
# TODO : change infos
|
| 360 |
radio_1 = gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?")
|
| 361 |
|
| 362 |
+
|
| 363 |
+
gr.Markdown("### Step 2: Keygen, encrypt using FHE and send the inputs to the server.")
|
| 364 |
with gr.Row():
|
| 365 |
with gr.Column():
|
| 366 |
gr.Markdown("### Client ")
|
| 367 |
+
encrypt_button_1 = gr.Button("Encrypt the inputs and send to server.")
|
| 368 |
encrypted_input_1 = gr.Textbox(
|
| 369 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 370 |
)
|
| 371 |
|
| 372 |
+
client_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
| 373 |
+
|
| 374 |
|
| 375 |
with gr.Column():
|
| 376 |
gr.Markdown("### Bank ")
|
| 377 |
+
encrypt_button_2 = gr.Button("Encrypt the inputs and send to server.")
|
| 378 |
encrypted_input_2 = gr.Textbox(
|
| 379 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 380 |
)
|
| 381 |
|
| 382 |
+
bank_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
| 383 |
+
|
| 384 |
+
|
| 385 |
with gr.Column():
|
| 386 |
gr.Markdown("### Third Party ")
|
| 387 |
+
encrypt_button_3 = gr.Button("Encrypt the inputs and send to server.")
|
| 388 |
encrypted_input_3 = gr.Textbox(
|
| 389 |
label="Encrypted input representation:", max_lines=2, interactive=False
|
| 390 |
)
|
| 391 |
|
| 392 |
+
party_id = gr.Textbox(label="", max_lines=2, interactive=False, visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
gr.Markdown("## Server side")
|
| 395 |
gr.Markdown(
|
|
|
|
| 418 |
)
|
| 419 |
get_output_button = gr.Button("Receive the encrypted output from the server.")
|
| 420 |
|
| 421 |
+
encrypted_output_representation = gr.Textbox(
|
| 422 |
+
label="Credit card approval decision: ", max_lines=1, interactive=False
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
gr.Markdown("### Step 8: Decrypt the output.")
|
| 426 |
decrypt_button = gr.Button("Decrypt the output")
|
| 427 |
|