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.
31 lines (30 loc) • 984 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubAddr = void 0;
const blsct_1 = require("./blsct");
const managedObj_1 = require("./managedObj");
class SubAddr extends managedObj_1.ManagedObj {
constructor(obj) {
super(obj);
}
static generate(viewKey, spendingPubKey, subAddrId) {
const obj = (0, blsct_1.deriveSubAddress)(viewKey.value(), spendingPubKey.value(), subAddrId.value());
return new SubAddr(obj);
}
static fromDoublePublicKey(dpk) {
const rv = (0, blsct_1.dpkToSubAddr)(dpk.value());
const inst = new SubAddr(rv.value);
(0, blsct_1.freeObj)(rv);
return inst;
}
value() {
return (0, blsct_1.castToSubAddr)(this.obj);
}
serialize() {
return (0, blsct_1.serializeSubAddr)(this.value());
}
static deserialize(hex) {
return SubAddr._deserialize(hex, blsct_1.deserializeSubAddr);
}
}
exports.SubAddr = SubAddr;