Skip to content

Add buildShieldRequest shield note serializer - #28

Merged
mattgle merged 1 commit into
devfrom
feat/shield-request-builder
Jul 23, 2026
Merged

mattgle merged 1 commit into
devfrom
feat/shield-request-builder

Conversation

@mattgle

@mattgle mattgle commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds the encrypt/serialize direction for shield notes: buildShieldRequest, a standalone builder that turns a ShieldNote into the { preimage, ciphertext } struct the RailgunSmartWallet contract expects.

The note random is encrypted with AES-256-GCM under the ECDH shared key of the shield private key and the receiver's viewing public key; the receiver's viewing public key is encrypted with AES-256-CTR under the shield private key. Both are packed into the contract's three 32-byte encryptedBundle slots plus shieldKey, so a built request decrypts cleanly back through ShieldNote.fromShieldCommitment.

It is a standalone function rather than a ShieldNote method, keeping the note a pure data model, and the serializer has no node: imports so it stays browser-safe.

Testss:

  • Round-trip: built request through fromShieldCommitment recovers random, value, npk, token
  • bundle[2] CTR-decrypts back to the receiver viewing public key
  • Non-recipient decryption returns null without throwing
  • Byte-identical golden fixture with a pinned IV

@mattgle mattgle self-assigned this Jul 22, 2026
@mattgle
mattgle requested a review from bhflm July 22, 2026 19:33
@mattgle
mattgle marked this pull request as ready for review July 22, 2026 19:35

@bhflm bhflm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mattgle
mattgle merged commit 39f0870 into dev Jul 23, 2026
1 check passed
@mattgle
mattgle deleted the feat/shield-request-builder branch July 23, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants