Skip to content

Commit

Permalink
add feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Dec 11, 2024
1 parent 888f4fe commit 697b6b7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/ripple/app/tx/impl/SetAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,23 @@ SetAccount::doApply()
}
}

//
// QuantumSignature
//
if (ctx_.view().rules().enabled(featureQuantumSigning))
{
if (uSetFlag == asfForceQuantum)
{
JLOG(j_.trace()) << "Set lsfForceQuantum.";
uFlagsOut |= lsfForceQuantum;
}
else if (uClearFlag == asfForceQuantum)
{
JLOG(j_.trace()) << "Clear lsfForceQuantum.";
uFlagsOut &= ~lsfForceQuantum;
}
}

if (uFlagsIn != uFlagsOut)
sle->setFieldU32(sfFlags, uFlagsOut);

Expand Down
14 changes: 13 additions & 1 deletion src/ripple/app/tx/impl/Transactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
#include <ripple/protocol/UintTypes.h>
#include <limits>
#include <set>
extern "C" {
#include "api.h"
}

#ifndef DILITHIUM_PK_SIZE
#define DILITHIUM_PK_SIZE pqcrystals_dilithium2_PUBLICKEYBYTES
#endif

namespace ripple {

Expand Down Expand Up @@ -857,13 +864,18 @@ Transactor::checkSingleSign(PreclaimContext const& ctx)
}

// Look up the account.
auto const idSigner = calcAccountID(PublicKey(makeSlice(pkSigner)));
PublicKey pubKey = PublicKey(makeSlice(pkSigner));
auto const idSigner = calcAccountID(pubKey);
auto const idAccount = ctx.tx.getAccountID(sfAccount);
auto const sleAccount = ctx.view.read(keylet::account(idAccount));

if (!sleAccount)
return terNO_ACCOUNT;

if (ctx.view.rules().enabled(featureQuantumSigning) &&
sleAccount->isFlag(lsfForceQuantum) && pubKey.size() != DILITHIUM_PK_SIZE)
return telBAD_PUBLIC_KEY;

bool const isMasterDisabled = sleAccount->isFlag(lsfDisableMaster);

if (ctx.view.rules().enabled(fixMasterKeyAsRegularKey))
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t numFeatures = 74;
static constexpr std::size_t numFeatures = 75;

/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
Expand Down Expand Up @@ -362,6 +362,7 @@ extern uint256 const fix240819;
extern uint256 const fixPageCap;
extern uint256 const fix240911;
extern uint256 const fixFloatDivide;
extern uint256 const featureQuantumSigning;

} // namespace ripple

Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ enum LedgerSpecificFlags {
0x00800000, // True, trust lines allow rippling by default
lsfDepositAuth = 0x01000000, // True, all deposits require authorization
lsfTshCollect = 0x02000000, // True, allow TSH collect-calls to acc hooks
lsfForceQuantum = 0x04000000, // True, force quantum-resistant signature
lsfDisallowIncomingNFTokenOffer =
0x04000000, // True, reject new incoming NFT offers
lsfDisallowIncomingCheck =
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/TxFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ enum AccountFlags : uint32_t {
asfDisallowIncomingPayChan = 14,
asfDisallowIncomingTrustline = 15,
asfDisallowIncomingRemit = 16,
asfForceQuantum = 17,
};

// OfferCreate flags:
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::De
REGISTER_FIX (fixPageCap, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fix240911, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FIX (fixFloatDivide, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(QuantumSigning, Supported::yes, VoteBehavior::DefaultYes);

// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.
Expand Down

0 comments on commit 697b6b7

Please sign in to comment.