Compare commits

..

71 Commits

Author SHA1 Message Date
RichardAH
5c5a39098e nothing commit to force rebuild 2025-05-13 11:10:23 +10:00
Denis Angell
fdc2a0e5a6 remove cosmetic changes 2025-05-08 11:47:58 +02:00
RichardAH
9b47d06c64 Merge branch 'dev' into tmp-conan 2025-05-03 12:31:28 +10:00
Denis Angell
34b3442e00 Merge branch 'dev' into tmp-conan 2025-04-30 11:52:25 +02:00
Denis Angell
dd5d580b97 [fold] bad merge 2025-04-30 10:39:12 +02:00
Denis Angell
e4478fa883 revert build in docker changes 2025-04-30 10:33:43 +02:00
RichardAH
857eefc829 Merge branch 'dev' into tmp-conan 2025-04-29 13:42:34 +10:00
Denis Angell
8ac2887961 Merge branch 'dev' into tmp-conan 2025-04-23 15:57:12 +02:00
Denis Angell
b87120ebc6 update conan boost 2025-04-23 15:56:13 +02:00
Denis Angell
c30b73db62 Merge branch 'dev' into tmp-conan 2025-04-17 08:41:34 +02:00
Denis Angell
8dc718a560 fix conan 2025-04-17 08:40:27 +02:00
Denis Angell
658eb73e00 build: add interface library libxrpl: (#4449)
Make it easy for projects to depend on libxrpl by adding an `ALIAS`
target named `xrpl::libxrpl` for projects to link.

The name was chosen because:

* The current library target is named `xrpl_core`. There is no other
  "non-core" library target against which we need to distinguish the
  "core" library. We only export one library target, and it should just
  be named after the project to keep things simple and predictable.
* Underscores in target or library names are generally discouraged.
* Every target exported in CMake should be prefixed with the project
  name.

By adding an `ALIAS` target, existing consumers who use the `xrpl_core`
target will not be affected.

* In the future, there can be a migration plan to make `xrpl_core` the
  `ALIAS` target (and `libxrpl` the "real" target, which will affect the
  filename of the compiled binary), and eventually remove it entirely.

Also:

* Fix the Conan recipe so that consumers using Conan import a target
  named `xrpl::libxrpl`. This way, every consumer can use the same
  instructions.
* Document the two easiest methods to depend on libxrpl. Both have been
  tested.
* See #4443.
2025-04-16 11:29:35 +02:00
RichardAH
df2e2ecd7c Merge branch 'dev' into tmp-conan 2025-04-16 10:29:29 +10:00
Denis Angell
26cb84fa6c remove more kInfo 2025-04-11 11:22:00 +02:00
Denis Angell
938feb3c23 Update release-builder.sh 2025-04-11 10:50:52 +02:00
Denis Angell
7d6b2e76d2 remove info log from catalogue tests 2025-04-11 10:45:46 +02:00
Denis Angell
ab38e48fff Merge branch 'dev' into tmp-conan 2025-04-10 11:35:45 +02:00
Denis Angell
9b7103ea4d rename workflow 2025-04-10 11:33:08 +02:00
Denis Angell
0bf50c5dc7 eof 2025-03-30 16:48:43 +02:00
Denis Angell
8b0592ce06 Update xahau-sh-build-in-docker.yml 2025-03-29 04:22:35 +01:00
Denis Angell
c27e2a9c05 Update xahau-sh-build-in-docker.yml 2025-03-29 03:26:09 +01:00
Denis Angell
f8d22bbc24 add caching 2025-03-29 03:08:58 +01:00
Denis Angell
95ab35a185 Update release-builder.sh 2025-03-29 02:43:43 +01:00
Denis Angell
313ad7134b test workflow 2025-03-29 02:40:38 +01:00
Denis Angell
859dcbcabf remove EXIT_IF_CONTAINER_RUNNING 2025-03-29 02:26:01 +01:00
Denis Angell
a8e9448b1a revert docker dependency cache 2025-03-29 02:15:13 +01:00
Denis Angell
cab4d63a07 revert some cmake builds 2025-03-28 20:44:09 +01:00
Denis Angell
9a90a7ffdc optional release builder 2025-03-28 20:42:18 +01:00
Denis Angell
ddbbe91e5a attempt fix builder 2025-03-28 19:32:37 +01:00
Denis Angell
2d9ac91cd1 fix build dir 2025-03-28 14:35:41 +01:00
Denis Angell
ed243745f8 fix checkpatterns 2025-03-28 11:49:45 +01:00
Denis Angell
5eac2d3e44 change on fields 2025-03-28 11:44:22 +01:00
Denis Angell
245cf4a676 refactor checkpatterns remove comments 2025-03-28 10:44:18 +01:00
Denis Angell
864734f607 Update xahau-sh-build-in-docker.yml 2025-03-28 10:35:21 +01:00
Niq Dudfield
689740d818 Use GA runners with conan/ccache caches (#482) 2025-03-28 10:29:55 +01:00
Denis Angell
48919f028c [GA] Remove build caching 2025-03-25 11:40:18 +01:00
Denis Angell
9c26f1f213 [GA] revert 2025-03-25 10:45:28 +01:00
Denis Angell
69b7728b2d [GA] tmp disable build cache 2025-03-25 10:37:17 +01:00
Denis Angell
9178aa9d8a [GA] remove unused workflows 2025-03-25 10:17:33 +01:00
Denis Angell
17fdd09640 [GA] update conan profile 2025-03-25 10:13:05 +01:00
Denis Angell
40dc69d642 [GA] conan mac os build 2025-03-25 10:06:17 +01:00
Denis Angell
58e3840345 remove cxxflags for macos action 2025-03-24 12:02:01 +01:00
Denis Angell
b73dd584e7 Merge branch 'dev' into tmp-conan 2025-03-21 15:15:03 +01:00
Denis Angell
0726789d77 update conan to 1.86 2025-03-21 15:09:59 +01:00
Denis Angell
5ef3795cea [fix] release build issue 2025-03-06 08:47:01 +01:00
Denis Angell
da5f1d189b Merge branch 'dev' into tmp-conan 2025-03-05 08:22:27 +01:00
Denis Angell
6fdf788b13 Merge branch 'dev' into tmp-conan 2025-02-28 10:22:52 +01:00
Denis Angell
802ea6c568 [temp] remove negative rate test 2025-02-11 14:32:29 +01:00
Denis Angell
ecc779346e Merge branch 'dev' into tmp-conan 2025-02-11 12:11:27 +01:00
Denis Angell
680c6095d4 Update macos.yml 2025-02-11 12:06:20 +01:00
Denis Angell
6858861660 fix failing test 2025-02-07 11:01:20 +01:00
Denis Angell
9faef17407 fix bad commit 2025-02-06 11:13:29 +01:00
Denis Angell
ee68cc2cd2 clang-format 2025-02-05 11:31:06 +01:00
Denis Angell
7c360bad33 add optional include 2025-02-05 11:31:00 +01:00
Denis Angell
26a66bc2ef fix misc warnings 2025-02-04 12:24:34 +01:00
Denis Angell
4b93e1657f fix macos github action 2025-02-04 12:18:32 +01:00
Denis Angell
cd45285cab include optional 2025-02-04 12:18:25 +01:00
Denis Angell
b7acfb9803 fix misc warnings 2025-02-04 12:18:09 +01:00
Denis Angell
97a10d6556 [fold] fix test 2025-02-04 12:08:12 +01:00
Denis Angell
fe43029272 [fold] clang-format 2025-02-02 23:13:25 +01:00
Denis Angell
bf33b6f637 [fold] update conan 2025-02-02 22:25:33 +01:00
Denis Angell
c27518b846 [fold] use rippleci docker image 2025-02-02 22:23:26 +01:00
Denis Angell
7d8f5de93d [fold] remove conan patch 2025-02-02 22:23:15 +01:00
Denis Angell
858ea1bf25 [fold] add external snappy 2025-02-02 21:46:08 +01:00
Denis Angell
7162fe0497 [fold] upgrade artifact@v4 2025-02-02 21:09:52 +01:00
Denis Angell
56c0e0dd5f [fold] fix bad assert 2025-02-02 21:07:09 +01:00
Denis Angell
20ca066454 [fold] update workflow 2025-02-02 21:06:55 +01:00
Denis Angell
171610d1a9 [release] add release build 2025-02-01 16:54:35 +01:00
Denis Angell
2f6cf0ab4b [patch] remit transfer rate 2025-02-01 13:11:56 +01:00
Denis Angell
71884ad48a sync 2025-02-01 12:11:01 +01:00
Denis Angell
799a056313 conan 2025-02-01 12:00:35 +01:00
18 changed files with 22 additions and 24587 deletions

View File

@@ -153,7 +153,6 @@ target_link_libraries (xrpl_core
Ripple::syslibs
secp256k1::secp256k1
ed25519::ed25519
NIH::dilithium2_ref
date::date
Ripple::opts)
#[=================================[

View File

@@ -1,84 +0,0 @@
include(FetchContent)
ExternalProject_Add(
dilithium_src
PREFIX ${nih_cache_path}
GIT_REPOSITORY https://github.com/pq-crystals/dilithium.git
GIT_TAG v3.1
CMAKE_ARGS
-DDILITHIUM_MODE=2
-DDILITHIUM_RANDOMIZED_SIGNING=ON
-DDILITHIUM_USE_AES=ON
LOG_BUILD ON
LOG_CONFIGURE ON
COMMAND
pwd
BUILD_COMMAND
${CMAKE_COMMAND}
--build .
--config $<CONFIG>
$<$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.12>:--parallel ${ep_procs}>
INSTALL_COMMAND ""
BUILD_BYPRODUCTS
<BINARY_DIR>/ref/libdilithium2_ref.a
<BINARY_DIR>/ref/libdilithium2aes_ref.a
<BINARY_DIR>/ref/libfips202_ref.a
)
ExternalProject_Get_Property(dilithium_src BINARY_DIR)
ExternalProject_Get_Property(dilithium_src SOURCE_DIR)
set(dilithium_src_SOURCE_DIR "${SOURCE_DIR}")
set(dilithium_src_BINARY_DIR "${BINARY_DIR}")
# Check if the api.h file exists
include_directories("${dilithium_src_SOURCE_DIR}/ref")
# Create imported targets for each static library
add_library(dilithium::dilithium2_ref STATIC IMPORTED GLOBAL)
set_target_properties(dilithium::dilithium2_ref PROPERTIES
IMPORTED_LOCATION "${dilithium_src_BINARY_DIR}/ref/libdilithium2_ref.a"
INTERFACE_INCLUDE_DIRECTORIES "${dilithium_src_SOURCE_DIR}/ref/"
)
add_library(dilithium::dilithium2aes_ref STATIC IMPORTED GLOBAL)
set_target_properties(dilithium::dilithium2aes_ref PROPERTIES
IMPORTED_LOCATION "${dilithium_src_BINARY_DIR}/ref/libdilithium2aes_ref.a"
INTERFACE_INCLUDE_DIRECTORIES "${dilithium_src_SOURCE_DIR}/ref/"
)
add_library(dilithium::libfips202_ref STATIC IMPORTED GLOBAL)
set_target_properties(dilithium::libfips202_ref PROPERTIES
IMPORTED_LOCATION "${dilithium_src_BINARY_DIR}/ref/libfips202_ref.a"
INTERFACE_INCLUDE_DIRECTORIES "${dilithium_src_SOURCE_DIR}/ref/"
)
add_dependencies(dilithium::dilithium2_ref dilithium_src)
add_dependencies(dilithium::dilithium2aes_ref dilithium_src)
add_dependencies(dilithium::libfips202_ref dilithium_src)
# Add a custom command to generate randombytes.c
add_custom_command(
OUTPUT "${dilithium_src_BINARY_DIR}/ref/randombytes.c"
COMMAND ${CMAKE_COMMAND} -E copy "${dilithium_src_SOURCE_DIR}/ref/randombytes.c" "${dilithium_src_BINARY_DIR}/ref/randombytes.c"
DEPENDS dilithium_src
)
# Add the randombytes_ref library
add_library(randombytes_ref STATIC "${dilithium_src_BINARY_DIR}/ref/randombytes.c")
# Include the Dilithium ref directory for headers
target_include_directories(randombytes_ref PUBLIC "${dilithium_src_SOURCE_DIR}/ref")
# Ensure that randombytes_ref depends on the Dilithium source so it's built after
add_dependencies(randombytes_ref dilithium_src)
# Create an interface library that links to both
target_link_libraries(ripple_libs INTERFACE
randombytes_ref
dilithium::dilithium2_ref
dilithium::dilithium2aes_ref
dilithium::libfips202_ref
)
# Link the Dilithium library to your target
add_library(NIH::dilithium2_ref ALIAS dilithium::dilithium2_ref)

View File

@@ -81,7 +81,6 @@ endif ()
include(RippledCompiler)
include(RippledInterface)
include(deps/dilithium)
###
if (NOT USE_CONAN)
add_subdirectory(src/secp256k1)

View File

@@ -587,23 +587,6 @@ 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);

View File

@@ -40,13 +40,6 @@
#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 {
@@ -864,18 +857,13 @@ Transactor::checkSingleSign(PreclaimContext const& ctx)
}
// Look up the account.
PublicKey pubKey = PublicKey(makeSlice(pkSigner));
auto const idSigner = calcAccountID(pubKey);
auto const idSigner = calcAccountID(PublicKey(makeSlice(pkSigner)));
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))

