Account

Overview

Key Management class. Enables the creation of a new Beo Account, importation of an existing account from an existing private key or seed, and message signing and verification functionality.

An Beo Account is generated from a randomly generated seed (number) from which an account private key, view key, and a public account address are derived. The private key lies at the root of an account. It is a highly sensitive secret and should be protected as it allows for creation of Beo Program executions and arbitrary value transfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public address to which other users of Beo can send Beo credits and other records to. This class should only be used in environments where the safety of the underlying key material can be assured.

Kind: global class

account.encryptAccount(ciphertext) ⇒ PrivateKeyCiphertext

Encrypt the account's private key with a password

Kind: instance method of Account

Param
Type

ciphertext

string

Example

let account = new Account();
let ciphertext = account.encryptAccount("password");

account.decryptRecord(ciphertext) ⇒ Record

Decrypts a Record in ciphertext form into plaintext

Kind: instance method of Account

Param
Type

ciphertext

string

Example

let account = new Account();
let record = account.decryptRecord("record1ciphertext");

account.decryptRecords(ciphertexts) ⇒ Array.<Record>

Decrypts an array of Records in ciphertext form into plaintext

Kind: instance method of Account

Param
Type

ciphertexts

Array.<string>

Example

let account = new Account();
let record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);

account.ownsRecordCiphertext(ciphertext) ⇒ boolean

Determines whether the account owns a ciphertext record

Kind: instance method of Account

Param
Type

ciphertext

RecordCipherText | string

Example

// Create a connection to the Beo network and an account
let connection = new NodeConnection("vm.Beo.org/api");
let account = Account.fromCiphertext("ciphertext", "password");

// Get a record from the network
let record = connection.getBlock(1234);
let recordCipherText = record.transactions[0].execution.transitions[0].id;

// Check if the account owns the record
if account.ownsRecord(recordCipherText) {
    // Then one can do something like:
    // Decrypt the record and check if it's spent
    // Store the record in a local database
    // Etc.
}

account.sign(message) ⇒ Signature

Signs a message with the account's private key. Returns a Signature.

Kind: instance method of Account

Param
Type

message

Uint8Array

Example

let account = new Account();
let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
account.sign(message);

account.verify(message, signature) ⇒ boolean

Verifies the Signature on a message.

Kind: instance method of Account

Param
Type

message

Uint8Array

signature

Signature

Example

let account = new Account();
let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
let signature = account.sign(message);
account.verify(message, signature);

Account.fromCiphertext(ciphertext, password) ⇒ PrivateKey | Error

Attempts to create an account from a private key ciphertext

Kind: static method of Account

Param
Type

ciphertext

PrivateKeyCiphertext | string

password

string

Example

let ciphertext = PrivateKey.newEncrypted("password");
let account = Account.fromCiphertext(ciphertext, "password");

Last updated