add back clawback hash (#6175)

This commit is contained in:
Shawn Xie
2026-01-06 12:21:00 -05:00
committed by GitHub
parent abf7a62b1f
commit 3e9dc276ed
4 changed files with 19 additions and 11 deletions

View File

@@ -27,11 +27,12 @@ addCommonZKPFields(
std::uint64_t amount);
uint256
getContextHash(
getClawbackContextHash(
AccountID const& account,
std::uint32_t sequence,
uint192 const& issuanceID,
std::uint64_t amount,
AccountID const& holder,
TxType const& txType);
AccountID const& holder);
/**
* @brief Generates a new secp256k1 key pair.

View File

@@ -10,23 +10,29 @@ void
addCommonZKPFields(
Serializer& s,
std::uint16_t txType,
AccountID const& account,
std::uint32_t sequence,
uint192 const& issuanceID,
std::uint64_t amount)
{
s.add16(txType);
s.addBitString(account);
s.add32(sequence);
s.addBitString(issuanceID);
s.add64(amount);
}
uint256
getContextHash(
getClawbackContextHash(
AccountID const& account,
std::uint32_t sequence,
uint192 const& issuanceID,
std::uint64_t amount,
AccountID const& holder,
TxType const& txType)
AccountID const& holder)
{
Serializer s;
addCommonZKPFields(s, txType, issuanceID, amount);
addCommonZKPFields(
s, ttCONFIDENTIAL_CLAWBACK, account, sequence, issuanceID, amount);
s.addBitString(holder);

View File

@@ -1097,8 +1097,9 @@ MPTTester::confidentialClaw(MPTConfidentialClawback const& arg)
jv[sfZKProof] = *arg.proof;
else
{
uint256 const ctxHash = getContextHash(
*id_, *arg.amt, arg.holder->id(), ttCONFIDENTIAL_CLAWBACK);
std::uint32_t const seq = env_.seq(account);
uint256 const ctxHash = getClawbackContextHash(
account.id(), seq, *id_, *arg.amt, arg.holder->id());
Buffer proof = getClawbackProof(
*arg.holder, *arg.amt, getPrivKey(account), ctxHash);

View File

@@ -87,8 +87,8 @@ ConfidentialClawback::preclaim(PreclaimContext const& ctx)
auto const ciphertext = (*sleHolderMPToken)[sfIssuerEncryptedBalance];
auto const pubKeySlice = (*sleIssuance)[sfIssuerElGamalPublicKey];
auto const contextHash =
getContextHash(mptIssuanceID, amount, holder, ctx.tx.getTxnType());
auto const contextHash = getClawbackContextHash(
account, ctx.tx[sfSequence], mptIssuanceID, amount, holder);
return verifyEqualityProof(
amount, ctx.tx[sfZKProof], pubKeySlice, ciphertext, contextHash);
}