Skip to content

Commit

Permalink
tweak EncryptSharedString
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Oct 30, 2020
1 parent b07acf6 commit 5f9831e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ func EncryptShared(user1PrivateKey *bsvec.PrivateKey, user2PubKey *bsvec.PublicK
func EncryptSharedString(user1PrivateKey *bsvec.PrivateKey, user2PubKey *bsvec.PublicKey, data string) (
*bsvec.PrivateKey, *bsvec.PublicKey, string, error) {

sharedPrivKey, sharedPubKey, encryptedData, err := EncryptShared(user1PrivateKey, user2PubKey, []byte(data))
// Generate shared keys that can be decrypted by either user
sharedPrivKey, sharedPubKey := GenerateSharedKeyPair(user1PrivateKey, user2PubKey)

// Encrypt data with shared key
encryptedData, err := bsvec.Encrypt(sharedPubKey, []byte(data))

return sharedPrivKey, sharedPubKey, hex.EncodeToString(encryptedData), err
}

0 comments on commit 5f9831e

Please sign in to comment.