ZK-073: Redesign relayer binding and zero-relayer semantics across SDK and contract code#446
Open
canvascn00-crypto wants to merge 1 commit intoANAVHEOBA:mainfrom
Open
Conversation
Wave Issue Key: ZK-073 Unified relayer binding contract across SDK, circuit, and contract code: ## Changes ### Circuit (circuits/) - **relayer.nr**: Replaced incomplete validation with canonical re-export from fee.nr. Added validate_relayer_not_malformed() defense-in-depth. - **mod.nr**: Updated to delegate validate_relayer to fee.nr canonical impl. - **spend.nr**: Added ZK-073 regression tests for all three modes: - Mode 1: No relayer (relayer=0, fee=0) - Mode 2: Relayer + fee (relayer≠0, fee>0) - Mode 3: Malformed (rejected — phantom relayer, orphan fee) ### Contract (contracts/) - **address_decoder.rs**: decode_optional_relayer now returns Result with MalformedRelayer error for non-canonical encodings. Added validate_relayer_fee_binding() for contract-level enforcement. - **withdraw.rs**: Added relayer/fee binding validation call after address decoding. Added regression tests. - **errors.rs**: Added MalformedRelayer error variant (code 48). - **relayer_binding_zk073.rs**: New regression test file. ### SDK (sdk/) - **relayer_binding.ts**: New module defining the canonical relayer binding contract with resolveRelayerBinding() and classifyRelayerBinding(). Self-tests for all modes. - **relayer_binding_zk073.test.ts**: End-to-end regression tests verifying clean distinction between absent and malformed relayer cases. ## Acceptance Criteria Met ✅ Relayer handling no longer depends on ad hoc zero-address assumptions ✅ Contract accepts only relayer encodings the SDK can produce canonically ✅ Regression tests distinguish absent relayer from malformed relayer cleanly
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.
Wave Issue Key: ZK-073
Unified relayer binding contract across SDK, circuit, and contract code.
See issue: #349