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.

36 lines (35 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AmountRecoveryReq = void 0; const blsct_1 = require("./blsct"); const point_1 = require("./point"); const rangeProof_1 = require("./rangeProof"); class AmountRecoveryReq { rangeProof; nonce; constructor(rangeProof, nonce) { this.rangeProof = rangeProof; this.nonce = nonce; } toString() { return `${this.constructor.name}(${this.rangeProof}, ${this.nonce})`; } serialize() { const serRangeProof = this.rangeProof.serialize(); const serNonce = this.nonce.serialize(); return `${serRangeProof}${serNonce}`; } static deserialize(hex) { if (hex.length % 2 !== 0) { hex = `0${hex}`; } const nonceHexLen = blsct_1.POINT_SIZE * 2; const rangeProofHexLen = hex.length - nonceHexLen; const rangeProofHex = hex.slice(0, rangeProofHexLen); const nonceHex = hex.slice(rangeProofHexLen); const rangeProof = rangeProof_1.RangeProof.deserialize(rangeProofHex); const nonce = point_1.Point.deserialize(nonceHex); return new AmountRecoveryReq(rangeProof, nonce); } } exports.AmountRecoveryReq = AmountRecoveryReq;