refactor: expose credential preflight checks on ProofRequest - #411
Conversation
887653b to
a95f92b
Compare
a95f92b to
f5ae23c
Compare
| /// - [`CredentialConstraintsCheckError::Storage`] if the credential store query fails. | ||
| /// - [`CredentialConstraintsCheckError::ConstraintTooDeep`] if the constraint tree exceeds depth 2. | ||
| /// - [`CredentialConstraintsCheckError::ConstraintTooLarge`] if the constraint tree exceeds the node limit. | ||
| pub fn check_credentials( |
There was a problem hiding this comment.
I think this is implementing duplicate logic from https://github.com/worldcoin/world-id-protocol/blob/ada9887a40255ce7e8576cbca4e0442c049d887d/crates/primitives/src/request/mod.rs#L374. is this performing any additional action from just exposing that method to foreign code?
There was a problem hiding this comment.
I will reuse this method for constraints evaluation, thanks for sharing.
however, check_credentials applies time constraints per item and returns per-item diagnostics for UI before triggering ZK proof generation.
there are two options (or more, idk) here:
— keep in walletkit: time checks stay here, can't reuse protocol's since they're buried in circuit input validation.
— add to protocol primitives: expose time checks as a reusable method, walletkit just maps storage records → protocol types.
f5ae23c to
43314c8
Compare
- move check_credentials_against_proof_request into ProofRequest::check_credentials under requests/credential_check.rs - replace manual constraint depth/node checks with validate_constraints() - drop tests that duplicate world-id-primitives coverage
43314c8 to
6b48ddf
Compare

Expose the existing credential preflight check as
ProofRequest::check_credentials(store, now), rebased onto current main and thecrates/layout. The check reports local credential availability and time constraints per request item, then evaluates the request's constraint expression without generating a proof.Reuse protocol 0.14's
validate_constraints()instead of duplicating tree depth/node limits, map unexpected validation errors without panicking, and build one diagnostic per request item with an iterator. No dependency changes are needed.Keep
check_credentials_against_proof_requestand its original Rust result/error import paths as a forwarding compatibility API: Android and iOS still use it. Current test coverage is preserved rather than dropped during the rebase, with an additional method-versus-legacy equivalence test.Validation: all 18 credential-preflight tests pass, including legacy API equivalence. Strict Clippy (
cargo clippy -p walletkit-core --lib --tests -- -D warnings), formatting, andgit diff --checkpass. CI is running on the rebased branch for generated foreign bindings and the complete workspace.Note
Medium Risk
Touches proof-request credential gating used before proof generation and FFI surfaces, though behavior is intended to stay the same aside from centralized constraint validation.
Overview
Moves credential preflight logic into
requests/credential_checkand exposesProofRequest::check_credentials(store, now)as the primary API (UniFFI-exported). The oldproof_request_credential_constraints_checkmodule is now a thin re-export socheck_credentials_against_proof_requestand existing import paths keep working for mobile bindings.Implementation changes: constraint limits go through
CoreProofRequest::validate_constraints()instead of inline depth/node checks, withCredentialConstraintsCheckError::Unknownfor other validation failures. The legacy free function forwards to the method; tests are relocated and amethod_and_legacy_api_agreetest locks parity.Reviewed by Cursor Bugbot for commit 6b48ddf. Bugbot is set up for automated code reviews on this repo. Configure here.