Skip to content
GitLab
Menu
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
292ef52a
Commit
292ef52a
authored
Oct 10, 2021
by
Anders Jensen Løvig
Browse files
Update README.md
parent
db392838
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
292ef52a
# Cryptographic Computing - Handin
5
# Cryptographic Computing - Handin
6
A Go implementation of a passive secure two-party protocol for blood type compatibility based on
Yao's garbled circuit protocol
.
A Go implementation of a passive secure two-party protocol for blood type compatibility based on
a homomorphic encryption scheme
.
## Implementation
The protocol is implemented in
`cmd/handin
5
/main.go`
with tests in
`cmd/handin
5
/main_test.go`
.
The protocol is implemented in
`cmd/handin
6
/main.go`
with tests in
`cmd/handin
6
/main_test.go`
.
For the implementation we have implemented support packages which can be reused:
-
`internal/crypto/elgamal`
implements textbook ElGamal encryption.
-
`internal/crypto/oblivious`
implements a 1 out of n oblivious transfer protocol.
-
`internal/crypto/garbled`
implements Yao's garbled circuits.
-
`internal/crypto/garbled`
implements Yao's garbled circuits.
-
`internal/crypto/homomorphic`
implements the homomorphic encryption scheme.
### Notes on implementation.
1.
For the security parameters we choose 200-bit p, 10^6-bit q, 40-bit r and 1000 elements in the public key. We choose those values
because they improve the performance of the scheme, and everything still works.
2.
In the homomorphic encryption scheme, we need to choose a subset S. We do this by shuffling a list containing the numbers [1,...,n]
and then chooses the k first numbers in the list, where k is a random integer in the range
[
1,...,n). This was we always add at least
some noise to the encryption.
## Requirements
...
...
cmd/handin6/main.go
View file @
292ef52a
...
...
@@ -101,7 +101,7 @@ func RunProtocol(x, y int) (z bool, err error) {
conn
:=
make
(
chan
*
big
.
Int
)
Alice
:=
&
Party
{
conn
}
Bob
:=
&
Party
{
conn
}
privKey
,
err
:=
homomorphic
.
GenerateKey
(
rand
.
Reader
,
2
000
,
100000
,
6
0
,
2
000
)
privKey
,
err
:=
homomorphic
.
GenerateKey
(
rand
.
Reader
,
1
000
,
100000
0
,
4
0
,
1
000
)
if
err
!=
nil
{
return
}
...
...
cmd/handin6/main_test.go
View file @
292ef52a
...
...
@@ -6,20 +6,6 @@ import (
"testing"
)
func
TestBloodTable
(
t
*
testing
.
T
)
{
// Check the dimensions of BloodTable.
if
len
(
blood
.
Table
)
!=
8
{
t
.
Fatalf
(
"Expected 8 rows, got %d"
,
len
(
blood
.
Table
))
}
for
i
:=
range
blood
.
Table
{
if
len
(
blood
.
Table
[
i
])
!=
8
{
t
.
Fatalf
(
"Expected columns in row %d, got %d"
,
i
,
len
(
blood
.
Table
))
}
}
}
func
TestProtocol
(
t
*
testing
.
T
)
{
// Runs the protocol for all combinations of recipient and donor blood types.
n
:=
len
(
blood
.
Table
)
...
...
internal/crypto/homomorphic/dhe.go
View file @
292ef52a
...
...
@@ -72,7 +72,7 @@ func Encrypt(random io.Reader, m int, pub *PublicKey) (c *big.Int, err error) {
// Sample random subset S of [0...n]
S
:=
make
([]
int
,
pub
.
n
)
for
i
:=
0
;
i
<
pub
.
n
;
i
++
{
S
[
i
]
=
i
S
[
i
]
=
i
+
1
}
util
.
Shuffle
(
pub
.
n
,
func
(
i
,
j
int
)
{
S
[
i
],
S
[
j
]
=
S
[
j
],
S
[
i
]
})
sLen
,
err
:=
util
.
RandIntn
(
random
,
big
.
NewInt
(
int64
(
pub
.
n
)))
...
...
@@ -83,7 +83,7 @@ func Encrypt(random io.Reader, m int, pub *PublicKey) (c *big.Int, err error) {
c
=
big
.
NewInt
(
int64
(
m
))
for
i
:=
range
S
{
c
=
c
.
Add
(
c
,
pub
.
y
[
S
[
i
]])
c
=
c
.
Add
(
c
,
pub
.
y
[
S
[
i
]
-
1
])
}
return
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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