Commit 639191ef authored by Thomas Hoffmann's avatar Thomas Hoffmann
Browse files

Implement stuff - sadly no test :(

parent 2413f8f2
......@@ -52,6 +52,16 @@ func mod(a, n int) int {
return (a%n + n) % n
}
func Int2Bools(x, bits int) []bool {
var output = make([]bool,0)
var tmp = 0
for i := bits-1; i >= 0; i-- {
tmp = int(math.Exp2(float64(i)))
output = append(output,(x & tmp) / tmp == 1)
}
return output
}
type Party struct {
rand *rand.Rand
vals []bool
......@@ -275,13 +285,14 @@ func (P *Protocol) RunProtocol(x, y []bool) bool {
func main() {
var p = InitProtocol(1)
x, y := []bool{false, false, false}, []bool{true, true, true}
var bloodA, BloodB = BloodType_ABn, BloodType_ABp
x, y := Int2Bools(bloodA,3), Int2Bools(BloodB,3)//[]bool{false, false, false}, []bool{true, true, true}
z := p.RunProtocol(x, y)
if z == BloodTable[BloodType_ABp][BloodType_Bp] {
if z == BloodTable[bloodA][BloodB] {
fmt.Println("Protocol succeded")
fmt.Println(z)
} else {
fmt.Println("Protocol failed")
fmt.Printf("Protocol failed, output was %t, but should be %t", z, BloodTable[bloodA][BloodB])
}
}
......
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