View File

@@ -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 = 82;
static constexpr std::size_t numFeatures = 81;
/** Amendments that this server supports and the default voting behavior.
Whether they are enabled depends on the Rules defined in the validated
@@ -369,7 +369,6 @@ extern uint256 const fixXahauV3;
extern uint256 const fix20250131;
extern uint256 const featureHookCanEmit;
extern uint256 const fixRewardClaimFlags;
extern uint256 const featureQuantumSigning;
} // namespace ripple

View File

@@ -28,7 +28,6 @@ namespace ripple {
enum class KeyType {
secp256k1 = 0,
ed25519 = 1,
dilithium = 2,
};
inline std::optional<KeyType>
@@ -40,9 +39,6 @@ keyTypeFromString(std::string const& s)
if (s == "ed25519")
return KeyType::ed25519;
if (s == "dilithium")
return KeyType::dilithium;
return {};
}
@@ -54,9 +50,6 @@ to_string(KeyType type)
if (type == KeyType::ed25519)
return "ed25519";
if (type == KeyType::dilithium)
return "dilithium";
return "INVALID";
}

View File

@@ -275,7 +275,6 @@ 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 =

View File

@@ -43,11 +43,10 @@ namespace ripple {
information needed to determine the cryptosystem
parameters used is stored inside the key.
As of this writing three systems are supported:
As of this writing two systems are supported:
secp256k1
ed25519
dilithium
secp256k1 public keys consist of a 33 byte
compressed public key, with the lead byte equal
@@ -56,14 +55,12 @@ namespace ripple {
The ed25519 public keys consist of a 1 byte
prefix constant 0xED, followed by 32 bytes of
public key data.
The dilithium public keys will have their own specific format.
*/
class PublicKey
{
protected:
std::uint8_t buf_[1312];
std::size_t size_ = 0;
std::uint8_t buf_[33]; // should be large enough
public:
using const_iterator = std::uint8_t const*;

View File

@@ -36,8 +36,7 @@ namespace ripple {
class SecretKey
{
private:
std::uint8_t buf_[2528];
std::size_t size_ = 0;
std::uint8_t buf_[32];
public:
using const_iterator = std::uint8_t const*;
@@ -50,7 +49,6 @@ public:
~SecretKey();
SecretKey(std::array<std::uint8_t, 32> const& data);
SecretKey(std::array<std::uint8_t, 2528> const& data);
SecretKey(Slice const& slice);
std::uint8_t const*
@@ -62,7 +60,7 @@ public:
std::size_t
size() const
{
return size_;
return sizeof(buf_);
}
/** Convert the secret key to a hexadecimal string.
@@ -88,13 +86,13 @@ public:
const_iterator
end() const noexcept
{
return buf_ + size_;
return buf_ + sizeof(buf_);
}
const_iterator
cend() const noexcept
{
return buf_ + size_;
return buf_ + sizeof(buf_);
}
};
@@ -128,10 +126,6 @@ toBase58(TokenType type, SecretKey const& sk)
SecretKey
randomSecretKey();
/** Create a secret key using secure random numbers. */
SecretKey
randomSecretKey(KeyType type);
/** Generate a new secret key deterministically. */
SecretKey
generateSecretKey(KeyType type, Seed const& seed);

View File

@@ -92,7 +92,6 @@ enum AccountFlags : uint32_t {
asfDisallowIncomingPayChan = 14,
asfDisallowIncomingTrustline = 15,
asfDisallowIncomingRemit = 16,
asfForceQuantum = 17,
};
// OfferCreate flags:

View File

@@ -475,7 +475,6 @@ REGISTER_FIX (fixXahauV3, Supported::yes, VoteBehavior::De
REGISTER_FIX (fix20250131, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(HookCanEmit, Supported::yes, VoteBehavior::DefaultNo);
REGISTER_FIX (fixRewardClaimFlags, 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.

View File

@@ -26,18 +26,6 @@
#include <ed25519.h>
#include <type_traits>
extern "C" {
#include "api.h"
}
#ifndef CRYPTO_PUBLICKEYBYTES
#define CRYPTO_PUBLICKEYBYTES pqcrystals_dilithium2_PUBLICKEYBYTES
#endif
#ifndef crypto_sign_verify
#define crypto_sign_verify pqcrystals_dilithium2_ref_verify
#endif
namespace ripple {
std::ostream&
@@ -225,10 +213,6 @@ publicKeyType(Slice const& slice)
if (slice[0] == 0x02 || slice[0] == 0x03)
return KeyType::secp256k1;
}
else if (slice.size() == CRYPTO_PUBLICKEYBYTES)
{
return KeyType::dilithium;
}
return std::nullopt;
@@ -311,11 +295,6 @@ verify(
m.data(), m.size(), publicKey.data() + 1, sig.data()) ==
0;
}
else if (*type == KeyType::dilithium)
{
return crypto_sign_verify(
sig.data(), sig.size(), m.data(), m.size(), publicKey.data()) == 0;
}
}
return false;
}

View File

@@ -25,89 +25,26 @@
#include <ripple/protocol/SecretKey.h>
#include <ripple/protocol/digest.h>
#include <ripple/protocol/impl/secp256k1.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <ed25519.h>
#pragma push_macro("L")
#pragma push_macro("K")
#pragma push_macro("N")
#pragma push_macro("S")
#pragma push_macro("U")
#pragma push_macro("D")
#undef L
#undef K
#undef N
#undef S
#undef U
#undef D
extern "C" {
#include "api.h"
#include "fips202.h"
#include "packing.h"
#include "params.h"
#include "poly.h"
#include "polyvec.h"
#include "sign.h"
}
#include <iomanip>
#include <iostream>
#include <iterator>
#include <ostream>
#include <sstream>
#include <stdexcept>
// Define the dilithium functions and sizes with respect to functions named here
#ifndef CRYPTO_PUBLICKEYBYTES
#define CRYPTO_PUBLICKEYBYTES pqcrystals_dilithium2_PUBLICKEYBYTES
#endif
#ifndef CRYPTO_SECRETKEYBYTES
#define CRYPTO_SECRETKEYBYTES pqcrystals_dilithium2_SECRETKEYBYTES
#endif
#ifndef CRYPTO_BYTES
#define CRYPTO_BYTES pqcrystals_dilithium2_BYTES
#endif
#ifndef crypto_sign_keypair
#define crypto_sign_keypair pqcrystals_dilithium2_ref_keypair
#endif
#ifndef crypto_sign_signature
#define crypto_sign_signature pqcrystals_dilithium2_ref_signature
#endif
namespace ripple {
SecretKey::~SecretKey()
{
secure_erase(buf_, size_);
secure_erase(buf_, sizeof(buf_));
}
SecretKey::SecretKey(std::array<std::uint8_t, 32> const& key)
{
size_ = 32;
std::memcpy(buf_, key.data(), key.size());
}
SecretKey::SecretKey(std::array<std::uint8_t, 2528> const& key)
{
size_ = 2528;
std::memcpy(buf_, key.data(), key.size());
}
SecretKey::SecretKey(Slice const& slice)
{
if (slice.size() != 32 && slice.size() != 2528)
{
if (slice.size() != sizeof(buf_))
LogicError("SecretKey::SecretKey: invalid size");
}
size_ = slice.size();
std::memcpy(buf_, slice.data(), size_);
std::memcpy(buf_, slice.data(), sizeof(buf_));
}
std::string
@@ -297,18 +234,6 @@ signDigest(PublicKey const& pk, SecretKey const& sk, uint256 const& digest)
return Buffer{sig, len};
}
std::string
toHexString(const uint8_t* data, size_t length)
{
std::ostringstream oss;
for (size_t i = 0; i < length; ++i)
{
oss << std::uppercase << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(data[i]);
}
return oss.str();
}
Buffer
sign(PublicKey const& pk, SecretKey const& sk, Slice const& m)
{
@@ -344,13 +269,7 @@ sign(PublicKey const& pk, SecretKey const& sk, Slice const& m)
secp256k1Context(), sig, &len, &sig_imp) != 1)
LogicError(
"sign: secp256k1_ecdsa_signature_serialize_der failed");
return Buffer{sig, len};
}
case KeyType::dilithium: {
uint8_t sig[CRYPTO_BYTES];
size_t len;
crypto_sign_signature(sig, &len, m.data(), m.size(), sk.data());
return Buffer{sig, len};
}
default:
@@ -361,143 +280,11 @@ sign(PublicKey const& pk, SecretKey const& sk, Slice const& m)
SecretKey
randomSecretKey()
{
return randomSecretKey(KeyType::secp256k1);
}
SecretKey
randomSecretKey(KeyType type)
{
switch (type)
{
case KeyType::ed25519:
case KeyType::secp256k1: {
std::uint8_t buf[32];
beast::rngfill(buf, sizeof(buf), crypto_prng());
SecretKey sk(Slice{buf, sizeof(buf)});
secure_erase(buf, sizeof(buf));
return sk;
}
case KeyType::dilithium: {
uint8_t pk[CRYPTO_PUBLICKEYBYTES];
uint8_t buf[CRYPTO_SECRETKEYBYTES];
crypto_sign_keypair(pk, buf);
SecretKey sk(Slice{buf, CRYPTO_SECRETKEYBYTES});
secure_erase(buf, sizeof(buf));
return sk;
}
}
}
void
expand_mat(polyvecl mat[K], const uint8_t rho[SEEDBYTES])
{
unsigned int i, j;
uint16_t nonce;
for (i = 0; i < K; ++i)
{
for (j = 0; j < L; ++j)
{
nonce = (i << 8) + j; // Combine indices i and j into a nonce
poly_uniform(&mat[i].vec[j], rho, nonce);
}
}
}
int
pqcrystals_dilithium2_ref_keypair_seed(
uint8_t* pk,
uint8_t* sk,
const uint8_t* seed)
{
uint8_t seedbuf[3 * SEEDBYTES];
uint8_t tr[CRHBYTES];
const uint8_t* rho;
const uint8_t* rhoprime;
const uint8_t* key;
polyvecl mat[K], s1, s1hat;
polyveck t1, t0, s2;
unsigned int i;
/* Use the provided seed to generate rho, rhoprime, and key */
shake256(seedbuf, 3 * SEEDBYTES, seed, SEEDBYTES);
rho = seedbuf;
rhoprime = rho + SEEDBYTES;
key = rhoprime + SEEDBYTES;
/* Expand matrix */
expand_mat(mat, rho);
/* Sample short vectors s1 and s2 using rhoprime */
polyvecl_uniform_eta(&s1, rhoprime, 0);
polyveck_uniform_eta(&s2, rhoprime, L);
/* Compute t = As1 + s2 */
s1hat = s1;
polyvecl_ntt(&s1hat);
for (i = 0; i < K; ++i)
{
polyvecl_pointwise_acc_montgomery(&t1.vec[i], &mat[i], &s1hat);
poly_invntt_tomont(&t1.vec[i]);
}
polyveck_add(&t1, &t1, &s2);
/* Extract t1 and write public key */
polyveck_caddq(&t1);
polyveck_power2round(&t1, &t0, &t1);
pack_pk(pk, rho, &t1);
/* Hash rho and t1 to obtain tr */
uint8_t buf[CRYPTO_PUBLICKEYBYTES];
memcpy(buf, pk, CRYPTO_PUBLICKEYBYTES);
shake256(tr, CRHBYTES, buf, CRYPTO_PUBLICKEYBYTES);
/* Pack secret key */
pack_sk(sk, rho, tr, key, &t0, &s1, &s2);
/* Clean sensitive data */
secure_erase(seedbuf, sizeof(seedbuf));
secure_erase((void*)&s1, sizeof(s1));
secure_erase((void*)&s1hat, sizeof(s1hat));
secure_erase((void*)&s2, sizeof(s2));
secure_erase((void*)&t0, sizeof(t0));
secure_erase((void*)&t1, sizeof(t1));
return 0;
}
int
pqcrystals_dilithium2_ref_publickey(uint8_t* pk, const uint8_t* sk)
{
uint8_t seedbuf[3 * SEEDBYTES + 2 * CRHBYTES];
uint8_t *rho, *tr, *key;
polyvecl mat[K], s1, s1hat;
polyveck t0, t1, s2;
rho = seedbuf;
tr = rho + SEEDBYTES;
key = tr + SEEDBYTES;
unpack_sk(rho, tr, key, &t0, &s1, &s2, sk);
/* Expand matrix */
polyvec_matrix_expand(mat, rho);
/* Matrix-vector multiplication */
s1hat = s1;
polyvecl_ntt(&s1hat);
polyvec_matrix_pointwise_montgomery(&t1, mat, &s1hat);
polyveck_reduce(&t1);
polyveck_invntt_tomont(&t1);
/* Add error vector s2 */
polyveck_add(&t1, &t1, &s2);
/* Extract t1 and write public key */
polyveck_caddq(&t1);
polyveck_power2round(&t1, &t0, &t1);
pack_pk(pk, rho, &t1);
return 1;
std::uint8_t buf[32];
beast::rngfill(buf, sizeof(buf), crypto_prng());
SecretKey sk(Slice{buf, sizeof(buf)});
secure_erase(buf, sizeof(buf));
return sk;
}
SecretKey
@@ -519,17 +306,6 @@ generateSecretKey(KeyType type, Seed const& seed)
return sk;
}
if (type == KeyType::dilithium)
{
uint8_t pk[CRYPTO_PUBLICKEYBYTES];
uint8_t buf[CRYPTO_SECRETKEYBYTES];
auto key = sha512Half_s(Slice(seed.data(), seed.size()));
pqcrystals_dilithium2_ref_keypair_seed(pk, buf, key.data());
SecretKey sk{Slice{buf, CRYPTO_SECRETKEYBYTES}};
secure_erase(buf, CRYPTO_SECRETKEYBYTES);
return sk;
}
LogicError("generateSecretKey: unknown key type");
}
@@ -566,14 +342,6 @@ derivePublicKey(KeyType type, SecretKey const& sk)
ed25519_publickey(sk.data(), &buf[1]);
return PublicKey(Slice{buf, sizeof(buf)});
}
case KeyType::dilithium: {
uint8_t pk_data[CRYPTO_PUBLICKEYBYTES];
if (pqcrystals_dilithium2_ref_publickey(pk_data, sk.data()) != 1)
LogicError(
"derivePublicKey: secp256k1_ec_pubkey_serialize failed");
return PublicKey{Slice{pk_data, CRYPTO_PUBLICKEYBYTES}};
}
default:
LogicError("derivePublicKey: bad key type");
};
@@ -588,23 +356,18 @@ generateKeyPair(KeyType type, Seed const& seed)
detail::Generator g(seed);
return g(0);
}
default:
case KeyType::ed25519: {
auto const sk = generateSecretKey(type, seed);
return {derivePublicKey(type, sk), sk};
}
case KeyType::dilithium: {
auto const sk = generateSecretKey(type, seed);
return {derivePublicKey(type, sk), sk};
}
default:
throw std::invalid_argument("Unsupported key type");
}
}
std::pair<PublicKey, SecretKey>
randomKeyPair(KeyType type)
{
auto const sk = randomSecretKey(type);
auto const sk = randomSecretKey();
return {derivePublicKey(type, sk), sk};
}
@@ -615,16 +378,9 @@ parseBase58(TokenType type, std::string const& s)
auto const result = decodeBase58Token(s, type);
if (result.empty())
return std::nullopt;
if (result.size() != 32 && result.size() != 2528)
if (result.size() != 32)
return std::nullopt;
return SecretKey(makeSlice(result));
}
} // namespace ripple
#pragma pop_macro("K")
#pragma pop_macro("L")
#pragma pop_macro("N")
#pragma pop_macro("S")
#pragma pop_macro("U")
#pragma pop_macro("D")

View File

@@ -100,38 +100,10 @@ class Wildcard_test : public beast::unit_test::suite
}
}
void
testSimplePayment(FeatureBitset features)
{
using namespace test::jtx;
testcase("simple payment");
Env env{*this, envconfig(), features};
Account const alice{"alice"};
Account const bob{"bob"};
Account const carol{"carol"};
Account const dave{"dave", KeyType::dilithium};
env.fund(XRP(1000), alice, bob, carol, dave);
env.close();
env(fset(dave, asfForceQuantum));
env(pay(dave, bob, XRP(100)));
env.close();
Json::Value params;
params[jss::ledger_index] = env.current()->seq() - 1;
params[jss::transactions] = true;
params[jss::expand] = true;
auto const jrr = env.rpc("json", "ledger", to_string(params));
std::cout << jrr << std::endl;
}
void
testWithFeats(FeatureBitset features)
{
// testWildcardSign(features);
testSimplePayment(features);
testWildcardSign(features);
}
public:

View File

@@ -366,7 +366,7 @@ public:
std::array<PublicKey, 32> keys;
for (std::size_t i = 0; i != keys.size(); ++i)
keys[i] = derivePublicKey(keyType, randomSecretKey(keyType));
keys[i] = derivePublicKey(keyType, randomSecretKey());
for (std::size_t i = 0; i != keys.size(); ++i)
{
@@ -431,54 +431,6 @@ public:
}
testBase58(KeyType::ed25519);
// testcase("Base58: dilithium");
// {
// auto const pk1 = derivePublicKey(
// KeyType::dilithium,
// generateSecretKey(
// KeyType::dilithium, generateSeed("masterpassphrase")));
// auto const pk2 = parseBase58<PublicKey>(
// TokenType::NodePublic,
// "p9pow2SA5t1GpXJCZiWeWiKjZ4xav57jYgDzAhesVequQtwp2UMQ1ezUUE81t7"
// "QY7zyvWqsRCTuxDAyZikit8Qwrr3Gcq5nNdW9DzbqjiY18Ze5ZZCdpNmkcsye6"
// "MajNjTrjbr7VzcH2HksZnRB6gTiy8Ktm3s6jwU9wiDHo3kbZdY1UbV9MZXSweg"
// "abP9s1oFRMSCZ3UQJAPHBVeCyd9LCp4oV3kj3TVSo7VF8D5xzgwFvtiwXxcAae"
// "sKnG5u1NgyYPFNqXFZA48ezBjmsYTt5ZKcKcCShkKa5tN4dME4NCagDa9G8U24"
// "8HShgFkVHCwjpRcyAEPehN9TUowySQZZFNQu8887sQ1M22BJ6rmSkfLAbV6jpm"
// "HinSjURu67SZ1vvNm5rmEEcLvpMwHibwJQkurVD7LYXUJrL2uXUf5AiuZycJEi"
// "1XZcd6sQaNAp64FPecRzWMnLM9eqg2nJQGt9YP7Gv6S2JV5m3AULsebDDZ1hYR"
// "7CUNfAeo3Dj6SoatPJaqED5GfQK2Z451QHQr9FQXsLMJ9bfXhQDJJYTa3kKyo9"
// "1wtaZataHyhDaGpJ3WwuDV1adkfgcrMLbK52mi6Qqznm22WQRxVtp2heuEees9"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5fXgZ4NHfJb5hRwX95vg1WKXYMttHMBL6Zi7QEf"
// "9VSdrt2qTw3MTG3F4A3uxJhyapzv1XBfxdKUTRbEh3h59CTmxLZauPBKE2QW5a"
// "jDUwoZKv9cV6isLfNe49XYSWa4ger9X3Gfga8xxPrmaxnWeST2qjfUkhuqi44F"
// "v");
// BEAST_EXPECT(pk2);
// BEAST_EXPECT(pk1 == *pk2);
// }
// testBase58(KeyType::dilithium);
}
void

File diff suppressed because it is too large Load Diff

View File

@@ -220,135 +220,6 @@ public:
}
}
{
testcase("Node keypair generation & signing (dilithium)");
auto const secretKey = generateSecretKey(
KeyType::dilithium, generateSeed("masterpassphrase"));
auto const publicKey =
derivePublicKey(KeyType::dilithium, secretKey);
BEAST_EXPECT(
toBase58(TokenType::NodePublic, publicKey) ==
"p9pow2SA5t1GpXJCZiWeWiKjZ4xav57jYgDzAhesVequQtwp2UMQ1ezUUE81t7"
"QY7zyvWqsRCTuxDAyZikit8Qwrr3Gcq5nNdW9DzbqjiY18Ze5ZZCdpNmkcsye6"
"MajNjTrjbr7VzcH2HksZnRB6gTiy8Ktm3s6jwU9wiDHo3kbZdY1UbV9MZXSweg"
"abP9s1oFRMSCZ3UQJAPHBVeCyd9LCp4oV3kj3TVSo7VF8D5xzgwFvtiwXxcAae"
"sKnG5u1NgyYPFNqXFZA48ezBjmsYTt5ZKcKcCShkKa5tN4dME4NCagDa9G8U24"
"8HShgFkVHCwjpRcyAEPehN9TUowySQZZFNQu8887sQ1M22BJ6rmSkfLAbV6jpm"
"HinSjURu67SZ1vvNm5rmEEcLvpMwHibwJQkurVD7LYXUJrL2uXUf5AiuZycJEi"
"1XZcd6sQaNAp64FPecRzWMnLM9eqg2nJQGt9YP7Gv6S2JV5m3AULsebDDZ1hYR"
"7CUNfAeo3Dj6SoatPJaqED5GfQK2Z451QHQr9FQXsLMJ9bfXhQDJJYTa3kKyo9"
"1wtaZataHyhDaGpJ3WwuDV1adkfgcrMLbK52mi6Qqznm22WQRxVtp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yQQXsNQj2fcY5L6g"
"NMJFEQ3W62QNHYSkPUcUURRFYSxUsC4QHkahEz86U9FoNMyaHNE7Bi1ufq3kcz"
"fToAkPPkdr5Tg5uXo3BkNbDnFtQWP2UywLCrrxi29yucB8zfq27QA1ATBHKVFG"
"15sgjksNL3AfgZRoDE2n7TeG3jXvMfHiWevaExkS1Gsht6QJXaVX3NaQMd9Uy4"
"vqWdyTucNcRLZzrfgzmyvLzbRfBzPGLHdTJxLvB9c4VNhQLSdCDJQHZ8TqxGhH"
"u5dw1owkV7DjcBxyKLUM86mPG8wVDmkV34bckE6VBcfoERcQsAuQCsF8n34HVu"
"usxziQgPJ2rYM2Gi9wNdmrBUoq6WiYzRtuG4GSLxV3KoZipYTa4gmLyhFQhaUr"
"QfxvjFnSVbTqwvgxX6bt1Uo3jYpqzYieu6EBmUWbo4GpXkzcnAK6rymz3F3fka"
"x2V9LnWMnYjfayq8YsCVmxVCPMbVyB5xS2LWqFaUqdxFDvDD6quBGeL4YP9oGL"
"sR1TdLRCRqVhD5YcC5nALXhXbwmfqfyMLLsYFsYidEHdzeATF");
BEAST_EXPECT(
to_string(calcNodeID(publicKey)) ==
"8A94F2BC52E94646EC83CD988657FE37A9D5CDB5");
auto sig = sign(publicKey, secretKey, makeSlice(message1));
BEAST_EXPECT(sig.size() != 0);
BEAST_EXPECT(verify(publicKey, makeSlice(message1), sig));
// Correct public key but wrong message
BEAST_EXPECT(!verify(publicKey, makeSlice(message2), sig));
// Verify with incorrect public key
{
auto const otherPublicKey = derivePublicKey(
KeyType::ed25519,
generateSecretKey(
KeyType::ed25519, generateSeed("otherpassphrase")));
BEAST_EXPECT(!verify(otherPublicKey, makeSlice(message1), sig));
}
// Correct public key but wrong signature
{
// Slightly change the signature:
if (auto ptr = sig.data())
ptr[sig.size() / 2]++;
BEAST_EXPECT(!verify(publicKey, makeSlice(message1), sig));
}
}
{
testcase("Account keypair generation & signing (secp256k1)");
@@ -432,132 +303,6 @@ public:
BEAST_EXPECT(!verify(pk, makeSlice(message1), sig));
}
}
{
testcase("Account keypair generation & signing (dilithium)");
auto const [pk, sk] = generateKeyPair(
KeyType::dilithium, generateSeed("masterpassphrase"));
BEAST_EXPECT(
to_string(calcAccountID(pk)) ==
"rDdkg2HADzqCh6s6CyZ53ExSQ3fRMEycuV");
BEAST_EXPECT(
toBase58(TokenType::AccountPublic, pk) ==
"pRUFoiSyVkDrDDrZekFKmqdYfDznimyyHb6XzWVPRqgpniKgQeNKenTpvr3Y4V"
"Sbdx2rSdUzi52f4wnQ9UqctLsuP7VzpmLcj5gSnzZC4rSu4QNmEDtYxUswp3d9"
"7UiDdbUjWikPHrWmuyi8n1VpmbwHKWmXppKuxNLDLX73cP8MBGTmP5JdcrFrtm"
"kNMxp9Q81GbyvseaVHPYexjzpHwt6zm2og4hCNegehnBNqcDJcyRyh39cCkKao"
"Y1MK5iAhEXpXAwc8Wf9bVTouA15pbCmz7GL8SXFNmHD7xJRxbTmSpMAZSuhE6Y"
"e9dZAeAeJNpcjsmFWUuz8yhuH5s9PE9idKERYrLExV1FXTDhDA6F2ZR5duff2Z"
"aveYacowDHtQya3gErmq5ccJqZVFu2qWM5gwUrJ1BLD85jWeL25aMW1U6YDvJz"
"V4cvzo2oHdnS6wQMwN3vH56QEKta19BoGkntYhyUZipx7e1Nhp5NNccSCqR4uB"
"LB2dAgteUcCvwvkXFwy91xhGa7WqDRBzCVnEDVzaEZY1P4MjN1iguvtPhUXY8R"
"7drgMYzPUZr5yik6DKRnNS1Ub9aaxfvj8NCQWcUXbSQsFkN5AJYbrkLW7kAjVm"
"J1xuY9E2L8vFKfywJ4Dy6dkZ7raetT1BEQWKtCa2pP8Hq3nCjJdpjS9VM3CtgN"
"doxEg1tnd5G3qk658UGPb3hLkushX4q5nNuB9oXtfey3fPNguYSKqcusQqSw6y"
"2DqN91Bu6Q15PCgaCjrCBjRFCqVxsiybj6SVNDCcUEVD9JXVKCCA3ZijKdvEmJ"
"ESwLJe7qd7hmKuiMWy3yUqt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qxx6oPn5G7"
"riMYCohgBWVXHcv9qWDaUQAhaJjK8ES7nTuAdo7cQ7XY78KWDc1WgiHojAxC8a"
"tVVspKHFY98HM7rvmzsydMRhFPYaFBhVctLzvg6ok6enMyU9TyjVfEbWRXV3J5"
"JMGqkABYnx6nriz9YFRDuQh6fwof4KUyjpUXk5eGPxtGAYSAqbNNFpDAmf6n8h"
"ybHqHGYV1rGeC9dVdGwgzHNjbgrUkDSx6vTHCWP8kvfMMtHtmGxuRCcPCz88yU"
"LNYo6YSHBp1LKfFBcZiCA45DLac4L69SHeueLdJKZrCHBAwg3Df6J7dDhbzCHK"
"SUqMDaZzaNTynHcLK79Jya86dLuzKh5Mk2qEoFysGRSr2MhsP");
auto sig = sign(pk, sk, makeSlice(message1));
BEAST_EXPECT(sig.size() != 0);
BEAST_EXPECT(verify(pk, makeSlice(message1), sig));
// Correct public key but wrong message
BEAST_EXPECT(!verify(pk, makeSlice(message2), sig));
// Verify with incorrect public key
{
auto const otherKeyPair = generateKeyPair(
KeyType::ed25519, generateSeed("otherpassphrase"));
BEAST_EXPECT(
!verify(otherKeyPair.first, makeSlice(message1), sig));
}
// Correct public key but wrong signature
{
// Slightly change the signature:
if (auto ptr = sig.data())
ptr[sig.size() / 2]++;
BEAST_EXPECT(!verify(pk, makeSlice(message1), sig));
}
}
}
void