Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Hoffmann
CryComp
Commits
639191ef
Commit
639191ef
authored
Sep 17, 2021
by
Thomas Hoffmann
Browse files
Implement stuff - sadly no test :(
parent
2413f8f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
cmd/handin3/main.go
View file @
639191ef
...
...
@@ -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
[
B
lood
Type_ABp
][
BloodType_Bp
]
{
if
z
==
BloodTable
[
b
lood
A
][
BloodB
]
{
fmt
.
Println
(
"Protocol succeded"
)
fmt
.
Println
(
z
)
}
else
{
fmt
.
Print
ln
(
"Protocol failed
"
)
fmt
.
Print
f
(
"Protocol failed
, output was %t, but should be %t"
,
z
,
BloodTable
[
bloodA
][
BloodB
]
)
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment