fix(wallet): decrypt the private balance with the SDK's own eERC key#96
Open
hitakshiA wants to merge 1 commit into
Open
fix(wallet): decrypt the private balance with the SDK's own eERC key#96hitakshiA wants to merge 1 commit into
hitakshiA wants to merge 1 commit into
Conversation
The eERC SDK's register() ignores the decryptionKey passed to the EERC constructor and derives its own from a deterministic wallet signature (generateDecryptionKey), binding the on-chain public key and the ElGamal-encrypted balance to THAT key. Our read path constructed a fresh EERC with account.eercDecryptionKey and never called generateDecryptionKey, so calculateTotalBalance decrypted with the wrong key, failed its eGCT verify, and every shielded balance rendered $0.00 even though the deposit was on-chain (activity showed it correctly). Have createEerc install the SDK's own key up front. The signature is local (self-custody key) and deterministic, so it is stable across sessions and matches whatever key registration used. Verified end-to-end on Fuji: a fresh wallet that deposited 0.04 USDC now decrypts to 40000 (was 0).
📝 WalkthroughWalkthrough
ChangesEERC key initialization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Problem
Every shielded balance rendered $0.00 on the Home screen even though the deposit landed on-chain (activity showed
+$1.00).Root cause
The eERC SDK's
register()ignores thedecryptionKeypassed to theEERCconstructor and derives its own key from a deterministic wallet signature (generateDecryptionKey), binding the on-chain public key + ElGamal-encrypted balance to that key. Our read path built a freshEERCwithaccount.eercDecryptionKeyand never calledgenerateDecryptionKey, socalculateTotalBalancedecrypted with the wrong key, failed its eGCT verify, and returned 0.Fix
createEercnow callsawait eerc.generateDecryptionKey()up front, so reads/transfers/deposits use the same key registration used. The signature is local (self-custody key) and deterministic, so it is stable across sessions and retroactively fixes already-registered wallets.Verification
40000(was0).Summary by CodeRabbit
Greptile Summary
This PR updates the wallet eERC setup to use the SDK-derived key.
generateDecryptionKey()when creating anEERCinstance.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
EERCinstance, derives the SDK decryption key, and returns the initialized instance.generateDecryptionKeyto the hoisted mock used by shield tests.Reviews (1): Last reviewed commit: "fix(wallet): decrypt the private balance..." | Re-trigger Greptile