Commit 4d19e278 authored by Thomas Hoffmann's avatar Thomas Hoffmann
Browse files

Rewrite run-function

parent e229081f
......@@ -226,41 +226,37 @@ func NewProtocol() *Protocol {
}
func (P *Protocol) Run(x, y []bool) bool {
//alice := P.A
//bob := P.B
if len(x) != len(y) {
return false
}
//Input round
var idx_xS, idx_yS = P.Input(x[2], y[2])
var idx_xA, idx_yA = P.Input(x[1], y[1])
var idx_xB, idx_yB = P.Input(x[0], y[0])
//Compute f(x,y) =
// (x_sign OR NOT y_sign) AND
// (x_A OR NOT y_A) AND
// (x_B OR NOT y_B)
//a. Compute (x_sign OR NOT y_sign) = NOT (NOT x_sign AND y_sign)
var idx_f1 = P.NOT(idx_xS)
idx_f1 = P.AND(idx_f1, idx_yS) // NOT x_sign AND y_sign
idx_f1 = P.NOT(idx_f1) //NOT (NOT x_sign AND y_sign)
//b. Compute (x_A OR NOT y_A) = NOT (NOT x_A AND y_A)
var idx_f2 = P.NOT(idx_xA) //compute NOT x_A
idx_f2 = P.AND(idx_f2, idx_yA) // NOT x_A AND y_A
idx_f2 = P.NOT(idx_f2) //NOT (NOT x_A AND y_A)
//c. Compute (x_B OR NOT y_B) = NOT (NOT x_B AND y_B)
var idx_f3 = P.NOT(idx_xB) //compute NOT x_B
idx_f3 = P.AND(idx_f3, idx_yB) // NOT x_B AND y_B
idx_f3 = P.NOT(idx_f3) //NOT (NOT x_B AND y_B)
//d. Compute f(x,y)
var idx_f = P.AND(idx_f1, idx_f2)
idx_f = P.AND(idx_f, idx_f3)
var output = P.Output(idx_f, true, false)
idx_xS, idx_yS := P.Input(x[2], y[2])
idx_xA, idx_yA := P.Input(x[1], y[1])
idx_xB, idx_yB := P.Input(x[0], y[0])
//Compute 1. layer
idx_1a := P.NOT(idx_xS)
idx_1b := P.NOT(idx_xA)
idx_1c := P.NOT(idx_xB)
//Compute 2. layer
idx_2a := P.AND(idx_1a,idx_yS)
idx_2b := P.AND(idx_1b,idx_yA)
idx_2c := P.AND(idx_1c,idx_yB)
//Compute 3. layer
idx_3a := P.NOT(idx_2a)
idx_3b := P.NOT(idx_2b)
idx_3c := P.NOT(idx_2c)
//Compute 4. layer
idx_4 := P.AND(idx_3a,idx_3b)
//Compute final layer
idx_f := P.AND(idx_4,idx_3c)
output := P.Output(idx_f, true, false)
return output[0]
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment