/** Wallet seed width, in bytes. */ export declare const SEED_LEN = 32; /** An EVM reserve address is 20 bytes; it enters the coin derivation preimage raw (§6.12: fixed-width fields take no length prefix). */ export declare const RESERVE_ADDR_LEN = 20; /** Ed25519 and X25519 keys are 32 bytes throughout. */ export declare const KEY_LEN = 32; /** * Withdraw-path coin secret: `HKDF(seed ‖ reserveAddr ‖ be64(counter), * "px402/v1/coin")` (spec §6.1). * * The result is an Ed25519 secret *seed*, i.e. the 32 bytes RFC 8032 hashes to * obtain the signing scalar and the nonce prefix -- not a scalar itself. Every * 32-byte string is a valid seed, so this cannot fail. */ export declare function deriveCoinSecret(seed: Uint8Array, reserveAddr: Uint8Array, counter: bigint | number): Uint8Array; /** * Withdraw-path blinding ikm: `HKDF(seed ‖ reserveAddr ‖ be64(counter), * "px402/v1/withdraw-blind")` (spec §6.1), the input `selectSeeded` turns * into `r(i)`. * * **Caller invariant: `counter` must never repeat (spec §6.13).** * `selectSeeded` does not bind `N` into the KDF, so `r` is a function of this * ikm *alone*: two coin indices that reach the same ikm reuse `r` under the * same denomination key, which is a silent unlinkability failure that nothing * downstream can detect. `(seed, reserveAddr)` are constant across a * reserve's whole withdraw history, so the counter is the only thing * separating one withdraw blinding from another. */ export declare function deriveWithdrawBlindIkm(seed: Uint8Array, reserveAddr: Uint8Array, counter: bigint | number): Uint8Array; /** * Reserve secp256k1 secret: `HKDF(seed ‖ be32(index), "px402/v1/reserve")` * (spec §6.10). * * Returned as raw bytes, exactly as the Rust side does: this is the key * material the on-chain authorization signatures (§5.2, `ecrecover`) are made * with, and the secp256k1 scalar validity check belongs to whichever signer * consumes it. A uniformly derived 32-byte string exceeds the secp256k1 group * order with probability below 2^-128. */ export declare function deriveReserveKey(seed: Uint8Array, index: number): Uint8Array; /** The compressed Ed25519 public key of a coin -- the value revealed at spend time. */ export declare function coinPublic(secret: Uint8Array): Uint8Array; /** * The admission check for a coin public key: canonical compressed encoding, * on the curve, in the prime-order subgroup. Mirrors * `keys.rs::CoinPublic::validate`; throws on the first condition that fails. * * What each condition buys, and why "it decodes" is not enough: * * - **Canonical encoding.** Ed25519 decompression masks the sign bit and * reduces `y` modulo `p`, so several distinct 32-byte strings decode to one * point -- `[0xff; 32]` among them. Coin identity here is always the * *bytes*: `σ` is computed over `C_p`, and the commitment hashes bind those * bytes. Any component keying a spent-coin set on the decoded point where * another keyed it on the bytes would disagree about which coin is which. * Re-encoding and comparing makes bytes -> point injective on everything * this admits. * - **Not small order.** With `C_p` set to the compressed identity, the pair * `(R = [s]B, S = s)` satisfies the *cofactorless* Ed25519 verification * equation for **any** message, holding no secret at all. Such a key must * never be blind-signed into a coin in the first place. * - **Torsion-free.** Every honest coin key is `[a]B` for a clamped `a`, so * this rejects nothing a conforming wallet can produce. It rules out the * mixed-order variants `A + t` of an honest key, which exist only to create * a second byte string that behaves like a coin. */ export declare function validateCoinPublic(coinPub: Uint8Array): void; /** * Clamped SHA-512 prefix of the Ed25519 secret (RFC 8032 §5.1.5, * `crypto_sign_ed25519_sk_to_curve25519`). * * **NOT the raw seed.** Using the seed directly as an X25519 scalar is the * conformance error §3.1 names: it yields a different shared secret, which in * refresh means an honest wallet cannot recover its own change. The identity * `ECDH(toX25519Secret(c_s), T) = ECDH(t, toX25519Public(C_p))` holds only * under this conversion, because the Ed25519 public key is `[a]B` for exactly * this clamped `a`. */ export declare function toX25519Secret(ed25519Secret: Uint8Array): Uint8Array; /** * Edwards -> Montgomery birational map `u = (1 + y) / (1 - y)` * (`crypto_sign_ed25519_pk_to_curve25519`). * * [`validateCoinPublic`] is applied first, which is what makes this function * injective on the bytes it accepts: decoding alone is not, so without it * `[0xff; 32]` and the canonical encoding of the same point would map to one * transfer secret, and two components disagreeing about whether a melt record * is keyed by the bytes or by the decoded point would disagree about coin * identity. */ export declare function toX25519Public(ed25519Public: Uint8Array): Uint8Array; /** * X25519 Diffie-Hellman, RFC 7748. * * Stricter than the Rust side's `x25519_dalek::StaticSecret::diffie_hellman` * in one respect: `@noble/curves` rejects a low-order peer public key instead * of returning the all-zero shared secret. Rust reaches the same outcome * through `refresh.rs`'s explicit all-zero-DH guard, so both implementations * refuse the same inputs -- this one refuses them here, with a throw, rather * than one call later. */ export declare function ecdh(secret: Uint8Array, publicKey: Uint8Array): Uint8Array;