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.

32 lines (31 loc) 966 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TxKey = void 0; const blsct_1 = require("../blsct"); const scalar_1 = require("../scalar"); /** Represents a tx key. A tx key is a Scalar and introduces no new functionality; it serves purely as a semantic alias. Both SpendingKey and ViewKey are exclusively derived from a TxKey. * * Examples: * ```ts * const { Scalar, ChildKey } = require('navio-blsct') * const s = Scalar.random() * const ck = new ChildKey(s) * const tk = ck.toTxKey() * tk.toSpendingKey() * tk.toViewKey() * ``` */ class TxKey extends scalar_1.Scalar { constructor(obj) { super(obj); } toSpendingKey() { const obj = (0, blsct_1.fromTxKeyToSpendingKey)(this.value()); return new scalar_1.Scalar(obj); } toViewKey() { const obj = (0, blsct_1.fromTxKeyToViewKey)(this.value()); return new scalar_1.Scalar(obj); } } exports.TxKey = TxKey;