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
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | The view key of the account that generated the transition |
| tpk | Group | The transition public key |
| return | Field | The 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
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | The view key of the owner of the record |
| record_ciphertext | RecordCiphertext | The record ciphertext used to derive the record view key |
| return | Field | The 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
| Param | Type | Description |
|---|---|---|
| record_vk | Field | The record view key |
| record_ciphertext | RecordCiphertext | The record ciphertext to decrypt |
| return | RecordPlaintext | The 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
| Param | Type | Description |
|---|---|---|
| transition | Transition | The transition to decrypt |
| transition_vk | Field | The transition view key |
| return | Transition | The decrypted transition |
decryptOwnedRecords
Decrypts a set of record ciphertexts in parallel and stores successful decryptions
decryptOwnedRecords(view_key, records) ► Array<RecordPlaintext>
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | The view key of the owner of the records |
| records | Array<RecordCiphertext> | The record ciphertexts to decrypt |
| return | Array<RecordPlaintext> | The decrypted record plaintexts |
checkOwnedRecords
Checks if record ciphertexts are owned by the given view key
checkOwnedRecords(view_key, records) ► Array<RecordCiphertext>
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | View key of the owner of the records |
| records | Array<RecordCiphertext> | The record ciphertexts for which to check ownership |
| return | Array<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
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | View key associated with the record |
| record | RecordPlaintext | Record plaintext associated with a sender |
| sender_ciphertext | Field | Sender ciphertext associated with the record |
| return | Address | Address of the sender |
decryptSenderWithRvk
Decrypt the sender ciphertext associated with the record using the record view key
decryptSenderWithRvk(record_view_key, sender_ciphertext) ► Address
| Param | Type | Description |
|---|---|---|
| record_view_key | Field | Record view key associated with the record |
| sender_ciphertext | Field | Sender ciphertext associated with the record |
| return | Address | The address of the sender |