@@ -18,3 +18,59 @@ def __init__(self, graph):
1818 self .scene = QGraphicsScene ()
1919 self .setScene (self .scene )
2020 self .draw_graph ()
21+ def draw_graph (self ):
22+ node_positions = {
23+ 'A' : QPointF (50 , 50 ),
24+ 'B' : QPointF (250 , 50 ),
25+ 'C' : QPointF (250 , 200 ),
26+ 'D' : QPointF (50 , 200 )
27+ }
28+ radius = 30
29+
30+ pen = QPen (Qt .black )
31+ brush = QBrush (QColor ("skyblue" ))
32+
33+ self .scene .clear ()
34+
35+ for node , pos in node_positions .items ():
36+ self .scene .addEllipse (pos .x (), pos .y (), radius , radius , pen , brush )
37+ self .scene .addText (node ).setPos (pos .x ()+ 8 , pos .y ()+ 5 )
38+
39+ for (src , dst ), weight in self .graph .edge_weights .items ():
40+ src_pos = node_positions [src ] + QPointF (radius / 2 , radius / 2 )
41+ dst_pos = node_positions [dst ] + QPointF (radius / 2 , radius / 2 )
42+ self .scene .addLine (src_pos .x (), src_pos .y (), dst_pos .x (), dst_pos .y (), QPen (Qt .darkGray ))
43+ mid_x = (src_pos .x () + dst_pos .x ()) / 2
44+ mid_y = (src_pos .y () + dst_pos .y ()) / 2
45+ self .scene .addText (str (weight )).setPos (mid_x , mid_y )
46+
47+ class ZKPDemoApp (QMainWindow ):
48+ def __init__ (self ):
49+ super ().__init__ ()
50+ self .setWindowTitle ("Zero-Knowledge Proof Demo - Graph Mode" )
51+ self .setGeometry (200 , 100 , 1000 , 700 )
52+ self .canvas = GraphCanvas (graph )
53+ self .start_selector = QComboBox ()
54+ self .end_selector = QComboBox ()
55+ for v in graph .vertices :
56+ self .start_selector .addItem (v )
57+ self .end_selector .addItem (v )
58+ self .prove_button = QPushButton ("🔒 Commit to Path" )
59+ self .prove_button .clicked .connect (self .run_zkp_simulation )
60+ self .output_panel = QTextEdit ()
61+ self .output_panel .setReadOnly (True )
62+ self .output_panel .setStyleSheet ("background-color: #f8f8f8; padding: 8px; font-family: Courier;" )
63+ control_layout = QHBoxLayout ()
64+ control_layout .addWidget (QLabel ("Start Node:" ))
65+ control_layout .addWidget (self .start_selector )
66+ control_layout .addWidget (QLabel ("End Node:" ))
67+ control_layout .addWidget (self .end_selector )
68+ control_layout .addWidget (self .prove_button )
69+ main_layout = QVBoxLayout ()
70+ main_layout .addLayout (control_layout )
71+ main_layout .addWidget (self .canvas , stretch = 3 )
72+ main_layout .addWidget (QLabel ("Walkthrough Panel:" ))
73+ main_layout .addWidget (self .output_panel , stretch = 1 )
74+ container = QWidget ()
75+ container .setLayout (main_layout )
76+ self .setCentralWidget (container )
0 commit comments