hive-keychain / hive-keychain-extension

A wallet browser extension for the Hive blockchain and cryptocurrency
MIT License
77 stars 51 forks source link

Help with creating encrypted message #116

Closed CBradell closed 2 years ago

CBradell commented 2 years ago

Hey stoodkev,

Sorry to bother you, I am having the hardest time as a C# developer going through the source code layers to find how the requestEncodeMessage is encrypting the message.

Would you be able to provide any insight on how the message is hashed/created so that it can be used by the requestVerifyKey function?

My end goal is to create an encoded message on my backend and then give it to the user to decode with the requestVerifyKey to ensure they control the private key of an account.

Any help or insight would be greatly appreciated! I have spent a lot of time trying to work this out but to no avail so far.

stoodkev commented 2 years ago

Hi! We're using hive-js library for encrypting / decrypting the messages :

import * as hive from '@hiveio/hive-js';
hive.memo.encode(privateKey, receiverPublicKey, memo) // memo needs to start by a '#'
CBradell commented 2 years ago

Wow, thanks for the quick reply @stoodkev!

Just to confirm, even though it's hive.memo.encode, the same method can also be used for Posting/Active key?

stoodkev commented 2 years ago

Yeah, it works with any type of key. Just make sure you start the message with a '#'

CBradell commented 2 years ago

Perfect, thanks!