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

Import ecies keys from ecdsa keys #16

Closed
udhos opened this issue Sep 14, 2020 · 6 comments
Closed

Import ecies keys from ecdsa keys #16

udhos opened this issue Sep 14, 2020 · 6 comments

Comments

@udhos
Copy link

udhos commented Sep 14, 2020

Hi,

How can I import ecies keys from existing ecdsa keys?

  • ecies.PrivateKey from ecdsa.PrivateKey
  • ecies.PublicKey from ecdsa.PublicKey

ecdsa: https://golang.org/pkg/crypto/ecdsa/
ecies: https://github.com/ecies/go

Thanks,
Everton

@kigawas
Copy link
Member

kigawas commented Sep 15, 2020

You have to use the same elliptic curve, which is secp256k1, and import it with hex string or bytes

@udhos
Copy link
Author

udhos commented Sep 15, 2020

I see that there are helper functions to import ecies keys from bytes. But how to properly export ecdsa keys to bytes?

@kigawas
Copy link
Member

kigawas commented Sep 15, 2020

You can check the documentation of ecdsa.

It's just a big int, you can convert it to bytes.

@kigawas kigawas closed this as completed Sep 15, 2020
@savely-krasovsky
Copy link
Member

Well, sure I can add the helper function that accepts ecdsa.PrivateKey; the problem is that this private key MUST BE secp256k1 curve.

I hope library user SHOULD understand how it works and be able to write such a function himself.

@udhos
Copy link
Author

udhos commented Sep 15, 2020

In my specific case, the ecdsa key is P256:

P256 returns a Curve which implements NIST P-256 (FIPS 186-3, section D.2.3), also known as secp256r1 or prime256v1. The CurveParams.Name of this Curve is "P-256".

Can I just export its big Int D data as []byte and feed It into NewPrivateKeyFromBytes() ?

@savely-krasovsky
Copy link
Member

@udhos well, currently this library set does NOT support secp256r1 or anything else except secp256k1.

We already discuss it here: ecies/py#81

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

No branches or pull requests

3 participants