UNPKG

@cashu/cashu-ts

Version:

cashu library for communicating with a cashu mint

72 lines (71 loc) 2.29 kB
import { ProjPointType } from '@noble/curves/abstract/weierstrass'; export type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>; export type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>; export type MintKeys = { [k: string]: Uint8Array; }; export type SerializedMintKeys = { [k: string]: string; }; export type Keyset = { id: string; unit: string; active: boolean; }; export type BlindSignature = { C_: ProjPointType<bigint>; amount: number; id: string; }; export type SerializedBlindSignature = { C_: string; amount: number; id: string; }; export type DLEQ = { s: Uint8Array; e: Uint8Array; r?: bigint; }; export type Proof = { C: ProjPointType<bigint>; secret: Uint8Array; amount: number; id: string; witness?: Witness; }; export type SerializedProof = { C: string; secret: string; amount: number; id: string; witness?: string; }; export type SerializedBlindedMessage = { B_: string; amount: number; witness?: string; }; export type Secret = [WellKnownSecret, SecretData]; export type WellKnownSecret = 'P2PK'; export type SecretData = { nonce: string; data: string; tags?: string[][]; }; export type Witness = { signatures: string[]; }; export type Tags = { [k: string]: string; }; export type SigFlag = 'SIG_INPUTS' | 'SIG_ALL'; export declare function hashToCurve(secret: Uint8Array): ProjPointType<bigint>; export declare function hash_e(pubkeys: Array<ProjPointType<bigint>>): Uint8Array; export declare function pointFromBytes(bytes: Uint8Array): import('@noble/curves/abstract/weierstrass').WeierstrassPoint<bigint>; export declare function pointFromHex(hex: string): import('@noble/curves/abstract/weierstrass').WeierstrassPoint<bigint>; export declare const getKeysetIdInt: (keysetId: string) => bigint; export declare function createRandomPrivateKey(): Uint8Array<ArrayBufferLike>; export declare function serializeMintKeys(mintKeys: MintKeys): SerializedMintKeys; export declare function deserializeMintKeys(serializedMintKeys: SerializedMintKeys): MintKeys; export declare function deriveKeysetId(keys: MintKeys): string;