diff --git a/include/xrpl/protocol/ConfidentialTransfer.h b/include/xrpl/protocol/ConfidentialTransfer.h index 451b56f547..ec710c2bb6 100644 --- a/include/xrpl/protocol/ConfidentialTransfer.h +++ b/include/xrpl/protocol/ConfidentialTransfer.h @@ -289,7 +289,7 @@ verifyRevealedAmount( * @param hasAuditor Whether the issuance has an auditor configured. * @return The number of recipients (3 or 4). */ -constexpr std::size_t +constexpr uint8_t getConfidentialRecipientCount(bool hasAuditor) { return hasAuditor ? 4 : 3; diff --git a/src/libxrpl/protocol/ConfidentialTransfer.cpp b/src/libxrpl/protocol/ConfidentialTransfer.cpp index 10906394f4..4acb9d5fe2 100644 --- a/src/libxrpl/protocol/ConfidentialTransfer.cpp +++ b/src/libxrpl/protocol/ConfidentialTransfer.cpp @@ -101,11 +101,7 @@ makeEcPair(Slice const& buffer) return std::nullopt; // LCOV_EXCL_LINE auto parsePubKey = [](Slice const& slice, secp256k1_pubkey& out) { - return secp256k1_ec_pubkey_parse( - secp256k1Context(), - &out, - reinterpret_cast(slice.data()), - slice.length()); + return secp256k1_ec_pubkey_parse(secp256k1Context(), &out, slice.data(), slice.length()); }; Slice const s1{buffer.data(), ecGamalEncryptedLength}; @@ -123,13 +119,13 @@ serializeEcPair(EcPair const& pair) { auto serializePubKey = [](secp256k1_pubkey const& pub, unsigned char* out) { size_t outLen = ecGamalEncryptedLength; // 33 bytes - int const ret = secp256k1_ec_pubkey_serialize( + auto const ret = secp256k1_ec_pubkey_serialize( secp256k1Context(), out, &outLen, &pub, SECP256K1_EC_COMPRESSED); return ret == 1 && outLen == ecGamalEncryptedLength; }; Buffer buffer(ecGamalEncryptedTotalLength); - unsigned char* ptr = buffer.data(); + auto const ptr = buffer.data(); bool const res1 = serializePubKey(pair.c1, ptr); bool const res2 = serializePubKey(pair.c2, ptr + ecGamalEncryptedLength); @@ -195,7 +191,7 @@ homomorphicSubtract(Slice const& a, Slice const& b) return std::nullopt; EcPair diff{}; - if (auto res = secp256k1_elgamal_subtract( + if (auto const res = secp256k1_elgamal_subtract( secp256k1Context(), &diff.c1, &diff.c2, &pairA->c1, &pairA->c2, &pairB->c1, &pairB->c2); res != 1) { @@ -268,7 +264,9 @@ verifyRevealedAmount( holder.encryptedAmount.size() != ecGamalEncryptedTotalLength || issuer.publicKey.size() != ecPubKeyLength || issuer.encryptedAmount.size() != ecGamalEncryptedTotalLength) + { return tecINTERNAL; // LCOV_EXCL_LINE + } auto toParticipant = [](ConfidentialRecipient const& r) { mpt_confidential_participant p; @@ -285,14 +283,18 @@ verifyRevealedAmount( { if (auditor->publicKey.size() != ecPubKeyLength || auditor->encryptedAmount.size() != ecGamalEncryptedTotalLength) + { return tecINTERNAL; // LCOV_EXCL_LINE + } auditorP = toParticipant(*auditor); auditorPtr = &auditorP; } if (mpt_verify_revealed_amount(amount, blindingFactor.data(), &holderP, &issuerP, auditorPtr) != 0) + { return tecBAD_PROOF; + } return tesSUCCESS; } @@ -305,11 +307,15 @@ checkEncryptedAmountFormat(STObject const& object) // are present. if (!object.isFieldPresent(sfHolderEncryptedAmount) || !object.isFieldPresent(sfIssuerEncryptedAmount)) + { return temMALFORMED; // LCOV_EXCL_LINE + } if (object[sfHolderEncryptedAmount].length() != ecGamalEncryptedTotalLength || object[sfIssuerEncryptedAmount].length() != ecGamalEncryptedTotalLength) + { return temBAD_CIPHERTEXT; + } bool const hasAuditor = object.isFieldPresent(sfAuditorEncryptedAmount); if (hasAuditor && object[sfAuditorEncryptedAmount].length() != ecGamalEncryptedTotalLength) @@ -317,7 +323,9 @@ checkEncryptedAmountFormat(STObject const& object) if (!isValidCiphertext(object[sfHolderEncryptedAmount]) || !isValidCiphertext(object[sfIssuerEncryptedAmount])) + { return temBAD_CIPHERTEXT; + } if (hasAuditor && !isValidCiphertext(object[sfAuditorEncryptedAmount])) return temBAD_CIPHERTEXT; @@ -347,11 +355,15 @@ verifyClawbackProof( { if (ciphertext.size() != ecGamalEncryptedTotalLength || pubKeySlice.size() != ecPubKeyLength || proof.size() != ecClawbackProofLength) + { return tecINTERNAL; // LCOV_EXCL_LINE + } if (mpt_verify_clawback_proof( proof.data(), amount, pubKeySlice.data(), ciphertext.data(), contextHash.data()) != 0) + { return tecBAD_PROOF; + } return tesSUCCESS; } @@ -378,7 +390,9 @@ verifySendProof( spendingBalance.size() != ecGamalEncryptedTotalLength || amountCommitment.size() != ecPedersenCommitmentLength || balanceCommitment.size() != ecPedersenCommitmentLength) + { return tecINTERNAL; // LCOV_EXCL_LINE + } auto makeParticipant = [](ConfidentialRecipient const& r) { mpt_confidential_participant p; @@ -395,19 +409,23 @@ verifySendProof( { if (auditor->publicKey.size() != ecPubKeyLength || auditor->encryptedAmount.size() != ecGamalEncryptedTotalLength) - return tecINTERNAL; + { + return tecINTERNAL; // LCOV_EXCL_LINE + } participants[3] = makeParticipant(*auditor); } if (mpt_verify_send_proof( proof.data(), participants.data(), - static_cast(recipientCount), + recipientCount, spendingBalance.data(), amountCommitment.data(), balanceCommitment.data(), contextHash.data()) != 0) + { return tecBAD_PROOF; + } return tesSUCCESS; } @@ -424,7 +442,9 @@ verifyConvertBackProof( if (proof.size() != ecConvertBackProofLength || pubKeySlice.size() != ecPubKeyLength || spendingBalance.size() != ecGamalEncryptedTotalLength || balanceCommitment.size() != ecPedersenCommitmentLength) + { return tecINTERNAL; // LCOV_EXCL_LINE + } if (mpt_verify_convert_back_proof( proof.data(), @@ -433,7 +453,9 @@ verifyConvertBackProof( balanceCommitment.data(), amount, contextHash.data()) != 0) + { return tecBAD_PROOF; + } return tesSUCCESS; } diff --git a/src/libxrpl/tx/transactors/token/ConfidentialMPTClawback.cpp b/src/libxrpl/tx/transactors/token/ConfidentialMPTClawback.cpp index 795d205885..80347924c4 100644 --- a/src/libxrpl/tx/transactors/token/ConfidentialMPTClawback.cpp +++ b/src/libxrpl/tx/transactors/token/ConfidentialMPTClawback.cpp @@ -117,8 +117,8 @@ ConfidentialMPTClawback::doApply() auto const clawAmount = ctx_.tx[sfMPTAmount]; - Slice const holderPubKey = (*sleHolderMPToken)[sfHolderEncryptionKey]; - Slice const issuerPubKey = (*sleIssuance)[sfIssuerEncryptionKey]; + auto const holderPubKey = (*sleHolderMPToken)[sfHolderEncryptionKey]; + auto const issuerPubKey = (*sleIssuance)[sfIssuerEncryptionKey]; // After clawback, the balance should be encrypted zero. auto const encZeroForHolder = encryptCanonicalZeroAmount(holderPubKey, holder, mptIssuanceID); @@ -142,7 +142,7 @@ ConfidentialMPTClawback::doApply() if (!sleIssuance->isFieldPresent(sfAuditorEncryptionKey)) return tecINTERNAL; // LCOV_EXCL_LINE - Slice const auditorPubKey = (*sleIssuance)[sfAuditorEncryptionKey]; + auto const auditorPubKey = (*sleIssuance)[sfAuditorEncryptionKey]; auto encZeroForAuditor = encryptCanonicalZeroAmount(auditorPubKey, holder, mptIssuanceID); diff --git a/src/libxrpl/tx/transactors/token/ConfidentialMPTConvert.cpp b/src/libxrpl/tx/transactors/token/ConfidentialMPTConvert.cpp index eca20414de..2227354f4c 100644 --- a/src/libxrpl/tx/transactors/token/ConfidentialMPTConvert.cpp +++ b/src/libxrpl/tx/transactors/token/ConfidentialMPTConvert.cpp @@ -67,7 +67,9 @@ ConfidentialMPTConvert::preclaim(PreclaimContext const& ctx) if (!sleIssuance->isFlag(lsfMPTCanConfidentialAmount) || !sleIssuance->isFieldPresent(sfIssuerEncryptionKey)) + { return tecNO_PERMISSION; + } // already checked in preflight, but should also check that issuer on the // issuance isn't the account either @@ -102,7 +104,7 @@ ConfidentialMPTConvert::preclaim(PreclaimContext const& ctx) if (auto const ter = requireAuth(ctx.view, mptIssue, account); !isTesSuccess(ter)) return ter; - STAmount const mptAmount = + auto const mptAmount = STAmount(MPTAmount{static_cast(amount)}, mptIssue); if (accountHolds( ctx.view, @@ -203,9 +205,8 @@ ConfidentialMPTConvert::doApply() (*sleMptoken)[sfMPTAmount] = amt - amtToConvert; (*sleIssuance)[sfConfidentialOutstandingAmount] = currentCOA + amtToConvert; - Slice const holderEc = ctx_.tx[sfHolderEncryptedAmount]; - Slice const issuerEc = ctx_.tx[sfIssuerEncryptedAmount]; - + auto const holderEc = ctx_.tx[sfHolderEncryptedAmount]; + auto const issuerEc = ctx_.tx[sfIssuerEncryptedAmount]; auto const auditorEc = ctx_.tx[~sfAuditorEncryptedAmount]; // Two cases for Convert: diff --git a/src/libxrpl/tx/transactors/token/ConfidentialMPTConvertBack.cpp b/src/libxrpl/tx/transactors/token/ConfidentialMPTConvertBack.cpp index 5cccead427..1071995264 100644 --- a/src/libxrpl/tx/transactors/token/ConfidentialMPTConvertBack.cpp +++ b/src/libxrpl/tx/transactors/token/ConfidentialMPTConvertBack.cpp @@ -164,9 +164,7 @@ ConfidentialMPTConvertBack::preclaim(PreclaimContext const& ctx) // holder is trying to convert back, we know for sure this txn should // fail if ((*sleIssuance)[~sfConfidentialOutstandingAmount].value_or(0) < amount) - { return tecINSUFFICIENT_FUNDS; - } // Check lock MPTIssue const mptIssue(mptIssuanceID); diff --git a/src/libxrpl/tx/transactors/token/ConfidentialMPTMergeInbox.cpp b/src/libxrpl/tx/transactors/token/ConfidentialMPTMergeInbox.cpp index a133bb934a..1cebca7010 100644 --- a/src/libxrpl/tx/transactors/token/ConfidentialMPTMergeInbox.cpp +++ b/src/libxrpl/tx/transactors/token/ConfidentialMPTMergeInbox.cpp @@ -46,7 +46,9 @@ ConfidentialMPTMergeInbox::preclaim(PreclaimContext const& ctx) if (!sleMptoken->isFieldPresent(sfConfidentialBalanceInbox) || !sleMptoken->isFieldPresent(sfConfidentialBalanceSpending) || !sleMptoken->isFieldPresent(sfHolderEncryptionKey)) + { return tecNO_PERMISSION; + } // Check lock auto const account = ctx.tx[sfAccount]; diff --git a/src/libxrpl/tx/transactors/token/ConfidentialMPTSend.cpp b/src/libxrpl/tx/transactors/token/ConfidentialMPTSend.cpp index ae03db2ccf..08a75076ab 100644 --- a/src/libxrpl/tx/transactors/token/ConfidentialMPTSend.cpp +++ b/src/libxrpl/tx/transactors/token/ConfidentialMPTSend.cpp @@ -33,7 +33,9 @@ ConfidentialMPTSend::preflight(PreflightContext const& ctx) if (ctx.tx[sfSenderEncryptedAmount].length() != ecGamalEncryptedTotalLength || ctx.tx[sfDestinationEncryptedAmount].length() != ecGamalEncryptedTotalLength || ctx.tx[sfIssuerEncryptedAmount].length() != ecGamalEncryptedTotalLength) + { return temBAD_CIPHERTEXT; + } bool const hasAuditor = ctx.tx.isFieldPresent(sfAuditorEncryptedAmount); if (hasAuditor && ctx.tx[sfAuditorEncryptedAmount].length() != ecGamalEncryptedTotalLength) @@ -46,14 +48,18 @@ ConfidentialMPTSend::preflight(PreflightContext const& ctx) // Check the Pedersen commitments are valid if (!isValidCompressedECPoint(ctx.tx[sfBalanceCommitment]) || !isValidCompressedECPoint(ctx.tx[sfAmountCommitment])) + { return temMALFORMED; + } // Check the encrypted amount formats, this is more expensive so put it at // the end if (!isValidCiphertext(ctx.tx[sfSenderEncryptedAmount]) || !isValidCiphertext(ctx.tx[sfDestinationEncryptedAmount]) || !isValidCiphertext(ctx.tx[sfIssuerEncryptedAmount])) + { return temBAD_CIPHERTEXT; + } if (hasAuditor && !isValidCiphertext(ctx.tx[sfAuditorEncryptedAmount])) return temBAD_CIPHERTEXT; @@ -154,7 +160,9 @@ ConfidentialMPTSend::preclaim(PreclaimContext const& ctx) if (!sleSenderMPToken->isFieldPresent(sfHolderEncryptionKey) || !sleSenderMPToken->isFieldPresent(sfConfidentialBalanceSpending) || !sleSenderMPToken->isFieldPresent(sfIssuerEncryptedBalance)) + { return tecNO_PERMISSION; + } // Check destination's MPToken existence auto const sleDestinationMPToken = ctx.view.read(keylet::mptoken(mptIssuanceID, destination)); @@ -165,14 +173,18 @@ ConfidentialMPTSend::preclaim(PreclaimContext const& ctx) if (!sleDestinationMPToken->isFieldPresent(sfHolderEncryptionKey) || !sleDestinationMPToken->isFieldPresent(sfConfidentialBalanceInbox) || !sleDestinationMPToken->isFieldPresent(sfIssuerEncryptedBalance)) + { return tecNO_PERMISSION; + } // Sanity check: Both MPTokens' auditor fields must be present if auditing // is enabled if (requiresAuditor && (!sleSenderMPToken->isFieldPresent(sfAuditorEncryptedBalance) || !sleDestinationMPToken->isFieldPresent(sfAuditorEncryptedBalance))) + { return tefINTERNAL; // LCOV_EXCL_LINE + } // Check lock MPTIssue const mptIssue(mptIssuanceID); @@ -205,7 +217,7 @@ ConfidentialMPTSend::doApply() auto sleSenderMPToken = view().peek(keylet::mptoken(mptIssuanceID, account_)); auto sleDestinationMPToken = view().peek(keylet::mptoken(mptIssuanceID, destination)); - auto sleDestAcct = view().peek(keylet::account(destination)); + auto const sleDestAcct = view().peek(keylet::account(destination)); if (!sleSenderMPToken || !sleDestinationMPToken || !sleDestAcct) return tecINTERNAL; // LCOV_EXCL_LINE @@ -215,15 +227,15 @@ ConfidentialMPTSend::doApply() !isTesSuccess(err)) return err; - Slice const senderEc = ctx_.tx[sfSenderEncryptedAmount]; - Slice const destEc = ctx_.tx[sfDestinationEncryptedAmount]; - Slice const issuerEc = ctx_.tx[sfIssuerEncryptedAmount]; + auto const senderEc = ctx_.tx[sfSenderEncryptedAmount]; + auto const destEc = ctx_.tx[sfDestinationEncryptedAmount]; + auto const issuerEc = ctx_.tx[sfIssuerEncryptedAmount]; auto const auditorEc = ctx_.tx[~sfAuditorEncryptedAmount]; // Subtract from sender's spending balance { - Slice const curSpending = (*sleSenderMPToken)[sfConfidentialBalanceSpending]; + auto const curSpending = (*sleSenderMPToken)[sfConfidentialBalanceSpending]; auto newSpending = homomorphicSubtract(curSpending, senderEc); if (!newSpending) return tecINTERNAL; // LCOV_EXCL_LINE @@ -233,7 +245,7 @@ ConfidentialMPTSend::doApply() // Subtract from issuer's balance { - Slice const curIssuerEnc = (*sleSenderMPToken)[sfIssuerEncryptedBalance]; + auto const curIssuerEnc = (*sleSenderMPToken)[sfIssuerEncryptedBalance]; auto newIssuerEnc = homomorphicSubtract(curIssuerEnc, issuerEc); if (!newIssuerEnc) return tecINTERNAL; // LCOV_EXCL_LINE @@ -244,7 +256,7 @@ ConfidentialMPTSend::doApply() // Subtract from auditor's balance if present if (auditorEc) { - Slice const curAuditorEnc = (*sleSenderMPToken)[sfAuditorEncryptedBalance]; + auto const curAuditorEnc = (*sleSenderMPToken)[sfAuditorEncryptedBalance]; auto newAuditorEnc = homomorphicSubtract(curAuditorEnc, *auditorEc); if (!newAuditorEnc) return tecINTERNAL; // LCOV_EXCL_LINE @@ -254,7 +266,7 @@ ConfidentialMPTSend::doApply() // Add to destination's inbox balance { - Slice const curInbox = (*sleDestinationMPToken)[sfConfidentialBalanceInbox]; + auto const curInbox = (*sleDestinationMPToken)[sfConfidentialBalanceInbox]; auto newInbox = homomorphicAdd(curInbox, destEc); if (!newInbox) return tecINTERNAL; // LCOV_EXCL_LINE @@ -264,7 +276,7 @@ ConfidentialMPTSend::doApply() // Add to issuer's balance { - Slice const curIssuerEnc = (*sleDestinationMPToken)[sfIssuerEncryptedBalance]; + auto const curIssuerEnc = (*sleDestinationMPToken)[sfIssuerEncryptedBalance]; auto newIssuerEnc = homomorphicAdd(curIssuerEnc, issuerEc); if (!newIssuerEnc) return tecINTERNAL; // LCOV_EXCL_LINE @@ -275,7 +287,7 @@ ConfidentialMPTSend::doApply() // Add to auditor's balance if present if (auditorEc) { - Slice const curAuditorEnc = (*sleDestinationMPToken)[sfAuditorEncryptedBalance]; + auto const curAuditorEnc = (*sleDestinationMPToken)[sfAuditorEncryptedBalance]; auto newAuditorEnc = homomorphicAdd(curAuditorEnc, *auditorEc); if (!newAuditorEnc) return tecINTERNAL; // LCOV_EXCL_LINE diff --git a/src/test/app/ConfidentialTransfer_test.cpp b/src/test/app/ConfidentialTransfer_test.cpp index 597e1e613f..e4d4630c39 100644 --- a/src/test/app/ConfidentialTransfer_test.cpp +++ b/src/test/app/ConfidentialTransfer_test.cpp @@ -3247,7 +3247,7 @@ class ConfidentialTransfer_test : public beast::unit_test::suite // Get the share MPTID from vault auto const vaultSle = env.le(vaultKeylet); BEAST_EXPECT(vaultSle != nullptr); - MPTID share = vaultSle->at(sfShareMPTID); + auto const share = vaultSle->at(sfShareMPTID); // Depositor deposits into vault tx = vault.deposit( @@ -3272,7 +3272,7 @@ class ConfidentialTransfer_test : public beast::unit_test::suite view.rawReplace(issuance); auto const k = keylet::mptoken(share, depositor.id()); - auto sle = std::const_pointer_cast(view.read(k)); + auto const sle = std::const_pointer_cast(view.read(k)); if (!sle) return false; // Inject dummy confidential balance fields @@ -5368,11 +5368,13 @@ class ConfidentialTransfer_test : public beast::unit_test::suite .err = expectedResult, }); else + { mptAlice.convert({ .account = bob, .amt = amt, .err = expectedResult, }); + } if (expectedResult == tesSUCCESS) { diff --git a/src/test/jtx/impl/mpt.cpp b/src/test/jtx/impl/mpt.cpp index a70829b6de..6bd2421fdd 100644 --- a/src/test/jtx/impl/mpt.cpp +++ b/src/test/jtx/impl/mpt.cpp @@ -577,6 +577,7 @@ MPTTester::checkDomainID(std::optional expected) const }); } +// todo: remove this function, which is only for debugging [[nodiscard]] bool MPTTester::printMPT(Account const& holder_) const { @@ -833,14 +834,11 @@ MPTTester::getConfidentialSendProof( std::uint64_t const amount, std::vector const& recipients, Slice const& blindingFactor, - std::size_t const nRecipients, uint256 const& contextHash, PedersenProofParams const& amountParams, PedersenProofParams const& balanceParams) const { auto const pedersenBalanceParams = makePedersenParams(balanceParams); - if (recipients.size() != nRecipients) - return std::nullopt; if (blindingFactor.size() != ecBlindingFactorLength) return std::nullopt; @@ -857,13 +855,15 @@ MPTTester::getConfidentialSendProof( return std::nullopt; // Build mpt_confidential_participant array - std::vector participants(nRecipients); - for (size_t i = 0; i < nRecipients; ++i) + std::vector participants(recipients.size()); + for (size_t i = 0; i < recipients.size(); ++i) { auto const& r = recipients[i]; if (r.encryptedAmount.size() != ecGamalEncryptedTotalLength || r.publicKey.size() != ecPubKeyLength) + { return std::nullopt; + } std::memcpy(participants[i].pubkey, r.publicKey.data(), kMPT_PUBKEY_SIZE); std::memcpy(participants[i].ciphertext, r.encryptedAmount.data(), kMPT_ELGAMAL_TOTAL_SIZE); } @@ -876,7 +876,7 @@ MPTTester::getConfidentialSendProof( senderPubKey->data(), amount, participants.data(), - nRecipients, + recipients.size(), blindingFactor.data(), contextHash.data(), amountParams.pedersenCommitment.data(), @@ -1353,7 +1353,6 @@ MPTTester::send(MPTConfidentialSend const& arg) auto const ctxHash = getSendContextHash(arg.account->id(), *id_, seq, arg.dest->id(), version); - auto const nRecipients = getConfidentialRecipientCount(auditorAmt.has_value()); std::vector recipients; auto const senderPubKey = getPubKey(*arg.account); @@ -1361,8 +1360,7 @@ MPTTester::send(MPTConfidentialSend const& arg) auto const issuerPubKey = getPubKey(issuer_); // If a key is missing, we skip adding the recipient. This intentionally - // causes proof generation to fail (due to recipient count mismatch), - // triggering the dummy proof fallback. + // causes proof generation to fail, triggering the dummy proof fallback. if (senderPubKey) recipients.push_back({Slice(*senderPubKey), senderAmt}); if (destPubKey) @@ -1397,7 +1395,6 @@ MPTTester::send(MPTConfidentialSend const& arg) *arg.amt, recipients, blindingFactor, - nRecipients, ctxHash, {amountCommitment, *arg.amt, senderAmt, blindingFactor}, {balanceCommitment, @@ -1611,7 +1608,6 @@ MPTTester::sendJV( auto const ctxHash = getSendContextHash(arg.account->id(), *id_, seq, arg.dest->id(), version); - auto const nRecipients = getConfidentialRecipientCount(auditorAmt.has_value()); std::vector recipients; auto const senderPubKey = getPubKey(*arg.account); @@ -1645,7 +1641,6 @@ MPTTester::sendJV( *arg.amt, recipients, blindingFactor, - nRecipients, ctxHash, {amountCommitment, *arg.amt, senderAmt, blindingFactor}, {balanceCommitment, @@ -1808,7 +1803,9 @@ MPTTester::generateKeyPair(Account const& account) if (secp256k1_ec_pubkey_serialize( secp256k1Context(), compressedPubKey, &outLen, &pubKey, SECP256K1_EC_COMPRESSED) != 1 || outLen != ecPubKeyLength) + { Throw("failed to serialize public key"); + } pubKeys.insert({account.id(), Buffer{compressedPubKey, ecPubKeyLength}}); privKeys.insert({account.id(), Buffer{privKey, ecPrivKeyLength}}); @@ -1817,11 +1814,8 @@ MPTTester::generateKeyPair(Account const& account) std::optional MPTTester::getPubKey(Account const& account) const { - auto it = pubKeys.find(account.id()); - if (it != pubKeys.end()) - { + if (auto const it = pubKeys.find(account.id()); it != pubKeys.end()) return it->second; - } return std::nullopt; } @@ -1829,11 +1823,8 @@ MPTTester::getPubKey(Account const& account) const std::optional MPTTester::getPrivKey(Account const& account) const { - auto it = privKeys.find(account.id()); - if (it != privKeys.end()) - { + if (auto const it = privKeys.find(account.id()); it != privKeys.end()) return it->second; - } return std::nullopt; } @@ -1879,9 +1870,8 @@ MPTTester::decryptAmount(Account const& account, Buffer const& amt) const std::optional MPTTester::getDecryptedBalance(Account const& account, EncryptedBalanceType balanceType) const - { - auto encryptedAmt = getEncryptedBalance(account, balanceType); + auto const encryptedAmt = getEncryptedBalance(account, balanceType); // Return zero to test cases like Feature Disabled, where the ledger object // does not exist. @@ -2058,8 +2048,7 @@ MPTTester::convertBack(MPTConvertBack const& arg) // if the caller generated ciphertexts themselves, they should also // generate the proof themselves from the blinding factor auto const seq = arg.ticketSeq.value_or(env_.seq(*arg.account)); - uint256 const contextHash = - getConvertBackContextHash(arg.account->id(), *id_, seq, version); + auto const contextHash = getConvertBackContextHash(arg.account->id(), *id_, seq, version); auto const prevEncryptedSpendingBalance = getEncryptedBalance(*arg.account, HOLDER_ENCRYPTED_SPENDING); @@ -2194,8 +2183,7 @@ MPTTester::convertBackJV(MPTConvertBack const& arg, std::uint32_t seq) { auto const version = getMPTokenVersion(*arg.account); auto const prevEncSpending = getEncryptedBalance(*arg.account, HOLDER_ENCRYPTED_SPENDING); - uint256 const contextHash = - getConvertBackContextHash(arg.account->id(), *id_, seq, version); + auto const contextHash = getConvertBackContextHash(arg.account->id(), *id_, seq, version); Buffer proof; if (!prevEncSpending) diff --git a/src/test/jtx/mpt.h b/src/test/jtx/mpt.h index b6f1a21a20..d770f15355 100644 --- a/src/test/jtx/mpt.h +++ b/src/test/jtx/mpt.h @@ -567,7 +567,6 @@ public: std::uint64_t const amount, std::vector const& recipients, Slice const& blindingFactor, - std::size_t const nRecipients, uint256 const& contextHash, PedersenProofParams const& amountParams, PedersenProofParams const& balanceParams) const;