UNPKG

@scure/sr25519

Version:

Audited & minimal implementation of sr25519 (polkadot) cryptography, with Merlin and Strobe

63 lines 2.6 kB
import { ristretto255 } from '@noble/curves/ed25519.js'; type Point = typeof ristretto255.Point.BASE; type Data = string | Uint8Array; declare class Strobe128 { state: Uint8Array; state32: Uint32Array; pos: number; posBegin: number; curFlags: number; constructor(protocolLabel: Data); private keccakF1600; private runF; private absorb; private squeeze; private overwrite; private beginOp; metaAD(data: Data, more: boolean): void; AD(data: Data, more: boolean): void; PRF(len: number, more: boolean): Uint8Array; KEY(data: Data, more: boolean): void; clone(): Strobe128; clean(): void; } declare class Merlin { strobe: Strobe128; constructor(label: Data); appendMessage(label: Data, message: Data): void; challengeBytes(label: Data, len: number): Uint8Array; clean(): void; } declare class SigningContext extends Merlin { constructor(name: string); label(label: Data): void; bytes(bytes: Uint8Array): this; protoName(label: Data): void; commitPoint(label: Data, point: Point): void; challengeScalar(label: Data): bigint; witnessScalar(label: Data, random: Uint8Array, nonceSeeds?: Uint8Array[]): bigint; witnessBytes(label: Data, len: number, random: Uint8Array, nonceSeeds?: Uint8Array[]): Uint8Array; } export declare function getPublicKey(secretKey: Uint8Array): Uint8Array; export declare function secretFromSeed(seed: Uint8Array): Uint8Array; export declare function fromKeypair(pair: Uint8Array): Uint8Array; export declare function sign(secretKey: Uint8Array, message: Uint8Array, random?: Uint8Array): Uint8Array; export declare function verify(message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean; export declare function getSharedSecret(secretKey: Uint8Array, publicKey: Uint8Array): Uint8Array; export declare const HDKD: { secretSoft(secretKey: Uint8Array, chainCode: Uint8Array, random?: Uint8Array): Uint8Array; publicSoft(publicKey: Uint8Array, chainCode: Uint8Array): Uint8Array; secretHard(secretKey: Uint8Array, chainCode: Uint8Array): Uint8Array; }; type VRF = { sign(msg: Uint8Array, secretKey: Uint8Array, ctx: Uint8Array, extra: Uint8Array, random?: Uint8Array): Uint8Array; verify(msg: Uint8Array, signature: Uint8Array, publicKey: Uint8Array, ctx?: Uint8Array, extra?: Uint8Array): boolean; }; export declare const vrf: VRF; export declare const __tests: { Strobe128: typeof Strobe128; Merlin: typeof Merlin; SigningContext: typeof SigningContext; }; export {}; //# sourceMappingURL=index.d.ts.map