/* tslint:disable */
/* eslint-disable */

export class DilithiumSigningKey {
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Get the public key bytes (1952 bytes for Dilithium3).
   */
  publicKey(): Uint8Array;
  /**
   * Get the secret key bytes (4000 bytes for Dilithium3).
   *
   * WARNING: Handle with care! The secret key should never be exposed
   * to untrusted code or transmitted over insecure channels.
   */
  secretKey(): Uint8Array;
  /**
   * Get the signature size in bytes.
   */
  static signatureSize(): number;
  /**
   * Get the public key size in bytes.
   */
  static publicKeySize(): number;
  /**
   * Get the secret key size in bytes.
   */
  static secretKeySize(): number;
  /**
   * Generate a new random Dilithium3 keypair.
   *
   * This creates a new keypair using system entropy. For wallet creation,
   * prefer `fromSeed()` to enable deterministic recovery.
   */
  constructor();
  /**
   * Sign a message with the Dilithium3 secret key.
   *
   * Returns the signature bytes (3293 bytes for Dilithium3).
   */
  sign(message: Uint8Array): Uint8Array;
  /**
   * Verify a signature against a message.
   *
   * Returns true if the signature is valid.
   */
  verify(message: Uint8Array, signature: Uint8Array): boolean;
  /**
   * Create a keypair from a seed (32+ bytes).
   *
   * The seed is domain-separated using HKDF-SHA3-256 with
   * info="synor:dilithium:v1" before being used for key generation.
   * This ensures the same mnemonic produces the same keypair.
   *
   * ## Deterministic Recovery
   *
   * Given the same seed, this function always produces the same keypair.
   * This is essential for wallet recovery from BIP-39 mnemonics.
   *
   * ## Parameters
   *
   * * `seed` - At least 32 bytes, typically from a BIP-39 mnemonic seed.
   *            For best security, use the full 64-byte BIP-39 seed.
   */
  static fromSeed(seed: Uint8Array): DilithiumSigningKey;
}

export class Keypair {
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Create a keypair from a BIP-39 mnemonic phrase.
   */
  static fromMnemonic(phrase: string, passphrase: string): Keypair;
  /**
   * Get the public key as hex string.
   */
  publicKeyHex(): string;
  /**
   * Get the public key as bytes.
   */
  publicKeyBytes(): Uint8Array;
  /**
   * Generate a new random keypair.
   */
  constructor();
  /**
   * Sign a message.
   */
  sign(message: Uint8Array): Uint8Array;
  /**
   * Verify a signature.
   */
  verify(message: Uint8Array, signature: Uint8Array): boolean;
  /**
   * Get the Synor address for this keypair.
   */
  address(network: string): string;
  /**
   * Create a keypair from a 32-byte seed.
   */
  static fromSeed(seed: Uint8Array): Keypair;
}

export class Keys {
  free(): void;
  [Symbol.dispose](): void;
  constructor();
  sign(msg: Uint8Array): Uint8Array;
  readonly pubkey: Uint8Array;
  readonly secret: Uint8Array;
}

export class Mnemonic {
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Get the word count.
   */
  wordCount(): number;
  /**
   * Parse a mnemonic from a phrase.
   */
  static fromPhrase(phrase: string): Mnemonic;
  /**
   * Generate a new random mnemonic with the specified word count.
   */
  constructor(word_count: number);
  /**
   * Get the mnemonic words as an array.
   */
  words(): string[];
  /**
   * Get the mnemonic phrase as a string.
   */
  phrase(): string;
  /**
   * Get the entropy bytes.
   */
  entropy(): Uint8Array;
  /**
   * Derive a 64-byte seed from the mnemonic.
   */
  toSeed(passphrase: string): Uint8Array;
  /**
   * Generate a 24-word mnemonic.
   */
  static generate(word_count: number): Mnemonic;
  /**
   * Validate a mnemonic phrase.
   */
  static validate(phrase: string): boolean;
}

export class Params {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  readonly publicKeyBytes: number;
  readonly secretKeyBytes: number;
  readonly signBytes: number;
  static readonly publicKeyBytes: number;
  static readonly secretKeyBytes: number;
  static readonly signBytes: number;
}

/**
 * Compute BLAKE3 hash.
 */
export function blake3(data: Uint8Array): Uint8Array;

/**
 * Decode a Synor address to get network and public key hash.
 */
export function decodeAddress(address: string): any;

/**
 * Derive key using HKDF-SHA256.
 */
export function deriveKey(input_key: Uint8Array, salt: Uint8Array, info: Uint8Array, output_len: number): Uint8Array;

/**
 * Get constant sizes for Dilithium3.
 */
export function dilithiumSizes(): object;

/**
 * Verify a Dilithium3 signature using only the public key.
 *
 * This is useful when you only have the public key (e.g., verifying
 * a transaction signature without access to the signing key).
 */
export function dilithiumVerify(signature: Uint8Array, message: Uint8Array, public_key: Uint8Array): boolean;

/**
 * Initialize the WASM module.
 */
export function init(): void;

export function keypair(): Keys;

/**
 * Compute SHA3-256 hash.
 */
export function sha3_256(data: Uint8Array): Uint8Array;

/**
 * Validate a Synor address.
 */
export function validateAddress(address: string): boolean;

export function verify(sig: Uint8Array, msg: Uint8Array, public_key: Uint8Array): boolean;

/**
 * Verify a signature with a public key.
 */
export function verifyWithPublicKey(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
