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.
94 lines (93 loc) • 4.17 kB
TypeScript
import { AmountRecoveryReq } from './amountRecoveryReq';
import { AmountRecoveryRes } from './amountRecoveryRes';
import { ManagedObj } from './managedObj';
import { Point } from './point';
import { Scalar } from './scalar';
import { TokenId } from './tokenId';
/** Represents a (possibly aggregated) range proof for one or more confidential transaction amounts.
*
* Examples:
* ```ts
* const { RangeProof, AmountRecoveryReq, AmountRecoveryRes, Point, TokenId } = require('navio-blsct')
* const nonce = Point.random()
* const tokenId = TokenId.default()
* const rp = RangeProof.generate([456], nonce, 'navio', tokenId)
* RangeProof.verifyProofs([rp]) // true
* const req = new AmountRecoveryReq(rp, nonce)
* const res = RangeProof.recoverAmounts([req1])
* res[0].isSucc // true
* res[0].amount // 456
* res[0].message // 'navio'
* rp.get_A() // Point object representing A
* rp.get_A_wip() // Point object representing A_wip
* rp.get_B() // Point object representing B
* rp.get_r_prime() // Scalar object representing r'
* rp.get_s_prime() // Scalar object representing s'
* rp.get_delta_prime() // Scalar object representing delta'
* rp.get_alpha_hat() // Scalar object representing alpha_hat
* rp.get_tau_x() // Scalar object representing tau_x
* const ser = rp.serialize()
* const deser = RangeProof.deserialize(ser)
* ser === deser.serialize() // true
* ```
*/
export declare class RangeProof extends ManagedObj {
constructor(obj: any);
/** Generates a range proof for the given amounts, nonce, and message.
* @param amounts - An array of amounts to be included in the range proof.
* @param nonce - A nonce used to generate the range proof.
* @param msg - A message associated with the range proof.
* @param tokenId - An optional token ID. If not provided, a default token ID is used.
* @returns A new `RangeProof` instance containing the generated range proof.
*/
static generate(amounts: number[], nonce: Point, msg: string, tokenId?: TokenId): RangeProof;
/** Verifies a list of range proofs.
* @param proofs - An array of `RangeProof` instances to be verified.
* @returns `true` if all proofs are valid, `false` otherwise.
*/
static verifyProofs(proofs: RangeProof[]): boolean;
/** Recovers amounts from a list of `AmountRecoveryReq` instances.
* @param reqs - An array of `AmountRecoveryReq` instances containing range proofs and nonces.
* @returns An array of `AmountRecoveryRes` instances containing the recovery results.
*/
recoverAmounts(reqs: AmountRecoveryReq[]): AmountRecoveryRes[];
value(): any;
serialize(): string;
/** Deserializes a hexadecimal string into a `RangeProof` instance.
* @param hex - A hexadecimal string representing the serialized range proof.
* @returns A new `RangeProof` instance containing the deserialized data.
*/
static deserialize(this: new (obj: any) => RangeProof, hex: string): RangeProof;
/** Returns the A point of the range proof.
* @returns A `Point` object representing the A point.
*/
get_A(): Point;
/** Returns the A_wip point of the range proof.
* @returns A `Point` object representing the A_wip point.
*/
get_A_wip(): Point;
/** Returns the B point of the range proof.
* @returns A `Point` object representing the B point.
*/
get_B(): Point;
/** Returns the r' scalar of the range proof.
* @returns A `Scalar` object representing the r' scalar.
*/
get_r_prime(): Scalar;
/** Returns the s' scalar of the range proof.
* @returns A `Scalar` object representing the s' scalar.
*/
get_s_prime(): Scalar;
/** Returns the tau_x scalar of the range proof.
* @returns A `Scalar` object representing the tau_x scalar.
*/
get_delta_prime(): Scalar;
/** Returns the alpha_hat scalar of the range proof.
* @returns A `Scalar` object representing the alpha_hat scalar.
*/
get_alpha_hat(): Scalar;
/** Returns the tau_x scalar of the range proof.
* @returns A `Scalar` object representing the t_aux scalar.
*/
get_tau_x(): Scalar;
}