Skip to content

AuthScheme.AuthRpoFalcon512 is undefined, so newWallet() / useCreateWallet() hang with "invalid enum value passed" #223

Description

@Keinberger

Issue Description

The public AuthScheme export from @miden-sdk/miden-sdk is the friendly string const { Falcon: "falcon", ECDSA: "ecdsa" } (api-types.d.ts). But WebClient.newWallet(storageMode, authScheme, seed) forwards its second argument straight to wasm-bindgen, which expects the numeric wasm AuthScheme enum (AuthRpoFalcon512 = 2, AuthEcdsaK256Keccak = 1). So AuthScheme.AuthRpoFalcon512 is undefined, and the natural call client.newWallet(storageMode, AuthScheme.AuthRpoFalcon512, seed) passes undefined to wasm, which throws invalid enum value passed.

The failure mode is worse than a plain throw: the panic happens inside a future_to_promise worker closure, so the newWallet promise never settles. The call hangs forever instead of rejecting, with no way for the caller to catch it.

The React SDK's useCreateWallet() hook is affected the same way. Its DEFAULTS.AUTH_SCHEME is AuthScheme.AuthRpoFalcon512 (@miden-sdk/react dist/index.mjs, which does import { AuthScheme } from "@miden-sdk/miden-sdk" then AUTH_SCHEME: AuthScheme.AuthRpoFalcon512), so it resolves to undefined for the same reason and the default createWallet() hangs.

Reproduction Steps

import { WebClient, AccountStorageMode, AuthScheme } from "@miden-sdk/miden-sdk";

const client = await WebClient.createClient("testnet");
console.log(AuthScheme.AuthRpoFalcon512); // undefined
console.log(Object.keys(AuthScheme));     // ["Falcon", "ECDSA"]

// Hangs; console shows "invalid enum value passed", promise never settles:
await client.newWallet(AccountStorageMode.private(), AuthScheme.AuthRpoFalcon512, undefined);

Via React, the same hang:

const { createWallet } = useCreateWallet();
await createWallet(); // defaults authScheme to AuthScheme.AuthRpoFalcon512 (undefined)

Workaround: pass the numeric discriminant directly, client.newWallet(AccountStorageMode.private(), 2, undefined) (2 = AuthRpoFalcon512 in the wasm-bindgen enum).

Error Output

Error: invalid enum value passed
    at wasm_bindgen::throw_str
    at <miden_client_web ... newWallet ...>
    at wasm_bindgen_futures::future_to_promise::{{closure}}::{{closure}}
(the newWallet promise never resolves or rejects)

Environment Information

  • @miden-sdk/miden-sdk: 0.15.3 (single-threaded st build)
  • @miden-sdk/react: 0.15.3
  • Browser: Chrome

Key Question

Should newWallet (and the underlying wasm binding) accept the friendly AuthScheme string const ("falcon" / "ecdsa") and resolve it internally the way MidenClient.createWallet already does with resolveAuthScheme, or should the numeric enum be exported so AuthScheme.AuthRpoFalcon512 is defined? Whichever it is, an invalid enum value should reject the promise rather than hang the call, and useCreateWallet()'s default should map to a valid scheme so the documented hook works out of the box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions