diff --git a/README.md b/README.md index 3be2a14..4a3889c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,17 @@ # Supersingular Isogeny Key Encapsulation -Repository stores implementation of SIKE based on field p503 in Go. It is small and condese implementation. - -Implementation uses HMAC instead of cSHAKE. +Repository stores Go's implementation of SIKE based on field p503. Implementation uses HMAC instead of cSHAKE. Implementation is quite slow, as the main focus here to keep code base +condensed rather than fast. ## Speed -This version is highly not optimized, it doesn't use any assembly. - ``` > go test -run=. -bench=. goos: linux goarch: amd64 -BenchmarkKeygen-4 1000000 1204 ns/op -BenchmarkEncaps-4 20 54651908 ns/op -BenchmarkDecaps-4 20 60516975 ns/op +BenchmarkKeygen-4 50 32298894 ns/op +BenchmarkEncaps-4 20 53348330 ns/op +BenchmarkDecaps-4 20 64073853 ns/op PASS ok _/home/hdc/repos/go-sike-p503 5.550s ``` \ No newline at end of file diff --git a/arith.go b/arith.go index b0edf4a..9146c38 100644 --- a/arith.go +++ b/arith.go @@ -357,16 +357,6 @@ func inv(dest, x *Fp2) { a := &x.A b := &x.B - // We want to compute - // - // 1 1 (a - bi) (a - bi) - // -------- = -------- -------- = ----------- - // (a + bi) (a + bi) (a - bi) (a^2 + b^2) - // - // Letting c = 1/(a^2 + b^2), this is - // - // 1/(a+bi) = a*c - b*ci. - fpMul(&asq, a, a) // = a*a*R*R fpMul(&bsq, b, b) // = b*b*R*R fp2Add(&asq, &asq, &bsq) // = (a^2 + b^2)*R*R diff --git a/sike_test.go b/sike_test.go index 1c44bfb..1d4edf6 100644 --- a/sike_test.go +++ b/sike_test.go @@ -620,8 +620,10 @@ func TestDecapsulation(t *testing.T) { func BenchmarkKeygen(b *testing.B) { prv := NewPrivateKey(KeyVariant_SIKE) + prv.Generate(rand.Reader) + for n := 0; n < b.N; n++ { - prv.Generate(rand.Reader) + prv.GeneratePublicKey() } }