Skip to content

Commit

Permalink
Added CIRCL SHAKE benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Sep 13, 2023
1 parent fb2000b commit 42845e3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
7 changes: 5 additions & 2 deletions benches/circl/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bench-ref:
env GODEBUG=cpu.avx2=off go test -bench=.
bench-kyber-ref:
env GODEBUG=cpu.avx2=off go test -bench='Kyber768'

bench-shake-ref:
env GODEBUG=cpu.avx2=off go test -bench='SHAKE'
6 changes: 3 additions & 3 deletions benches/circl/kyber768_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
)

func BenchmarkKeyGeneration(b *testing.B) {
func BenchmarkKyber768KeyGeneration(b *testing.B) {
scheme := schemes.ByName("Kyber768")

for i := 0; i < b.N; i++ {
Expand All @@ -15,7 +15,7 @@ func BenchmarkKeyGeneration(b *testing.B) {
}
}

func BenchmarkEncapsulation(b *testing.B) {
func BenchmarkKyber768Encapsulation(b *testing.B) {
scheme := schemes.ByName("Kyber768")

pk, _, _ := scheme.GenerateKeyPair()
Expand All @@ -27,7 +27,7 @@ func BenchmarkEncapsulation(b *testing.B) {
}
}

func BenchmarkDecapsulation(b *testing.B) {
func BenchmarkKyber768Decapsulation(b *testing.B) {
scheme := schemes.ByName("Kyber768")

pk, sk, _ := scheme.GenerateKeyPair()
Expand Down
44 changes: 44 additions & 0 deletions benches/circl/shake_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package main

import (
"github.com/cloudflare/circl/xof"
"testing"
)

const bytesToOutput = 10000;

func BenchmarkSHAKE128(b *testing.B) {
input := make([]byte, 0, 34);
output := make([]byte, bytesToOutput);

xof := xof.SHAKE128.New()
_, err := xof.Write([]byte(input))
if err != nil {
b.Fatal(err)
}

for i := 0; i < b.N; i++ {
n, err := xof.Read(output)
if n != bytesToOutput || err != nil {
b.Fatal()
}
}
}

func BenchmarkSHAKE256(b *testing.B) {
input := make([]byte, 0, 34);
output := make([]byte, bytesToOutput)

xof := xof.SHAKE256.New()
_, err := xof.Write([]byte(input))
if err != nil {
b.Fatal(err)
}

for i := 0; i < b.N; i++ {
n, err := xof.Read(output)
if n != bytesToOutput || err != nil {
b.Fatal()
}
}
}

0 comments on commit 42845e3

Please sign in to comment.