Add ZKP and ciphertext malleability tests (#6999)

This commit is contained in:
Shawn Xie
2026-04-28 11:25:40 -04:00
committed by GitHub
parent 5a643b1a7f
commit 9bfd78e2fc
4 changed files with 1632 additions and 382 deletions

View File

@@ -94,6 +94,7 @@ ConfidentialMPTClawback::preclaim(PreclaimContext const& ctx)
return tecNO_PERMISSION; // LCOV_EXCL_LINE
// Sanity check: claw amount can not exceed confidential outstanding amount
// or total outstanding amount (prevents underflow in doApply)
auto const amount = ctx.tx[sfMPTAmount];
if (amount > (*sleIssuance)[~sfConfidentialOutstandingAmount].value_or(0) ||
amount > (*sleIssuance)[sfOutstandingAmount])

View File

@@ -248,6 +248,9 @@ ConfidentialMPTConvert::doApply()
// homomorphically add auditor's encrypted balance
if (auditorEc)
{
if (!sleMptoken->isFieldPresent(sfAuditorEncryptedBalance))
return tecINTERNAL; // LCOV_EXCL_LINE
auto sum = homomorphicAdd(*auditorEc, (*sleMptoken)[sfAuditorEncryptedBalance]);
if (!sum)
return tecINTERNAL; // LCOV_EXCL_LINE
@@ -258,7 +261,8 @@ ConfidentialMPTConvert::doApply()
else if (
!sleMptoken->isFieldPresent(sfIssuerEncryptedBalance) &&
!sleMptoken->isFieldPresent(sfConfidentialBalanceInbox) &&
!sleMptoken->isFieldPresent(sfConfidentialBalanceSpending))
!sleMptoken->isFieldPresent(sfConfidentialBalanceSpending) &&
!sleMptoken->isFieldPresent(sfAuditorEncryptedBalance))
{
// Case 2: First-time convert - initialize all confidential fields
(*sleMptoken)[sfConfidentialBalanceInbox] = holderEc;

File diff suppressed because it is too large Load Diff