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.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CTxOutBlsctData = void 0;
const blsct_1 = require("./blsct");
const blindingKey_1 = require("./keys/childKeyDesc/blindingKey");
const managedObj_1 = require("./managedObj");
const point_1 = require("./point");
const rangeProof_1 = require("./rangeProof");
const spendingKey_1 = require("./keys/childKeyDesc/txKeyDesc/spendingKey");
class CTxOutBlsctData extends managedObj_1.ManagedObj {
rangeProofCache;
constructor(obj) {
super(obj);
this.fi.isBorrow = true;
}
value() {
// all the properties provided by this class
// are actually properties of CTxOut
return (0, blsct_1.castToCTxOut)(this.obj);
}
getSpendingKey() {
const obj = (0, blsct_1.getCTxOutSpendingKey)(this.value());
return spendingKey_1.SpendingKey.fromObj(obj);
}
getEphemeralKey() {
const obj = (0, blsct_1.getCTxOutEphemeralKey)(this.value());
return point_1.Point.fromObj(obj);
}
getBlindingKey() {
const obj = (0, blsct_1.getCTxOutBlindingKey)(this.value());
return blindingKey_1.BlindingKey.fromObj(obj);
}
getRangeProof() {
if (this.rangeProofCache !== undefined) {
return this.rangeProofCache;
}
const rv = (0, blsct_1.getCTxOutRangeProof)(this.value());
const x = rangeProof_1.RangeProof.fromObjAndSize(rv.value, rv.value_size);
(0, blsct_1.freeObj)(rv);
this.rangeProofCache = x;
return x;
}
getViewTag() {
return (0, blsct_1.getCTxOutViewTag)(this.value());
}
}
exports.CTxOutBlsctData = CTxOutBlsctData;