@celo/utils"packages/sdk/utils/src/commentEncryption"

Module: "packages/sdk/utils/src/commentEncryption"

Index

Interfaces

Functions

Object literals

Functions

decryptComment

decryptComment(comment: string, key: Buffer, sender: boolean): EncryptionStatus

Defined in packages/sdk/utils/src/commentEncryption.ts:104

Decrypts a comments encrypted by encryptComment. If it cannot decrypt the comment (i.e. comment was never encrypted in the first place), it returns the comments without any changes.

Parameters:

Name Type Description
comment string Comment to decrypt. If encrypted, base64 encoded. May be plaintext.
key Buffer Private key to decrypt the message with.
sender boolean If the decryptor is the sender of the message.

Returns: EncryptionStatus

Decrypted comment if can decrypt, otherwise comment.


decryptData

decryptData(data: Buffer, key: Buffer, sender: boolean): Buffer

Defined in packages/sdk/utils/src/commentEncryption.ts:45

Decrypts raw data that was encrypted by encryptData. Throws on error.

Parameters:

Name Type Description
data Buffer Data to decrypt.
key Buffer Private key to decrypt the message with.
sender boolean If the decryptor is the sender of the message.

Returns: Buffer

Decrypted data.


encryptComment

encryptComment(comment: string, pubKeyRecipient: Buffer, pubKeySelf: Buffer): EncryptionStatus

Defined in packages/sdk/utils/src/commentEncryption.ts:69

Encrypts a comment. If it can encrypt, it returns a base64 string with the following: ECIES(session key to other) + ECIES(session key to self) + AES(comment) If it fails to encrypt, it returns the comment without any changes.

Parameters:

Name Type Description
comment string Comment to encrypt.
pubKeyRecipient Buffer Public key of the recipient. May be compressed.
pubKeySelf Buffer Public key of the sender. May be compressed.

Returns: EncryptionStatus

base64 string of encrypted comment if can encrypt, otherwise comment.


encryptData

encryptData(data: Buffer, pubKeyRecipient: Buffer, pubKeySelf: Buffer): Buffer

Defined in packages/sdk/utils/src/commentEncryption.ts:27

Encrypts a buffer to two recipients. Throws on error.

Parameters:

Name Type Description
data Buffer Data to encrypt
pubKeyRecipient Buffer Public key of the recipient. Uncompressed without leading 0x04.
pubKeySelf Buffer Public key of the sender. Uncompressed without leading 0x04.

Returns: Buffer

Encrypted data to sender and recipient.

Object literals

Const CommentEncryptionUtils

CommentEncryptionUtils: object

Defined in packages/sdk/utils/src/commentEncryption.ts:115

decryptComment

decryptComment: decryptComment

Defined in packages/sdk/utils/src/commentEncryption.ts:117

encryptComment

encryptComment: encryptComment

Defined in packages/sdk/utils/src/commentEncryption.ts:116