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.
38 lines (37 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ViewTag = void 0;
const blsct_1 = require("./blsct");
const publicKey_1 = require("./keys/publicKey");
const scalar_1 = require("./scalar");
/** Represents a view tag derived from a blinding public key and a view key. The view tag is a 64-bit unsigned integer.
*
* Examples:
* ```ts
* const { ViewTag, PublicKey, ChildKey, Scalar } = require('navio-blsct')
* const blindingPubKey = PublicKey.random()
* const seed = Scalar.random()
* const viewKey = new ChildKey(seed).toTxKey().toViewKey()
* new ViewTag(blindingPubKey, viewKey)
* ```
*/
class ViewTag {
value;
/** Constructs a new `ViewTag` instance.
*
* @param blindingPubKey - The public key used for blinding.
* @param viewKey - The view key.
*/
constructor(blindingPubKey, viewKey) {
this.value = (0, blsct_1.calcViewTag)(blindingPubKey.value(), viewKey.value());
}
/** Generates a random view tag.
* @returns A new `ViewTag` instance with a random blinding public key and view key.
*/
static random() {
const blindingPubKey = publicKey_1.PublicKey.random();
const viewKey = scalar_1.Scalar.random();
return new ViewTag(blindingPubKey, viewKey);
}
}
exports.ViewTag = ViewTag;