crypto: split wire serialization in header
What changed, and why it matters
This commit is a routine code cleanup: it moves some serialization declarations out of a core cryptographic header file into a new dedicated header. There is no indication this fixes a security bug or changes how data is actually processed; it only reorganizes where certain type definitions live to make the codebase easier to maintain.
No security action required; treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change splits wire-serialization traits for crypto::hash, crypto::hash8, and crypto::ec_point from src/crypto/hash.h and crypto.h into a new src/crypto/wire.h. It removes includes of span.h and serialization/wire/traits.h from the crypto headers and adds the new wire.h include in the two translation units that need it (cryptonote_tx_utils.cpp and zmq_pub.cpp). This is a pure refactoring/reorganization with no functional change visible in the diff.
Changed components
src/crypto/hash.hsrc/crypto/crypto.hsrc/crypto/wire.hsrc/cryptonote_core/cryptonote_tx_utils.cppsrc/rpc/zmq_pub.cppcontrib/epee/include/serialization/wire/traits.hInspect captured patch +44 / −10
diff --git a/contrib/epee/include/serialization/wire/traits.h b/contrib/epee/include/serialization/wire/traits.h
index 834be2f..524decd 100644
--- a/contrib/epee/include/serialization/wire/traits.h
+++ b/contrib/epee/include/serialization/wire/traits.h
@@ -27,7 +27,7 @@
#pragma once
-#include <cstdint>
+#include <cstddef>
#include <type_traits>
#define WIRE_DECLARE_BLOB_NS(type) \
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index 01def5d..1145192 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -42,7 +42,6 @@
#include "mlocker.h"
#include "generic-ops.h"
#include "hex.h"
-#include "span.h"
#include "hash.h"
namespace crypto {
diff --git a/src/crypto/hash.h b/src/crypto/hash.h
index b8067f2..2c75462 100644
--- a/src/crypto/hash.h
+++ b/src/crypto/hash.h
@@ -37,8 +37,6 @@
#include "common/pod-class.h"
#include "generic-ops.h"
#include "hex.h"
-#include "span.h"
-#include "serialization/wire/traits.h"
namespace crypto {
@@ -109,9 +107,3 @@ namespace crypto {
CRYPTO_MAKE_HASHABLE(hash)
CRYPTO_MAKE_COMPARABLE(hash8)
-
-namespace wire
-{
- WIRE_DECLARE_BLOB_NS(crypto::hash);
- WIRE_DECLARE_BLOB_NS(crypto::hash8);
-}
diff --git a/src/crypto/wire.h b/src/crypto/wire.h
new file mode 100644
index 0000000..a606a52
--- /dev/null
+++ b/src/crypto/wire.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2026, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#pragma once
+
+#include "crypto.h"
+#include "serialization/wire/traits.h"
+
+namespace wire
+{
+ WIRE_DECLARE_BLOB_NS(crypto::hash);
+ WIRE_DECLARE_BLOB_NS(crypto::hash8);
+ WIRE_DECLARE_BLOB_NS(crypto::ec_point);
+}
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 52f05dd..b84e946 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -44,6 +44,7 @@ using namespace epee;
#include "cryptonote_basic/tx_extra.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
+#include "crypto/wire.h"
#include "ringct/rctSigs.h"
#include "serialization/wire.h"
diff --git a/src/rpc/zmq_pub.cpp b/src/rpc/zmq_pub.cpp
index b045bf1..30a9ae9 100644
--- a/src/rpc/zmq_pub.cpp
+++ b/src/rpc/zmq_pub.cpp
@@ -45,6 +45,7 @@
#include "common/expect.h"
#include "crypto/crypto.h"
+#include "crypto/wire.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/events.h"
#include "misc_log_ex.h"
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.