-
Notifications
You must be signed in to change notification settings - Fork 6
NonMembership proof #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the prover and verifier implementations to use NonMembership proofs when provided with a null value.
- In relay/prover.go, a new branch handles empty value cases by invoking VerifyNonMembership instead of VerifyMembership.
- In light-clients/lcp/types/client_state.go, the verification logic is modified to only compute and compare the hash when the value is non-empty.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| relay/prover.go | Adds NonMembership proof handling for empty values and updates the proof decoding pipeline. |
| light-clients/lcp/types/client_state.go | Skips computing the hash for empty values during membership verification. |
Comments suppressed due to low confidence (1)
relay/prover.go:345
- [nitpick] The variable name 'cp' is ambiguous. Consider renaming it to 'commitmentProofs' to improve clarity.
var cp lcptypes.CommitmentProofs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the logic for state proof verification to use a NonMembership proof when the provided value is empty.
- In relay/prover.go, a new branch handles NonMembership proofs using elc.MsgVerifyNonMembership when value is null.
- In light-clients/lcp/types/client_state.go, the code now computes the hashed value only when a value is provided during membership verification.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| relay/prover.go | Added a new branch to request a NonMembership proof when the input value is empty. |
| light-clients/lcp/types/client_state.go | Updated the value hashing logic to only execute for non-empty values, aligning with NonMembership proofs. |
| res, err := pr.lcpServiceClient.VerifyNonMembership(ctx.Context(), &m) | ||
| if err != nil { | ||
| return nil, clienttypes.Height{}, fmt.Errorf("failed ELC's VerifyNonMembership: elc_client_id=%v msg=%v %w", pr.config.ElcClientId, m, err) | ||
| } | ||
| cp.Message = res.Message | ||
| cp.Signatures = [][]byte{res.Signature} |
Copilot
AI
May 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Both the NonMembership and Membership branches assign cp.Message and cp.Signatures in an identical manner. Consider refactoring to reduce code duplication by extracting these assignments outside the conditional branches.
| res, err := pr.lcpServiceClient.VerifyNonMembership(ctx.Context(), &m) | |
| if err != nil { | |
| return nil, clienttypes.Height{}, fmt.Errorf("failed ELC's VerifyNonMembership: elc_client_id=%v msg=%v %w", pr.config.ElcClientId, m, err) | |
| } | |
| cp.Message = res.Message | |
| cp.Signatures = [][]byte{res.Signature} | |
| var err error | |
| res, err = pr.lcpServiceClient.VerifyNonMembership(ctx.Context(), &m) | |
| if err != nil { | |
| return nil, clienttypes.Height{}, fmt.Errorf("failed ELC's VerifyNonMembership: elc_client_id=%v msg=%v %w", pr.config.ElcClientId, m, err) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type of VerifyMembership and VerifyMembership is not compatible.
I think generics is needed to commonalize these code, it is a bit over spec at this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the prover and verifier logic to use NonMembership proofs when the provided value is null.
- In relay/prover.go, a branch is added to call VerifyNonMembership and assign the corresponding proof and signature when value is empty.
- In light-clients/lcp/types/client_state.go, the hash computation is conditioned on the value being non-empty to support NonMembership logic.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| relay/prover.go | Added NonMembership branch and adjusted proof encoding for empty values. |
| light-clients/lcp/types/client_state.go | Modified hash computation logic to conditionally handle empty values for non-membership. |
Comments suppressed due to low confidence (2)
relay/prover.go:386
- [nitpick] Consider renaming 'cpEnc' to 'encodedProofs' or another more descriptive name to improve clarity.
cpEnc, err := lcptypes.EthABIEncodeCommitmentProofs(&cp)
light-clients/lcp/types/client_state.go:236
- Ensure that there are unit tests covering both the membership and non-membership verification paths, as the new conditional logic impacts how the hashed value is computed.
hashedValue := crypto.Keccak256Hash(value)
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Change prover and verifier to use NonMembership proof when value is null