Skip to content

Commit 814fe01

Browse files
authored
Merge branch 'develop' into ximinez/lending-XLS-66
2 parents dedafbe + 21c0223 commit 814fe01

31 files changed

+105
-259
lines changed

include/xrpl/protocol/PublicKey.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,7 @@ verifyDigest(
231231
SHA512-Half, and the resulting digest is signed.
232232
*/
233233
[[nodiscard]] bool
234-
verify(
235-
PublicKey const& publicKey,
236-
Slice const& m,
237-
Slice const& sig,
238-
bool mustBeFullyCanonical = true) noexcept;
234+
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept;
239235

240236
/** Calculate the 160-bit node ID from a node public key. */
241237
NodeID

include/xrpl/protocol/STTx.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,15 @@ class STTx final : public STObject, public CountedObject<STTx>
103103
std::optional<std::reference_wrapper<SField const>> signatureTarget =
104104
{});
105105

106-
enum class RequireFullyCanonicalSig : bool { no, yes };
107-
108106
/** Check the signature.
109-
@param requireCanonicalSig If `true`, check that the signature is fully
110-
canonical. If `false`, only check that the signature is valid.
111107
@param rules The current ledger rules.
112108
@return `true` if valid signature. If invalid, the error message string.
113109
*/
114110
Expected<void, std::string>
115-
checkSign(RequireFullyCanonicalSig requireCanonicalSig, Rules const& rules)
116-
const;
111+
checkSign(Rules const& rules) const;
117112

118113
Expected<void, std::string>
119-
checkBatchSign(
120-
RequireFullyCanonicalSig requireCanonicalSig,
121-
Rules const& rules) const;
114+
checkBatchSign(Rules const& rules) const;
122115

123116
// SQL Functions with metadata.
124117
static std::string const&
@@ -140,40 +133,25 @@ class STTx final : public STObject, public CountedObject<STTx>
140133

141134
private:
142135
/** Check the signature.
143-
@param requireCanonicalSig If `true`, check that the signature is fully
144-
canonical. If `false`, only check that the signature is valid.
145136
@param rules The current ledger rules.
146137
@param sigObject Reference to object that contains the signature fields.
147138
Will be *this more often than not.
148139
@return `true` if valid signature. If invalid, the error message string.
149140
*/
150141
Expected<void, std::string>
151-
checkSign(
152-
RequireFullyCanonicalSig requireCanonicalSig,
153-
Rules const& rules,
154-
STObject const& sigObject) const;
142+
checkSign(Rules const& rules, STObject const& sigObject) const;
155143

156144
Expected<void, std::string>
157-
checkSingleSign(
158-
RequireFullyCanonicalSig requireCanonicalSig,
159-
STObject const& sigObject) const;
145+
checkSingleSign(STObject const& sigObject) const;
160146

161147
Expected<void, std::string>
162-
checkMultiSign(
163-
RequireFullyCanonicalSig requireCanonicalSig,
164-
Rules const& rules,
165-
STObject const& sigObject) const;
148+
checkMultiSign(Rules const& rules, STObject const& sigObject) const;
166149

167150
Expected<void, std::string>
168-
checkBatchSingleSign(
169-
STObject const& batchSigner,
170-
RequireFullyCanonicalSig requireCanonicalSig) const;
151+
checkBatchSingleSign(STObject const& batchSigner) const;
171152

172153
Expected<void, std::string>
173-
checkBatchMultiSign(
174-
STObject const& batchSigner,
175-
RequireFullyCanonicalSig requireCanonicalSig,
176-
Rules const& rules) const;
154+
checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
177155

178156
STBase*
179157
copy(std::size_t n, void* buf) const override;

include/xrpl/protocol/detail/features.macro

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo
6868
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
6969
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
7070
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
71-
XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes)
72-
XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes)
7371
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
7472

7573
// The following amendments are obsolete, but must remain supported
@@ -82,9 +80,9 @@ XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYe
8280
// enabled (added to the ledger).
8381
//
8482
// If a feature remains obsolete for long enough that no clients are able
85-
// to vote for it, the feature can be removed (entirely?) from the code.
86-
XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete)
87-
83+
// to vote for it, the feature can be removed entirely from the code. Until
84+
// then the feature needs to be marked explicitly as obsolete, e.g.
85+
// XRPL_FEATURE(Example, Supported::yes, VoteBehavior::Obsolete)
8886
// The following amendments have been active for at least two years. Their
8987
// pre-amendment code has been removed and the identifiers are deprecated.
9088
// All known amendments and amendments that may appear in a validated ledger
@@ -120,6 +118,8 @@ XRPL_RETIRE_FIX(TrustLinesToSelf)
120118
XRPL_RETIRE_FEATURE(Checks)
121119
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
122120
XRPL_RETIRE_FEATURE(CryptoConditions)
121+
XRPL_RETIRE_FEATURE(CryptoConditionsSuite)
122+
XRPL_RETIRE_FEATURE(DeletableAccounts)
123123
XRPL_RETIRE_FEATURE(DepositAuth)
124124
XRPL_RETIRE_FEATURE(DepositPreauth)
125125
XRPL_RETIRE_FEATURE(DisallowIncoming)
@@ -135,6 +135,7 @@ XRPL_RETIRE_FEATURE(MultiSignReserve)
135135
XRPL_RETIRE_FEATURE(NegativeUNL)
136136
XRPL_RETIRE_FEATURE(NonFungibleTokensV1_1)
137137
XRPL_RETIRE_FEATURE(PayChan)
138+
XRPL_RETIRE_FEATURE(RequireFullyCanonicalSig)
138139
XRPL_RETIRE_FEATURE(SortedDirectories)
139140
XRPL_RETIRE_FEATURE(TicketBatch)
140141
XRPL_RETIRE_FEATURE(TickSize)

