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.

52 lines (51 loc) 2.32 kB
import { ManagedObj } from '../managedObj'; import { PublicKey } from './publicKey'; import { Scalar } from '../scalar'; /** The unique source from which an address is derived. * A `DoublePublicKey` is a pair of `PublicKey`s that can be used to derive an address. * * Instantiating a `DoublePublicKey` object without a parameter returns a `DoublePublicKey` consisting of two randomly generated `PublicKey`s. * * Examples: * ```ts * const { DoublePublicKey, PublicKey } = require('navio-blsct') * const dpk = new DoublePublicKey() * const pk1 = PublicKey.random() * const pk2 = PublicKey.random() * const dpk2 = DoublePublicKey.from_public_keys(pk1, pk2) * const vk = Scalar.random() * const spendingPk = PublicKey.random() * const dpk3 = DoublePublicKey.fromKeysAndAcctAddr(vk, spendingPk, 1, 2) * const ser = dpk3.serialize() * const deser = DoublePublicKey.deserialize(ser) * deser.serialize() == ser * ``` */ export declare class DoublePublicKey extends ManagedObj { constructor(obj?: any); /** Generates a random `DoublePublicKey`. * @returns A new DoublePublicKey instance with two random `PublicKey`s. */ static random(): DoublePublicKey; /** Generates a `DoublePublicKey` from the provided `PublicKey`s. * @param pk1 - The first `PublicKey`. * @param pk2 - The second `PublicKey`. * @returns A new `DoublePublicKey` instance. */ static fromPublicKeys(pk1: PublicKey, pk2: PublicKey): DoublePublicKey; /** Generates a `DoublePublicKey` from the provided `PublicKey`, account, and address * @param viewKey - The `Scalar` used to derive the `DoublePublicKey`. * @param spendingPubKey - The `PublicKey` used for spending. * @param account - The account. * @param address - The address. * @returns A new `DoublePublicKey` instance. */ static fromKeysAcctAddr(viewKey: Scalar, spendingPubKey: PublicKey, account: number, address: number): DoublePublicKey; value(): any; serialize(): string; /** Deserializes a hexadecimal string into a `DoublePublicKey` instance. * @param hex - The hexadecimal string to convert. * @returns The `DoublePublicKey` instance represented by the input string. */ static deserialize(this: new (obj: any) => DoublePublicKey, hex: string): DoublePublicKey; }