-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSMC2.uc
248 lines (220 loc) · 5.76 KB
/
SMC2.uc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
(* Secure Message Communication *)
(* Triple unit for two way secure message communcation between two
parties *)
uc_requires Forwarding SMC.
ec_requires +KeysExponentsAndPlaintexts.
direct SMC2Pt1 {
in pt1@smc_req(pt2 : port, t : text) (* 1 *)
out smc_rsp(t : text)@pt1 (* 4 *)
}
direct SMC2Pt2 {
out smc_rsp(pt1 : port, t : text)@pt2 (* 2 *)
in pt2@smc_req(t : text) (* 3 *)
}
direct SMC2Dir {
Pt1 : SMC2Pt1
Pt2 : SMC2Pt2
}
functionality SMC2Real(SMC1 : SMC.SMCDir, SMC2 : SMC.SMCDir)
implements SMC2Dir {
subfun Fwd1 = Forwarding.Forw
subfun Fwd2 = Forwarding.Forw
party Pt1 serves SMC2Dir.Pt1 {
initial state WaitReq {
match message with
| [email protected]_req(pt2, t) => {
if (envport pt2) {
send Fwd1.D.fw_req
(intport Pt2, epdp_port_port_univ.`enc (pt1, pt2))
and transition WaitFwd2(pt1, pt2, t).
}
else { fail. }
}
| * => { fail. }
end
}
state WaitFwd2(pt1 : port, pt2 : port, t : text) {
match message with
| Fwd2.D.fw_rsp(_, _) => {
send SMC1.Pt1.smc_req(intport Pt2, t)
and transition WaitSMC2(pt1).
}
| * => { fail. }
end
}
state WaitSMC2(pt1 : port) {
match message with
| SMC2.Pt2.smc_rsp(_, t) => {
send SMC2Dir.Pt1.smc_rsp(t)@pt1
and transition Final.
}
| * => { fail. }
end
}
state Final {
match message with
| * => { fail. }
end
}
}
party Pt2 serves SMC2Dir.Pt2 {
initial state WaitFwd1 {
var pt1, pt2 : port;
match message with
| Fwd1.D.fw_rsp(_, u) => {
(pt1, pt2) <- oget (epdp_port_port_univ.`dec u);
send Fwd2.D.fw_req(intport Pt1, [])
and transition WaitSMC1(pt1, pt2).
}
| * => { fail. }
end
}
state WaitSMC1(pt1 : port, pt2 : port) {
match message with
| SMC1.Pt2.smc_rsp(_, t) => {
send SMC2Dir.Pt2.smc_rsp(pt1, t)@pt2
and transition WaitReq(pt2).
}
| * => { fail. }
end
}
state WaitReq(pt2 : port) {
match message with
| pt2'@SMC2Dir.Pt2.smc_req(t) => {
if (pt2' = pt2) {
send SMC2.Pt1.smc_req(intport Pt1, t)
and transition Final.
}
else { fail. }
}
| * => { fail. }
end
}
state Final {
match message with
| * => { fail. }
end
}
}
}
adversarial SMC2IF_to_Sim {
out sim_req1(pt1 : port, pt2 : port)
out sim_req2
in sim_rsp
}
functionality SMC2Ideal implements SMC2Dir SMC2IF_to_Sim {
initial state WaitReq1 {
match message with
| [email protected]_req(pt2, t) => {
if (envport pt2) {
send SMC2IF_to_Sim.sim_req1(pt1, pt2)
and transition WaitSim1(pt1, pt2, t).
}
else { fail. }
}
| * => { fail. }
end
}
state WaitSim1(pt1 : port, pt2 : port, t : text) {
match message with
| SMC2IF_to_Sim.sim_rsp => {
send SMC2Dir.Pt2.smc_rsp(pt1, t)@pt2
and transition WaitReq2(pt1, pt2).
}
| * => { fail. }
end
}
state WaitReq2(pt1 : port, pt2 : port) {
match message with
| pt2'@SMC2Dir.Pt2.smc_req(t) => {
if (pt2' = pt2) {
send SMC2IF_to_Sim.sim_req2
and transition WaitSim2(pt1, pt2, t).
}
else { fail. }
}
| * => { fail. }
end
}
state WaitSim2(pt1 : port, pt2 : port, t : text) {
match message with
| SMC2IF_to_Sim.sim_rsp => {
send SMC2Dir.Pt1.smc_rsp(t)@pt1
and transition Final.
}
| * => { fail. }
end
}
state Final {
match message with
| * => { fail. }
end
}
}
simulator SMC2Sim uses SMC2IF_to_Sim
simulates SMC2Real(SMC.SMCIdeal, SMC.SMCIdeal) {
initial state WaitReq1 {
match message with
| SMC2IF_to_Sim.sim_req1(pt1, pt2) => {
send SMC2Real.Fwd1.FwAdv.fw_obs
(intport SMC2Real.Pt1, intport SMC2Real.Pt2,
epdp_port_port_univ.`enc (pt1, pt2))
and transition WaitAdv1.
}
| * => { fail. }
end
}
state WaitAdv1 {
match message with
| SMC2Real.Fwd1.FwAdv.fw_ok => {
send SMC2Real.Fwd2.FwAdv.fw_obs
(intport SMC2Real.Pt2, intport SMC2Real.Pt1, [])
and transition WaitAdv2.
}
| * => { fail. }
end
}
state WaitAdv2 {
match message with
| SMC2Real.Fwd2.FwAdv.fw_ok => {
send SMC2Real.SMC1.SMC2Sim.sim_req
(intport SMC2Real.Pt1, intport SMC2Real.Pt2)
and transition WaitAdv3.
}
| * => { fail. }
end
}
state WaitAdv3 {
match message with
| SMC2Real.SMC1.SMC2Sim.sim_rsp => {
send SMC2IF_to_Sim.sim_rsp
and transition WaitReq2.
}
| * => { fail. }
end
}
state WaitReq2 {
match message with
| SMC2IF_to_Sim.sim_req2 => {
send SMC2Real.SMC2.SMC2Sim.sim_req
(intport SMC2Real.Pt2, intport SMC2Real.Pt1)
and transition WaitAdv4.
}
| * => { fail. }
end
}
state WaitAdv4 {
match message with
| SMC2Real.SMC2.SMC2Sim.sim_rsp => {
send SMC2IF_to_Sim.sim_rsp
and transition Final.
}
| * => { fail. }
end
}
state Final {
match message with
| * => { fail. }
end
}
}