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.
49 lines (48 loc) • 2.01 kB
TypeScript
import { PublicKey } from './keys/publicKey';
import { DoublePublicKey } from './keys/doublePublicKey';
import { Scalar } from './scalar';
import { ManagedObj } from './managedObj';
import { SubAddrId } from './subAddrId';
/** Represents a sub-address.
*
* Examples:
* ```ts
* const { SubAddr, PublicKey, DoublePublicKey, SubAddrId } = require('navio-blsct')
* const seed = new Scalar()
* const viewKey = new ChildKey(seed).toTxKey().toViewKey()
* const spendingPubKey = new PublicKey()
* const subAddrId = new SubAddrId(123, 456)
* new SubAddr(viewKey, spendingPubKey, subAddrId)
* const dpk = new DoublePublicKey()
* const x = SubAddr.fromDoublePublicKey(dpk)
* const ser = x.serialize()
* const deser = SubAddr.deserialize(ser)
* ser === deser.serialize() // true
* ```
*/
export declare class SubAddr extends ManagedObj {
constructor(obj: any);
/** Generates a new `SubAddr` instance.
*
* @param viewKey - The view key used for deriving the sub-address.
* @param spendingPubKey - The spending public key used for deriving the sub-address.
* @param subAddrId - The sub-address ID used for deriving the sub-address.
* @return A new `SubAddr` instance with the specified view key, spending public key, and sub-address ID.
*/
static generate(viewKey: Scalar, spendingPubKey: PublicKey, subAddrId: SubAddrId): SubAddr;
/** Generates a `SubAddr` from a `DoublePublicKey`.
*
* @param dpk - The `DoublePublicKey` used to derive the sub-address.
* @return A new `SubAddr` instance derived from the `DoublePublicKey`.
*/
static fromDoublePublicKey(dpk: DoublePublicKey): SubAddr;
toDoublePublicKey(): DoublePublicKey;
value(): any;
serialize(): string;
/** Deserializes a `SubAddr` from its hexadecimal representation.
*
* @param hex - The hexadecimal string to deserialize.
* @returns A new `SubAddr` instance.
*/
static deserialize(this: new (obj: any) => SubAddr, hex: string): SubAddr;
}