feat(proofs): add payroll proof verifier adapter interface - #435
Open
Dreal-pyper wants to merge 1 commit into
Open
feat(proofs): add payroll proof verifier adapter interface#435Dreal-pyper wants to merge 1 commit into
Dreal-pyper wants to merge 1 commit into
Conversation
…#357) Introduce a pluggable ProofVerifierAdapter contract so local, testnet, hosted, or future ZK verifier implementations share the same client interface. Verification results use five stable typed states (valid, invalid, expired, unavailable, malformed), a network-free MockProofVerifierAdapter is provided as the default for tests and local development, and adapter errors are normalized into SDK-safe ProofVerificationError objects via ProofVerificationClient / verifyProofWithAdapter. Includes docs and 31 passing tests. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@Dreal-pyper Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Dreal-pyper this PR currently has merge conflicts. Please resolve the conflicts before it can be merged automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a pluggable payroll proof verifier adapter interface to the SDK so local, testnet, hosted, or future ZK verifier implementations can share the same client contract — the SDK no longer hard-codes a single proof verification path.
What changed
New:
packages/core/src/proofs/types.tsProofVerificationStatus— five stable, typed verification states:valid,invalid,expired,unavailable,malformed.ProofVerificationInput— canonical input shape (reuses the SDK'sProofPayloadplus optionalpublicInputs,verificationKeyId,expiresAt,context).ProofVerificationResult— normalized verdict (status,isValid, sanitizedmessage,verifiedAt,details).New:
packages/core/src/proofs/verifierAdapter.tsProofVerifierAdapter— the pluggable interface (asyncverify(input)).MockProofVerifierAdapter— default network-free mock for tests and local development that simulates all five states (structural validation →malformed,expiresAtin the past →expired, configurabledefaultStatusforinvalid/unavailable,failWithto simulate thrown adapter errors).normalizeProofVerificationError— normalizes any adapter error into an SDK-safeZkPayrollError(maps unreachable/timeout-style errors toPROOF_VERIFIER_UNAVAILABLE, preservescauseand context).proofVerificationMessage/isStructurallyValidProofhelpers.packages/core/src/proofs/errors.tsProofVerificationError(extendsZkPayrollError) with stable codes:PROOF_VERIFICATION_FAILED,PROOF_VERIFIER_UNAVAILABLE,PROOF_VERIFICATION_MALFORMED.packages/core/src/client.ts— adapter injectionProofVerificationClient— SDK consumers inject any adapter via the constructor (defaults to the mock), so verification works out of the box.verifyProofWithAdapter— standalone helper for callers that already hold an adapter.ProofVerificationClientto avoid colliding with the existing on-chain contract wrapperProofVerifierClient(./clients), which remains unchanged and importable.packages/core/src/core/error-codes.ts+packages/core/src/errors.ts+packages/core/src/index.tsERROR_CODE_REGISTRY(categoryproof) and exported from the package root.Tests:
packages/core/tests/proof-verifier-adapter.test.ts(31 tests)Error, strings, objects,ZkPayrollErrorpassthrough, unavailable mapping), client injection, and export-surface non-collision with the contractProofVerifierClient.Docs
docs/PROOF_VERIFIER_ADAPTER.md— states, client usage, error handling, and a worked example of plugging in a real (hosted) verifier plus an author checklist.docs/ERROR_CODES.mdto include the three new codes (also picks up two eligibility codes that were already registered but missing from the generated file).Acceptance criteria
new ProofVerificationClient(adapter)/verifyProofWithAdapter(adapter, input).ProofVerificationStatusunion.docs/PROOF_VERIFIER_ADAPTER.md.Verification
npx jest tests/proof-verifier-adapter.test.ts— 31/31 passing.amount-normalization,archived-smoke,draft-builder,proof-request-snapshots,receipt-verification) fail identically ondevdue to pre-existing type errors unrelated to this change.eslintclean on all touched files (one pre-existingno-consolewarning insrc/errors.ts).tsc --noEmitintroduces zero new errors (61 pre-existing errors ondevuntouched).Close #357