Skip to content

fix(verifier): return structured verification reports instead of lossy booleans in WASM bindings #406

Description

@bordumb

Description

In crates/auths-verifier/src/wasm.rs (lines 154-191), WASM verification helpers such as wasm_verify_artifact_signature return a plain bool (false) for all failure cases:

#[wasm_bindgen(js_name = verifyArtifactSignature)]
pub async fn wasm_verify_artifact_signature(
    file_hash_hex: &str,
    signature_hex: &str,
    public_key_hex: &str,
    curve: Option<String>,
) -> bool {
    if file_hash_hex.len() > MAX_FILE_HASH_HEX_LEN ... {
        return false;
    }
    let Ok(hash_bytes) = hex::decode(file_hash_hex) else { return false; };
    let Ok(sig_bytes) = hex::decode(signature_hex) else { return false; };
    let Ok(pk_bytes) = hex::decode(public_key_hex) else { return false; };
    ...
}

Root Cause

When verification returns false, calling JS code cannot determine whether the failure was caused by invalid hex encoding, incorrect signature byte lengths (sig_bytes.len() != 64), input size exceeding bounds, or an actual cryptographic signature check failure.

Expected Behavior

WASM export functions should return a structured Result JSON object or WasmVerificationResult containing explicit error messages and error codes (e.g. InvalidHex, InvalidSignatureLength, SignatureMismatch) instead of losing error context via raw bool returns.

Location

  • crates/auths-verifier/src/wasm.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions