Skip to content

Commit

Permalink
Benchmark for half-gate encryption.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Jul 31, 2023
1 parent fc66178 commit 7c8eba0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,30 @@ CO OT:
│ Result │ 338.085µs │ 0.00% │ 55kB │
│ Total │ 1m17.852519512s │ │ 15GB │
└─────────────┴─────────────────┴────────┴──────┘
Max permanent wires: 53913890, cached circuits: 25
#gates=830166294 (XOR=533177896 XNOR=28813441 AND=267575026 OR=496562
INV=103369 xor=561991337 !xor=268174957 levels=10548 width=1796)
#w=853882864
```

Theoretical minimum single-threaded garbling time:

```
AND: 267575026 * 6 * 24.28 = 38980329787.68 ns
OR: 496562 * 4 * 28.59 = 56786830.32 ns
INV: 103369 * 2 * 28.59 = 5910639.42 ns
=================
39043027257.42 ns
39.04 s
```

The gate garbling speeds are measured with the `circuit/enc_test.go`:

```
cpu: Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
BenchmarkEnc-8 35426180 28.59 ns/op
BenchmarkEncHalf-8 48652969 24.28 ns/op
```

## RSA signature computation

Expand Down
20 changes: 20 additions & 0 deletions circuit/enc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,23 @@ func BenchmarkEnc(b *testing.B) {
encrypt(cipher, al, bl, cl, uint32(i), &data)
}
}

func BenchmarkEncHalf(b *testing.B) {
var key [32]byte

cipher, err := aes.NewCipher(key[:])
if err != nil {
b.Fatalf("Failed to create cipher: %s", err)
}

xl, err := ot.NewLabel(rand.Reader)
if err != nil {
b.Fatalf("Failed to create label: %s", err)
}

b.ResetTimer()
var data ot.LabelData
for i := 0; i < b.N; i++ {
encryptHalf(cipher, xl, uint32(i), &data)
}
}

0 comments on commit 7c8eba0

Please sign in to comment.