Ciphertext
Overview
SnarkVM Ciphertext object. A Ciphertext represents a symmetrically encrypted plaintext. This object provides decryption methods to recover the plaintext from the ciphertext given the proper decryption materials like view keys, transition keys, or nonces.
Methods
decrypt
Decrypt the ciphertext using the given view key
decrypt(viewKey, nonce) ► Plaintext
| Param | Type | Description |
|---|---|---|
| viewKey | ViewKey | The view key of the account that encrypted the ciphertext |
| nonce | Group | The nonce used to encrypt the ciphertext |
| return | Plaintext | The decrypted plaintext |
decryptWithTransitionInfo
Decrypt a ciphertext using the view key of the transition signer, transition public key, and (program, function, index) tuple
decryptWithTransitionInfo(view_key, transition_public_key, program, function_name, index) ► Plaintext
| Param | Type | Description |
|---|---|---|
| view_key | ViewKey | The view key of the transition signer |
| transition_public_key | Group | The transition public key used to encrypt the ciphertext |
| program | string | The program ID associated with the ciphertext |
| function_name | string | The name of the function associated with the encrypted inputs and outputs |
| index | u16 | The index of the input or output parameter that was encrypted |
| return | Plaintext | The decrypted plaintext |
decryptWithTransitionViewKey
Decrypt a ciphertext using the transition view key and a (program, function, index) tuple
decryptWithTransitionViewKey(transition_view_key, program, function_name, index) ► Plaintext
| Param | Type | Description |
|---|---|---|
| transition_view_key | Field | The transition view key that was used to encrypt the ciphertext |
| program | string | The program ID associated with the ciphertext |
| function_name | string | The name of the function associated with the encrypted inputs and outputs |
| index | u16 | The index of the input or output parameter that was encrypted |
| return | Plaintext | The decrypted plaintext |
decryptSymmetric
Decrypts a ciphertext into plaintext using the given ciphertext view key
decryptSymmetric(transition_view_key) ► Plaintext
| Param | Type | Description |
|---|---|---|
| transition_view_key | Field | The transition view key that was used to encrypt the ciphertext |
| return | Plaintext | The decrypted plaintext |
fromBytesLe
Deserialize a left endian byte array into a Ciphertext
fromBytesLe(bytes) ► Ciphertext
| Param | Type | Description |
|---|---|---|
| bytes | Uint8Array | The byte array representing the Ciphertext |
| return | Ciphertext | The Ciphertext object |
toBytesLe
Get the left endian byte array representation of the ciphertext
toBytesLe() ► Uint8Array
| Param | Type |
|---|---|
| return | Uint8Array |
fromBitsLe
Get a ciphertext object from a series of bits represented as a boolean array
fromBitsLe(bits) ► Ciphertext
| Param | Type | Description |
|---|---|---|
| bits | Array | A left endian boolean array representing the bits of the ciphertext |
| return | Ciphertext | The ciphertext object |
toBitsLe
Get the left endian boolean array representation of the bits of the ciphertext
toBitsLe() ► Array.<any>
| Param | Type |
|---|---|
| return | Array.<any> |
fromFields
Get a ciphertext object from an array of fields
fromFields(fields) ► Ciphertext
| Param | Type | Description |
|---|---|---|
| fields | Array | An array of fields |
| return | Ciphertext | The ciphertext object |
toFields
Get the field array representation of the ciphertext
toFields() ► Array.<any>
| Param | Type |
|---|---|
| return | Array.<any> |
fromString
Deserialize a Ciphertext string into a Ciphertext object
fromString(ciphertext) ► Ciphertext
| Param | Type | Description |
|---|---|---|
| ciphertext | string | A string representation of the ciphertext |
| return | Ciphertext | The Ciphertext object |
toBytes
Serialize a Ciphertext object into a byte array
toBytes() ► Uint8Array
| Param | Type |
|---|---|
| return | Uint8Array |
toString
Serialize a Ciphertext into a js string
toString() ► string
| Param | Type |
|---|---|
| return | string |