fix(js): base confidential-mint supply on the confidential ciphertext - #1402
fix(js): base confidential-mint supply on the confidential ciphertext#1402latent-9 wants to merge 3 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.
|
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.
|
The public helper docs still tell callers to manually re-sync the supply after The obsolete warning and workaround should be removed from the JSDoc. |
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.