Skip to main content

EncryptionToolkit

Overview

EncryptionToolkit provides a set of functions for encrypting, decrypting, and generating individual view keys for records, transitions, and ciphertexts. This class enables bulk operations on records and selective decryption using record-specific view keys.

Methods

generateTvk

Generates a transition view key from the view key and the transition public key

generateTvk(view_key, tpk)Field
ParamTypeDescription
view_keyViewKeyThe view key of the account that generated the transition
tpkGroupThe transition public key
returnFieldThe transition view key

generateRecordViewKey

Creates a record view key from the view key. This can later be used to decrypt a record without revealing an account's view key.

generateRecordViewKey(view_key, record_ciphertext)Field
ParamTypeDescription
view_keyViewKeyThe view key of the owner of the record
record_ciphertextRecordCiphertextThe record ciphertext used to derive the record view key
returnFieldThe record view key

decryptRecordWithRVk

Decrypts a record ciphertext using the record view key. Decryption only succeeds if the record view key was generated from the view key of the record owner.

decryptRecordWithRVk(record_vk, record_ciphertext)RecordPlaintext
ParamTypeDescription
record_vkFieldThe record view key
record_ciphertextRecordCiphertextThe record ciphertext to decrypt
returnRecordPlaintextThe decrypted record plaintext

decryptTransitionWithVk

Decrypts a transition using the transition view key. The ciphertext inputs and outputs can only be decrypted if the transition view key was generated by the transaction signer.

decryptTransitionWithVk(transition, transition_vk)Transition
ParamTypeDescription
transitionTransitionThe transition to decrypt
transition_vkFieldThe transition view key
returnTransitionThe decrypted transition

decryptOwnedRecords

Decrypts a set of record ciphertexts in parallel and stores successful decryptions

decryptOwnedRecords(view_key, records)Array<RecordPlaintext>
ParamTypeDescription
view_keyViewKeyThe view key of the owner of the records
recordsArray<RecordCiphertext>The record ciphertexts to decrypt
returnArray<RecordPlaintext>The decrypted record plaintexts

checkOwnedRecords

Checks if record ciphertexts are owned by the given view key

checkOwnedRecords(view_key, records)Array<RecordCiphertext>
ParamTypeDescription
view_keyViewKeyView key of the owner of the records
recordsArray<RecordCiphertext>The record ciphertexts for which to check ownership
returnArray<RecordCiphertext>The record ciphertexts that are owned by the view key

decryptSender

Decrypt the sender ciphertext associated with a record

decryptSender(view_key, record, sender_ciphertext)Address
ParamTypeDescription
view_keyViewKeyView key associated with the record
recordRecordPlaintextRecord plaintext associated with a sender
sender_ciphertextFieldSender ciphertext associated with the record
returnAddressAddress of the sender

decryptSenderWithRvk

Decrypt the sender ciphertext associated with the record using the record view key

decryptSenderWithRvk(record_view_key, sender_ciphertext)Address
ParamTypeDescription
record_view_keyFieldRecord view key associated with the record
sender_ciphertextFieldSender ciphertext associated with the record
returnAddressThe address of the sender