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.
43 lines (42 loc) • 1.61 kB
TypeScript
import { Scalar } from './scalar';
import { PublicKey } from './keys/publicKey';
import { ManagedObj } from './managedObj';
/** Represents the signature of a transaction.
*
* Examples:
* ```ts
* const { PublicKey, Scalar, Signature } = require('navio-blsct')
* const sk = Scalar.random()
* const pk = PublicKey.fromScalar(sk)
* const sig = Signature.generate(sk, 'navio')
* sig.verify(pk, 'navio')
* const ser = sig.serialize()
* const deser = Signature.deserialize(ser)
* ser === deser.serialize() // true
* ```
*/
export declare class Signature extends ManagedObj {
constructor(obj: any);
/** Generates a new `Signature` instance.
*
* @param privKey - The private key used to sign the message.
* @param msg - The message to be signed.
* @return A new `Signature` instance containing the signature of the message.
*/
static generate(privKey: Scalar, msg: string): Signature;
/** Verifies the signature against a public key and message.
*
* @param pubKey - The public key used to verify the signature.
* @param msg - The message that was signed.
* @return `true` if the signature is valid for the given public key and message, otherwise `false`.
*/
verify(pubKey: PublicKey, msg: string): boolean;
value(): any;
serialize(): string;
/** Serializes the signature to a hexadecimal string.
*
* @param hex - The hexadecimal string to serialize.
* @returns A hexadecimal string representation of the signature.
*/
static deserialize(this: new (obj: any) => Signature, hex: string): Signature;
}