-
Notifications
You must be signed in to change notification settings - Fork 2
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
TODO: More docs, examples and tests #1
Comments
I have done a lot of search for ECIES and your code seems to be the only one that works for me as a Windows user. I am using this with Chrome extension. I would like to know how to load an external generated public key generated by BouncyCastle. Or load in the hex for X and Y values to encypt. privateKey = "-----BEGIN EC PRIVATE KEY-----\r\nMIIBCwIBAQQgXUriUohju+MZIN/6GmejKI+9pw5fs464BzK8IbRPX+GggeMwgeAC\r\nAQEwLAYHKoZIzj0BAQIhAP////////////////////////////////////7///wv\r\nMEQEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCAAAAAAAAAAAAAA\r\nAAAAAAAAAAAAAAAAAAAAAAAAAAAABwRBBHm+Zn753LusVaBilc6HCwcCm/zbLc4o\r\n2VnygVsW+BeYSDradyajxGVdpPv8DhEIqP0XtEimhVQZnEfQj/sQ1LgCIQD/////\r\n///////////////+uq7c5q9IoDu/0l6M0DZBQQIBAQ==\r\n-----END EC PRIVATE KEY-----\r\n" string "-----BEGIN PUBLIC KEY-----\r\nMIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA////////////////\r\n/////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\nAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5m\r\nfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0\r\nSKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFB\r\nAgEBA0IABGMgfhYdsm7dTzR6Nr1+lUlLoCDzqlJq/QBV41mcON2yCJQ9SnNS3YUa\r\nxA8SwkXnnuatFpSmd8UfINaq+cLktO8=\r\n-----END PUBLIC KEY-----\r\n" |
@qisbic Glad to see my first issue reporter on github 😄, I think ecdh.setPrivateKey is what you want. Just replace |
Unfortunate.. this is not what I want.. the client is receiving a "public" key which is used to encrypt. Unfortunately, according to the documentation the ecdh.setPublicKey has been Deprecated. I have struggled for a few days trying to find javascript codes that will let me set a public key to encrypt for ECIES. Almost all codes used are ECDH/ECDSA in which the client generate the keys. Your codes come the closest to what I need to do. Thanks for any suggestions you would have. |
server side:
client side:
if crypto.ECDH can import your private key, encryption with public key on client side won't be a problem But after doing this ,client still generate a temporary key on each encryption, that's the first step to do according to the standard (see first step of Encryption) |
@qisbic maybe I didn't fully understand your requirement before. your key is ASN.1 encoded, and from this link you can see detailed data structure of your public key. And from this mail archive it looks like the key you using is invalid encoded, but it is ok, from the correct encoding we can see that the value you wanted to use with crypto.ECDH is the BIT_STRING part. There is an ASN.1 library on npm you can use it to decode your public key and get the last part use it as the public key on ecdh. I'm not sure but it should be same way of your library encoding public ec point and the way node did, because how to encode the point is standardized, you can check it by reading the source, here is how the node output the public key. Hope this post will help you. |
No description provided.
The text was updated successfully, but these errors were encountered: