fix(js): base confidential-mint supply on the confidential ciphertext - #1402
Open
latent-9 wants to merge 2 commits into
Open
fix(js): base confidential-mint supply on the confidential ciphertext#1402latent-9 wants to merge 2 commits into
latent-9 wants to merge 2 commits into
Conversation
The mint helper committed the new supply as `decryptable_supply + amount` while the equality-proof ciphertext encrypts `confidential_supply + amount`. CiphertextCommitmentEqualityProof requires both values to match, so any confidential mint fails on-chain once the two supplies diverge: after an apply-pending-burn advances the encrypted supply without re-encrypting the decryptable one, or when InitializeMintData sets a nonzero decryptable supply. Derive the new supply from the confidential ciphertext via the supply ElGamal keypair, which also keeps the decryptable supply in sync. Adds a regression test that mints, burns, applies the pending burn, and mints again without a manual decryptable-supply re-sync.
Contributor
Author
|
Update: after reproducing the audit locally, the advisory that actually fails the job is RUSTSEC-2026-0258 (
This is unrelated to the changes in this PR and would fail on Pushed 1feea7b adding both advisories to the ignore list in the Makefile Verified locally that |
RUSTSEC-2026-0258 (h2 unbounded empty DATA frames) is the advisory that fails the Audit job. h2 0.3.x has no fixed release, the fix requires the 0.4 line, so ignore it the same way as the other advisories without an applicable patch. RUSTSEC-2026-0173 (proc-macro-error2 unmaintained) has no replacement, ignore it as well to keep the job green.
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.
Summary
buildConfidentialMintProofPlanderives the new supply from the AESdecryptable_supply, but pairs the resulting commitment with a ciphertextthat encrypts
confidential_supply + amount. TheCiphertextCommitmentEqualityProofonly verifies when the ciphertext and thecommitment encode the same value, so the mint is rejected on-chain whenever
the two supplies differ:
ApplyPendingBurnadvances the ElGamalconfidential_supplybut does not re-encrypt the AESdecryptable_supply.InitializeMintData.decryptable_supplydiverges from the zero confidential supply before the first mint.
The on-chain mint hard-requires the new supply ciphertext to equal
add_with_lo_hi(confidential_supply, amount)and verifies the equality proofagainst that value, so the only consistent plaintext for the commitment is
the confidential supply, not the decryptable one.
Change
Derive
currentSupplyby decryptingconfidentialSupplywith the supplyElGamal keypair. The resulting
newDecryptableSupplyalso re-syncs the AESdecryptable supply in the same instruction, matching the manual
getUpdateConfidentialMintBurnDecryptableSupplyInstructionFromSupplycallthat was previously required after every burn.
Test
Adds a regression test that mints, burns, applies the pending burn (without
any manual decryptable-supply re-sync), and mints again. It verifies the
second mint succeeds and that the decryptable supply tracks the encrypted
supply.