-
Notifications
You must be signed in to change notification settings - Fork 98
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
ECIES Decrypting a message fetched from API giving me bad public key #75
Comments
@Mickellz Sorry, there are examples on the homepage, whether or not you are using an API should make no difference. Can you provide any code, to help you debug? |
Same problem |
This is due to the check on here : https://github.com/bitchan/eccrypto/blob/master/browser.js#L190 When you get the stored message from the API and decode it using something like that
It fails because the Buffer.isBuffer check on the Uint8Array of the publicKey fails. By commenting that assert, the code works properly and the message is decoded properly too. Here is the full code used to encode and decode I'm using :
Edit : To work with bitcoin keys and not keys generated by eccrypto with the helpers, I also had to comment :
Otherwise, while using eccrypto in the browser it's not working because of the same issue. Let me know if I can provide more details :) Edit 2 : There is a similar issue with the sign and verify methods, I had to replace :
By
Otherwise it's failing, even if the array is in fact at the correct 32 size :/ |
@giviz, I'm struggling with storing the private key somewhere, and using that later to (re)generate the public key. I'm having troubles with strings and buffers.. Can you share with us your implementations of Or if @JBaczuk you're around, or anybody else knows, how exactly does one go from the |
You know what, I finally figured it out (not a minute too soon). This post was instrumental. To go from buffer to string: where encoding works for me best as either |
I'm glad you figured it out, I was actually writing you an email to share my own implementation ! For that, you have to take a whole other path... but if it's not required on your use case you're good to go ! |
Actually i have accepted the fact that i need to use browserify 🙂 But if
you have a way around that i am all ears!
…On Wed, Mar 16, 2022, 4:37 PM giviz ***@***.***> wrote:
@aaronik <https://github.com/Aaronik>
I'm glad you figured it out, I was actually writing you an email to share
my own implementation !
Beware that your current solution will work well in nodejs but not in the
browser as it doesn't support Buffer.
For that, you have to take a whole other path... but if it's not required
on your use case you're good to go !
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKDMOIKWEUAOK7LGLGYDXLVAJWD3ANCNFSM4XP4KQUQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hello. So I have been trying to post the encrypted message as a string hex value to an api and when I retrieve it, buffer the object, and decrypt, it gives me "bad public key". I am not sure why this happens, but how can I effectively store a message as json on an api and fetch it back for client siding decryption?
The text was updated successfully, but these errors were encountered: