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.
let account = new Account();
let record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);
// 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.
}
let account = new Account();
let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
account.sign(message);
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);
let ciphertext = PrivateKey.newEncrypted("password");
let account = Account.fromCiphertext(ciphertext, "password");