Skip to content

Conversation

@samkim-crypto
Copy link
Contributor

@samkim-crypto samkim-crypto commented Jan 2, 2026

Problem

The add_with_lo_hi() and subtract_with_lo_hi() functions chain primitive operations that each perform complete deserialize-compute-serialize cycles. Intermediate results are serialized then immediately deserialized by the next operation, creating redundant overhead. Each call performs 5 deserializations and 3 serializations when only 3 and 1 are required respectively—representing significant serialization and deserialization overhead.

These functions are invoked on every confidential balance update: subtract_with_lo_hi debits the sender, add_with_lo_hi credits the receiver's pending balance, and add_with_lo_hi is called again when applying pending balances. A single end-to-end confidential transfer invokes these operations 3-4 times, compounding the overhead across every confidential token movement in the system.

Summary of Changes

Simplified the ciphertext artihmetic to avoid redundant serialization.

@samkim-crypto samkim-crypto marked this pull request as ready for review January 7, 2026 01:52
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great!

@samkim-crypto samkim-crypto merged commit 9f1b2c8 into solana-program:main Jan 7, 2026
38 checks passed
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.

3 participants