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

crypto: public X,Y from fixed private key #70407

Closed
3052 opened this issue Nov 18, 2024 · 2 comments
Closed

crypto: public X,Y from fixed private key #70407

3052 opened this issue Nov 18, 2024 · 2 comments
Labels
Milestone

Comments

@3052
Copy link

3052 commented Nov 18, 2024

Proposal Details

I am seeing no way to return the public X,Y from a fixed private key. this creates a fixed private key:

https://pkg.go.dev/crypto/ecdh#Curve.NewPrivateKey

then you can get the public key:

https://pkg.go.dev/crypto/ecdh#PrivateKey.PublicKey

but it stops after that because they X,Y are not available. you can create a private key like this:

https://pkg.go.dev/crypto/ecdsa#GenerateKey

then get X,Y via

  1. https://pkg.go.dev/crypto/ecdsa#PrivateKey.PublicKey
  2. https://pkg.go.dev/crypto/ecdsa#PublicKey.X
  3. https://pkg.go.dev/crypto/ecdsa#PublicKey.Y

but I see no way to create a fixed private key. even if you constructed a deterministic rand:

func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error)

it seems it wouldnt matter:

Note that the returned key does not depend deterministically on the bytes read from rand, and may change between calls and/or between versions.

for prior art, you can do this with Python:

https://pycryptodome.readthedocs.io/en/latest/src/public_key/ecc.html#Crypto.PublicKey.ECC.EccKey

@3052 3052 added the Proposal label Nov 18, 2024
@gopherbot gopherbot added this to the Proposal milestone Nov 18, 2024
@3052 3052 changed the title proposal: import/path: proposal title crypto: public X,Y from fixed private key Nov 18, 2024
@seankhliao
Copy link
Member

the x509 marshal/unmarshal will get you an ecdsa key.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants