Skip to content

Commit

Permalink
benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
meehow committed Feb 14, 2019
1 parent 5e50be8 commit 57023d8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ Published to 12D3KooWMJm**DUPA**tjcaHo8LARo5VHQ5uSxrt8Mdi5fytiRnnfD2f: {ipfs-pat
In [examples](examples) you can find key pairs which contain word "funny"
at the end of Peer ID. They are just for demonstration purposes.
Please consider these private keys as already leaked.

## Benchmarks

This tool is using [Ed25519](https://godoc.org/golang.org/x/crypto/ed25519)
algorithm because it is able to generate keys **2500 times faster**
than [RSA](https://godoc.org/crypto/rsa) and both can work with IPFS.

```
goos: linux
goarch: amd64
pkg: github.com/meehow/peer-id-generator
BenchmarkRSA-4 10 162383811 ns/op
BenchmarkEd25519-4 20000 64165 ns/op
PASS
ok github.com/meehow/peer-id-generator 4.384s
```
22 changes: 22 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"crypto/rand"
"testing"

crypto "github.com/libp2p/go-libp2p-crypto"
)

func BenchmarkRSA(b *testing.B) {
for i := 0; i < b.N; i++ {
crypto.GenerateRSAKeyPair(2048, rand.Reader)
}

}

func BenchmarkEd25519(b *testing.B) {
for i := 0; i < b.N; i++ {
crypto.GenerateEd25519Key(rand.Reader)
}

}

0 comments on commit 57023d8

Please sign in to comment.