Skip to content

Fix railgun unshield change note recovery#6397

Open
kjameslubin wants to merge 1 commit intodevelopfrom
fix/railgun-unshield-change-note
Open

Fix railgun unshield change note recovery#6397
kjameslubin wants to merge 1 commit intodevelopfrom
fix/railgun-unshield-change-note

Conversation

@kjameslubin
Copy link
Copy Markdown
Contributor

Summary

  • Fix partial unshields to encrypt change note ciphertext so the wallet scanner can recover the change balance (previously used all-zero dummy ciphertext, effectively burning change)
  • Use original note's random for change note so npk == poseidon(masterPubKey, random) verification passes in the scanner
  • Fix Dockerfile.multi libleveldb symlink for ARM64 builds (was hardcoded to x86_64 path)

Test plan

Tested end-to-end on helium testnet (local node):

  • Shield 50 USDST -> 49.875 shielded (0.25% fee)
  • Unshield 25 USDST -> 24.875 change note recovered by balance scanner
  • Full-amount shield/unshield round-trip (no change) still works
  • Balance scanner correctly decrypts change note from Transact event ciphertext

Made with Cursor

…overy

Partial unshields (spending less than the full note) create a change note
that goes back to the sender. Previously, the change note's ciphertext was
all zeros (dummy), making it impossible for the wallet scanner to decrypt
and recover the change balance -- effectively burning the change.

This fix:
- Replaces dummy ciphertext with real AES-CTR encrypted ciphertext using
  the sender's viewing key (via createCommitmentCiphertext from Transfer.hs)
- Uses the original note's random so npk verification passes in the scanner
  (npk == poseidon(masterPubKey, random))
- Passes ciphertext as parameter to createUnshieldRequest instead of
  hardcoding dummyCommitmentCiphertext

Also fixes Dockerfile.multi libleveldb symlink to work on ARM64 (was
hardcoded to x86_64 path).

Tested on helium testnet: shield 50 -> unshield 25 -> 24.875 change note
recovered successfully by the balance scanner.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants