Skip to main content

RecordPlaintext

Overview

Represents a plaintext Aleo record. The RecordPlaintext class provides methods for creating, inspecting, and extracting data from decrypted records including computing serial numbers and commitments.

Methods

fromString

Return a record plaintext from a string

fromString(record)RecordPlaintext
ParamTypeDescription
recordstringString representation of a plaintext representation of an Aleo record
returnRecordPlaintextRecord plaintext

toString

Returns the record plaintext string

toString() ► string
ParamType
returnstring

commitment

Get the commitment of the record

commitment(program_id, record_name, record_view_key)Field
ParamTypeDescription
program_idstringProgram ID of the program that the record is associated with
record_namestringName of the record
record_view_keystringThe string representation of the record view key
returnFieldCommitment of the record

getMember

Get the record entry matching a key

getMember(input)Plaintext
ParamTypeDescription
inputstringThe key to retrieve the value in the record data field
returnPlaintextThe plaintext value corresponding to the key

owner

Get the owner of the record

owner()Address
ParamType
returnAddress

toJsObject

Get a representation of a record as a javascript object for usage in client side computations. Note that this is not a reversible operation and exists for the convenience of discovering and using properties of the record.

The conversion guide is as follows:

  • u8, u16, u32, i8, i16, i32 → Number
  • u64, u128, i64, i128 → BigInt
  • Address, Field, Group, Scalar → String (bech32 representation)
toJsObject()Object
ParamType
returnObject

fromBytesLe

Get a record plaintext object from a series of bytes

fromBytesLe(bytes)RecordPlaintext
ParamTypeDescription
bytesUint8ArrayA left endian byte array representing the record plaintext
returnRecordPlaintextThe record plaintext

toBytesLe

Returns the left endian byte array representation of the record plaintext

toBytesLe()Uint8Array
ParamType
returnUint8Array

toBitsLe

Returns the left endian boolean array representation of the record plaintext bits

toBitsLe()Array
ParamType
returnArray

toFields

Get the field array representation of the record plaintext

toFields()Array
ParamType
returnArray

microcredits

Returns the amount of microcredits in the record

microcredits() ► bigint
ParamType
returnbigint

nonce

Returns the nonce of the record. This can be used to uniquely identify a record.

nonce() ► string
ParamType
returnstring

serialNumberString

Attempt to get the serial number of a record to determine whether or not it has been spent

serialNumberString(private_key, program_id, record_name, record_view_key) ► string
ParamTypeDescription
private_keyPrivateKeyPrivate key of the account that owns the record
program_idstringProgram ID of the program that the record is associated with
record_namestringName of the record
record_view_keystringThe string representation of the record view key
returnstringSerial number of the record

tag

Get the tag of the record using the graph key

tag(graph_key, commitment)Field
ParamTypeDescription
graph_keyGraphKeyGraph key of the account
commitmentFieldCommitment of the record
returnFieldTag of the record

recordViewKey

Generate the record view key. The record view key can only decrypt the record if the supplied view key belongs to the record owner.

recordViewKey(view_key)Field
ParamTypeDescription
view_keyViewKeyView key used to generate the record view key
returnFieldRecord view key

decryptSender

Decrypt the sender ciphertext associated with the record

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

clone

Clone the RecordPlaintext WASM object

clone()RecordPlaintext
ParamType
returnRecordPlaintext