Spaces:
Sleeping
Sleeping
Update tab/tab6_noise_simulation.py
Browse files- tab/tab6_noise_simulation.py +15 -1
tab/tab6_noise_simulation.py
CHANGED
|
@@ -66,4 +66,18 @@ def compare_original_vs_noisy(key_str):
|
|
| 66 |
corruption_rate = (len(flipped_indices) / total_bits) * 100
|
| 67 |
summary = f"⚠️ {len(flipped_indices)} bits flipped out of {total_bits} — {corruption_rate:.2f}% corruption detected."
|
| 68 |
|
| 69 |
-
return Image.open(buf), summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
corruption_rate = (len(flipped_indices) / total_bits) * 100
|
| 67 |
summary = f"⚠️ {len(flipped_indices)} bits flipped out of {total_bits} — {corruption_rate:.2f}% corruption detected."
|
| 68 |
|
| 69 |
+
return Image.open(buf), summary
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def get_tab6_noise_simulation():
|
| 73 |
+
with gr.Tab("🔍 Eavesdropper Noise Simulation"):
|
| 74 |
+
original_input = gr.Textbox(label="Enter QKD Key (binary)", lines=3)
|
| 75 |
+
simulate_btn = gr.Button("Simulate Eavesdropping")
|
| 76 |
+
output_graph = gr.Image(label="Original vs Noisy Key")
|
| 77 |
+
summary_output = gr.Textbox(label="Noise Impact Summary", lines=2)
|
| 78 |
+
|
| 79 |
+
simulate_btn.click(
|
| 80 |
+
fn=compare_original_vs_noisy,
|
| 81 |
+
inputs=[original_input],
|
| 82 |
+
outputs=[output_graph, summary_output]
|
| 83 |
+
)
|