UNPKG

navio-blsct

Version:

TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.

48 lines (47 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SubAddrId = void 0; const blsct_1 = require("./blsct"); const managedObj_1 = require("./managedObj"); /** Represents a sub-address ID. * * Examples: * ```ts * const { SubAddrId } = require('navio-blsct') * const x = SubAddrId.generate(123, 456) * x * const ser = x.serialize() * const deser = SubAddrId.deserialize(ser) * ser === deser.serialize() // true * ``` */ class SubAddrId extends managedObj_1.ManagedObj { constructor(obj) { super(obj); } /** Generates a new `SubAddrId` instance. * * @param account - The account for the sub-address. * @param address - The address for the sub-address. * @return A new `SubAddrId` instance with the specified account and address. */ static generate(account, address) { const obj = (0, blsct_1.genSubAddrId)(account, address); return new SubAddrId(obj); } value() { return (0, blsct_1.castToSubAddrId)(this.obj); } serialize() { return (0, blsct_1.serializeSubAddrId)(this.value()); } /** Deserializes a `SubAddrId` from its hexadecimal representation. * * @param hex - The hexadecimal string to deserialize. * @returns A new `SubAddrId` instance. */ static deserialize(hex) { return SubAddrId._deserialize(hex, blsct_1.deserializeSubAddrId); } } exports.SubAddrId = SubAddrId;