include/xrpl/protocol/detail/transactions.macro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet,
297297
#endif
298298
TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete,
299299
Delegation::notDelegatable,
300-
featureDeletableAccounts,
300+
uint256{},
301301
mustDeleteAcct,
302302
({
303303
{sfDestination, soeREQUIRED},

src/libxrpl/ledger/View.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ rippleSendIOU(
21382138
// Direct send: redeeming IOUs and/or sending own IOUs.
21392139
auto const ter =
21402140
rippleCreditIOU(view, uSenderID, uReceiverID, saAmount, false, j);
2141-
if (view.rules().enabled(featureDeletableAccounts) && ter != tesSUCCESS)
2141+
if (ter != tesSUCCESS)
21422142
return ter;
21432143
saActual = saAmount;
21442144
return tesSUCCESS;

src/libxrpl/protocol/PublicKey.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,13 @@ verifyDigest(
267267
}
268268

269269
bool
270-
verify(
271-
PublicKey const& publicKey,
272-
Slice const& m,
273-
Slice const& sig,
274-
bool mustBeFullyCanonical) noexcept
270+
verify(PublicKey const& publicKey, Slice const& m, Slice const& sig) noexcept
275271
{
276272
if (auto const type = publicKeyType(publicKey))
277273
{
278274
if (*type == KeyType::secp256k1)
279275
{
280-
return verifyDigest(
281-
publicKey, sha512Half(m), sig, mustBeFullyCanonical);
276+
return verifyDigest(publicKey, sha512Half(m), sig);
282277
}
283278
else if (*type == KeyType::ed25519)
284279
{

src/libxrpl/protocol/STTx.cpp

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ STTx::sign(
237237
}
238238

239239
Expected<void, std::string>
240-
STTx::checkSign(
241-
RequireFullyCanonicalSig requireCanonicalSig,
242-
Rules const& rules,
243-
STObject const& sigObject) const
240+
STTx::checkSign(Rules const& rules, STObject const& sigObject) const
244241
{
245242
try
246243
{
@@ -249,9 +246,8 @@ STTx::checkSign(
249246
// multi-signing. Otherwise we're single-signing.
250247

251248
Blob const& signingPubKey = sigObject.getFieldVL(sfSigningPubKey);
252-
return signingPubKey.empty()
253-
? checkMultiSign(requireCanonicalSig, rules, sigObject)
254-
: checkSingleSign(requireCanonicalSig, sigObject);
249+
return signingPubKey.empty() ? checkMultiSign(rules, sigObject)
250+
: checkSingleSign(sigObject);
255251
}
256252
catch (std::exception const&)
257253
{
@@ -260,27 +256,23 @@ STTx::checkSign(
260256
}
261257

262258
Expected<void, std::string>
263-
STTx::checkSign(
264-
RequireFullyCanonicalSig requireCanonicalSig,
265-
Rules const& rules) const
259+
STTx::checkSign(Rules const& rules) const
266260
{
267-
if (auto const ret = checkSign(requireCanonicalSig, rules, *this); !ret)
261+
if (auto const ret = checkSign(rules, *this); !ret)
268262
return ret;
269263

270264
if (isFieldPresent(sfCounterpartySignature))
271265
{
272266
auto const counterSig = getFieldObject(sfCounterpartySignature);
273-
if (auto const ret = checkSign(requireCanonicalSig, rules, counterSig);
267+
if (auto const ret = checkSign(rules, counterSig);
274268
!ret)
275269
return Unexpected("Counterparty: " + ret.error());
276270
}
277271
return {};
278272
}
279273

280274
Expected<void, std::string>
281-
STTx::checkBatchSign(
282-
RequireFullyCanonicalSig requireCanonicalSig,
283-
Rules const& rules) const
275+
STTx::checkBatchSign(Rules const& rules) const
284276
{
285277
try
286278
{
@@ -297,8 +289,8 @@ STTx::checkBatchSign(
297289
{
298290
Blob const& signingPubKey = signer.getFieldVL(sfSigningPubKey);
299291
auto const result = signingPubKey.empty()
300-
? checkBatchMultiSign(signer, requireCanonicalSig, rules)
301-
: checkBatchSingleSign(signer, requireCanonicalSig);
292+
? checkBatchMultiSign(signer, rules)
293+
: checkBatchSingleSign(signer);
302294

303295
if (!result)
304296
return result;
@@ -393,10 +385,7 @@ STTx::getMetaSQL(
393385
}
394386

395387
static Expected<void, std::string>
396-
singleSignHelper(
397-
STObject const& sigObject,
398-
Slice const& data,
399-
bool const fullyCanonical)
388+
singleSignHelper(STObject const& sigObject, Slice const& data)
400389
{
401390
// We don't allow both a non-empty sfSigningPubKey and an sfSigners.
402391
// That would allow the transaction to be signed two ways. So if both
@@ -411,11 +400,8 @@ singleSignHelper(
411400
if (publicKeyType(makeSlice(spk)))
412401
{
413402
Blob const signature = sigObject.getFieldVL(sfTxnSignature);
414-
validSig = verify(
415-
PublicKey(makeSlice(spk)),
416-
data,
417-
makeSlice(signature),
418-
fullyCanonical);
403+
validSig =
404+
verify(PublicKey(makeSlice(spk)), data, makeSlice(signature));
419405
}
420406
}
421407
catch (std::exception const&)
@@ -430,33 +416,24 @@ singleSignHelper(
430416
}
431417

432418
Expected<void, std::string>
433-
STTx::checkSingleSign(
434-
RequireFullyCanonicalSig requireCanonicalSig,
435-
STObject const& sigObject) const
419+
STTx::checkSingleSign(STObject const& sigObject) const
436420
{
437421
auto const data = getSigningData(*this);
438-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
439-
(requireCanonicalSig == STTx::RequireFullyCanonicalSig::yes);
440-
return singleSignHelper(sigObject, makeSlice(data), fullyCanonical);
422+
return singleSignHelper(sigObject, makeSlice(data));
441423
}
442424

443425
Expected<void, std::string>
444-
STTx::checkBatchSingleSign(
445-
STObject const& batchSigner,
446-
RequireFullyCanonicalSig requireCanonicalSig) const
426+
STTx::checkBatchSingleSign(STObject const& batchSigner) const
447427
{
448428
Serializer msg;
449429
serializeBatch(msg, getFlags(), getBatchTransactionIDs());
450-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
451-
(requireCanonicalSig == STTx::RequireFullyCanonicalSig::yes);
452-
return singleSignHelper(batchSigner, msg.slice(), fullyCanonical);
430+
return singleSignHelper(batchSigner, msg.slice());
453431
}
454432

455433
Expected<void, std::string>
456434
multiSignHelper(
457435
STObject const& sigObject,
458436
std::optional<AccountID> txnAccountID,
459-
bool const fullyCanonical,
460437
std::function<Serializer(AccountID const&)> makeMsg,
461438
Rules const& rules)
462439
{
@@ -513,8 +490,7 @@ multiSignHelper(
513490
validSig = verify(
514491
PublicKey(makeSlice(spk)),
515492
makeMsg(accountID).slice(),
516-
makeSlice(signature),
517-
fullyCanonical);
493+
makeSlice(signature));
518494
}
519495
}
520496
catch (std::exception const& e)
@@ -533,14 +509,8 @@ multiSignHelper(
533509
}
534510

535511
Expected<void, std::string>
536-
STTx::checkBatchMultiSign(
537-
STObject const& batchSigner,
538-
RequireFullyCanonicalSig requireCanonicalSig,
539-
Rules const& rules) const
512+
STTx::checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const
540513
{
541-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
542-
(requireCanonicalSig == RequireFullyCanonicalSig::yes);
543-
544514
// We can ease the computational load inside the loop a bit by
545515
// pre-constructing part of the data that we hash. Fill a Serializer
546516
// with the stuff that stays constant from signature to signature.
@@ -549,7 +519,6 @@ STTx::checkBatchMultiSign(
549519
return multiSignHelper(
550520
batchSigner,
551521
std::nullopt,
552-
fullyCanonical,
553522
[&dataStart](AccountID const& accountID) -> Serializer {
554523
Serializer s = dataStart;
555524
finishMultiSigningData(accountID, s);
@@ -559,14 +528,8 @@ STTx::checkBatchMultiSign(
559528
}
560529

561530
Expected<void, std::string>
562-
STTx::checkMultiSign(
563-
RequireFullyCanonicalSig requireCanonicalSig,
564-
Rules const& rules,
565-
STObject const& sigObject) const
531+
STTx::checkMultiSign(Rules const& rules, STObject const& sigObject) const
566532
{
567-
bool const fullyCanonical = (getFlags() & tfFullyCanonicalSig) ||
568-
(requireCanonicalSig == RequireFullyCanonicalSig::yes);
569-
570533
// Used inside the loop in multiSignHelper to enforce that
571534
// the account owner may not multisign for themselves.
572535
auto const txnAccountID = &sigObject != this
@@ -580,7 +543,6 @@ STTx::checkMultiSign(
580543
return multiSignHelper(
581544
sigObject,
582545
txnAccountID,
583-
fullyCanonical,
584546
[&dataStart](AccountID const& accountID) -> Serializer {
585547
Serializer s = dataStart;
586548
finishMultiSigningData(accountID, s);

0 commit comments

Comments
 (0)