Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions include/xrpl/protocol/ConfidentialTransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,64 +344,6 @@ verifyClawbackEqualityProof(
Buffer
generateBlindingFactor();

/**
* @brief Distinguishes the two algebraic structures used in
* ElGamal-Pedersen linkage proofs.
*
* - amount: The ciphertext was created with randomness `r`.
* Verification order: C1, C2, Pk, Pcm.
* - balance: The ciphertext was created with the secret key `s`.
* Verification order: Pk, C2, C1, Pcm (swaps Pk <-> C1).
*/
enum class PcmLinkageType { amount, balance };

/**
* @brief Verifies the cryptographic link between an ElGamal Ciphertext and a
* Pedersen Commitment.
*
* Proves that the ElGamal ciphertext `encAmt` encrypts the same value
* as the Pedersen Commitment `pcmSlice`.
*
* The `type` parameter selects the argument ordering passed to the
* underlying secp256k1 verification call to accommodate the different
* algebraic structures used for amounts (randomness `r`) vs balances
* (secret key `s`).
*
* @param type Whether this is an amount or balance linkage proof.
* @param proof The Zero Knowledge Proof bytes.
* @param encAmt The ElGamal ciphertext (C1, C2).
* @param pubKeySlice The sender's public key.
* @param pcmSlice The Pedersen Commitment.
* @param contextHash The unique context hash for this transaction.
* @return tesSUCCESS if the proof is valid, or an error code otherwise.
*/
TER
verifyPcmLinkage(
PcmLinkageType type,
Slice const& proof,
Slice const& encAmt,
Slice const& pubKeySlice,
Slice const& pcmSlice,
uint256 const& contextHash);

/**
* @brief Verifies an aggregated Bulletproof range proof.
*
* This function verifies that all commitments in commitment_C_vec commit
* to values within the valid 64-bit range [0, 2^64 - 1].
*
* @param proof The serialized Bulletproof proof.
* @param compressedCommitments Vector of compressed Pedersen commitments (each 33 bytes).
* @param contextHash The unique context hash for this transaction.
* @return tesSUCCESS if the proof is valid, tecBAD_PROOF if verification
* fails, or tecINTERNAL for internal errors.
*/
TER
verifyAggregatedBulletproof(
Slice const& proof,
std::vector<Slice> const& compressedCommitments,
uint256 const& contextHash);

/**
* @brief Verifies all zero-knowledge proofs for a ConfidentialMPTSend transaction.
*
Expand Down Expand Up @@ -461,19 +403,6 @@ verifyConvertBackProof(
uint64_t amount,
uint256 const& contextHash);

/**
* @brief Computes the remainder commitment for ConvertBack.
*
* Given a Pedersen commitment PC = m*G + rho*H, this function computes
* PC_rem = PC - amount*G = (m - amount)*G + rho*H
*
* @param commitment The compressed Pedersen commitment (33 bytes).
* @param amount The amount to subtract (must be non-zero).
* @return The remainder commitment (33 bytes), or std::nullopt on failure or if amount is 0.
*/
std::optional<Buffer>
computeConvertBackRemainder(Slice const& commitment, uint64_t amount);

/**
* @brief Sequential reader for extracting proof components from a ZKProof blob.
*
Expand Down
80 changes: 0 additions & 80 deletions src/libxrpl/protocol/ConfidentialTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,72 +355,6 @@ verifyClawbackEqualityProof(
return tesSUCCESS;
}

TER
verifyPcmLinkage(
PcmLinkageType type,
Slice const& proof,
Slice const& encAmt,
Slice const& pubKeySlice,
Slice const& pcmSlice,
uint256 const& contextHash)
{
if (proof.length() != ecPedersenProofLength || pubKeySlice.size() != ecPubKeyLength ||
pcmSlice.size() != ecPedersenCommitmentLength ||
encAmt.size() != ecGamalEncryptedTotalLength)
return tecINTERNAL;

int res;
if (type == PcmLinkageType::amount)
{
res = mpt_verify_amount_linkage(
secp256k1Context(),
proof.data(),
encAmt.data(),
pubKeySlice.data(),
pcmSlice.data(),
contextHash.data());
}
else
{
res = mpt_verify_balance_linkage(
proof.data(), encAmt.data(), pubKeySlice.data(), pcmSlice.data(), contextHash.data());
}

if (res != 0)
return tecBAD_PROOF;
return tesSUCCESS;
}

TER
verifyAggregatedBulletproof(
Slice const& proof,
std::vector<Slice> const& compressedCommitments,
uint256 const& contextHash)
{
std::size_t const m = compressedCommitments.size();
if (m != 1 && m != 2)
return tecINTERNAL; // LCOV_EXCL_LINE

std::size_t const expectedProofLen =
(m == 1) ? ecSingleBulletproofLength : ecDoubleBulletproofLength;
if (proof.size() != expectedProofLen)
return tecINTERNAL; // LCOV_EXCL_LINE

std::vector<uint8_t const*> commitmentPtrs(m);
for (size_t i = 0; i < m; ++i)
{
if (compressedCommitments[i].size() != ecPedersenCommitmentLength)
return tecINTERNAL; // LCOV_EXCL_LINE
commitmentPtrs[i] = compressedCommitments[i].data();
}

if (mpt_verify_aggregated_bulletproof(
proof.data(), proof.size(), commitmentPtrs.data(), m, contextHash.data()) != 0)
return tecBAD_PROOF;

return tesSUCCESS;
}

TER
verifySendProof(
Slice const& proof,
Expand Down Expand Up @@ -508,18 +442,4 @@ verifyConvertBackProof(
return tesSUCCESS;
}

std::optional<Buffer>
computeConvertBackRemainder(Slice const& commitment, uint64_t amount)
{
if (commitment.size() != ecPedersenCommitmentLength || amount == 0)
return std::nullopt; // LCOV_EXCL_LINE

Buffer out;
out.alloc(ecPedersenCommitmentLength);
if (mpt_compute_convert_back_remainder(commitment.data(), amount, out.data()) != 0)
return std::nullopt; // LCOV_EXCL_LINE

return out;
}

} // namespace xrpl
Loading