Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GenerateKeyEd25519 to only generate a private key #124

Merged
merged 1 commit into from
Oct 17, 2023
Merged

Conversation

qmuntal
Copy link
Collaborator

@qmuntal qmuntal commented Oct 13, 2023

While integrating Ed25519 into the standard library I noticed that it is not necessary for GenerateKeyEd25519 to return the public key, as it can already be derived from the private key.

Doing so can help reduces allocations and cgo calls in ed25519.GenerateKey, depending on how one decides to implement it.

goos: windows
goarch: amd64
pkg: github.com/golang-fips/openssl/v2
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
                      │   old.txt    │               new.txt               │
                      │    sec/op    │   sec/op     vs base                │
Ed25519GenerateKey-12   47.48µ ± 18%   35.97µ ± 7%  -24.25% (p=0.000 n=10)

                      │  old.txt   │              new.txt               │
                      │    B/op    │    B/op     vs base                │
Ed25519GenerateKey-12   56.00 ± 0%   16.00 ± 0%  -71.43% (p=0.000 n=10)

                      │  old.txt   │              new.txt               │
                      │ allocs/op  │ allocs/op   vs base                │
Ed25519GenerateKey-12   4.000 ± 0%   2.000 ± 0%  -50.00% (p=0.000 n=10)

Copy link
Collaborator

@ueno ueno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a significant speed-up; LGTM!

@qmuntal qmuntal merged commit 08f07a7 into v2 Oct 17, 2023
16 checks passed
@qmuntal qmuntal deleted the ed25519-2 branch October 17, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants