Compress ElGamal Public Keys and Pedersen Commitments + Add Validation (#6385)

This commit is contained in:
Shawn Xie
2026-02-19 08:41:15 -05:00
committed by GitHub
parent b6d1a8d62b
commit b2c434dd73
9 changed files with 206 additions and 65 deletions

View File

@@ -187,6 +187,18 @@ serializeEcPair(secp256k1_pubkey const& in1, secp256k1_pubkey const& in2, Buffer
bool
isValidCiphertext(Slice const& buffer);
/**
* @brief Verifies that a buffer contains a valid, parsable compressed EC point.
*
* Can be used to validate both compressed public keys and Pedersen commitments.
* Fails early if the prefix byte is not 0x02 or 0x03.
*
* @param buffer The input buffer containing a compressed EC point (33 bytes).
* @return true if the point can be parsed successfully, false otherwise.
*/
bool
isValidCompressedECPoint(Slice const& buffer);
/**
* @brief Homomorphically adds two ElGamal ciphertexts.
*

View File

@@ -305,8 +305,11 @@ std::size_t constexpr ecGamalEncryptedTotalLength = 66;
/** Length of equality ZKProof */
std::size_t constexpr ecEqualityProofLength = 98;
/** Length of EC public key */
std::size_t constexpr ecPubKeyLength = 64;
/** Length of EC point (compressed) */
std::size_t constexpr compressedECPointLength = 33;
/** Length of EC public key (compressed) */
std::size_t constexpr ecPubKeyLength = compressedECPointLength;
/** Length of EC private key */
std::size_t constexpr ecPrivKeyLength = 32;
@@ -323,7 +326,7 @@ std::size_t constexpr ecCiphertextEqualityProofLength = 261;
/** Length of ElGamal Pedersen linkage proof */
std::size_t constexpr ecPedersenProofLength = 195;
/** Length of Pedersen Commitment proof */
std::size_t constexpr ecPedersenCommitmentLength = 64;
/** Length of Pedersen Commitment (compressed) */
std::size_t constexpr ecPedersenCommitmentLength = compressedECPointLength;
} // namespace xrpl