Commit 292ef52a authored by Anders Jensen Løvig's avatar Anders Jensen Løvig
Browse files

Update README.md

parent db392838
# 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/handin5/main.go` with tests in `cmd/handin5/main_test.go`.
The protocol is implemented in `cmd/handin6/main.go` with tests in `cmd/handin6/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/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
......
......@@ -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, 2000, 100000, 60, 2000)
privKey, err := homomorphic.GenerateKey(rand.Reader, 1000, 1000000, 40, 1000)
if err != nil {
return
}
......
......@@ -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)
......
......@@ -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
}
......
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