From 9fecb09f92bcc030b5ed2b75748f4328d915c704 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Mon, 5 Feb 2024 11:19:53 +0100 Subject: [PATCH] Temporarily break certificate generation and validation Pending: https://github.com/stratum-mining/stratum/issues/717 --- src/common/sv2_noise.cpp | 6 ++++-- src/node/sv2_template_provider.cpp | 3 +++ src/test/sv2_noise_tests.cpp | 7 +++++++ src/test/sv2_transport_tests.cpp | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/sv2_noise.cpp b/src/common/sv2_noise.cpp index 4d35df04ed5f33..3bc3e610e2e1ed 100644 --- a/src/common/sv2_noise.cpp +++ b/src/common/sv2_noise.cpp @@ -21,8 +21,10 @@ uint256 Sv2SignatureNoiseMessage::GetHash() DataStream ss{}; ss << m_version << m_valid_from - << m_valid_to - << m_static_key; + << m_valid_to; + // TODO: Stratum v2 spec requires signing the static key, but SRI currently + // implements this incorrectly. + // << m_static_key; LogTrace(BCLog::SV2, "Certificate hashed data: %s\n", HexStr(ss)); diff --git a/src/node/sv2_template_provider.cpp b/src/node/sv2_template_provider.cpp index 8cf82c4cb365f0..1ddf34c79e3cd3 100644 --- a/src/node/sv2_template_provider.cpp +++ b/src/node/sv2_template_provider.cpp @@ -81,6 +81,9 @@ Sv2TemplateProvider::Sv2TemplateProvider(ChainstateManager& chainman, CTxMemPool // Start validity a little bit in the past to account for clock difference uint32_t valid_from = static_cast(std::chrono::duration_cast(now).count()) - 3600; uint32_t valid_to = std::numeric_limits::max(); // 2106 + // TODO: Stratum v2 spec requires signing the static key using the authority key, + // but SRI currently implements this incorrectly. + authority_key = m_static_key; m_certificate = Sv2SignatureNoiseMessage(version, valid_from, valid_to, XOnlyPubKey(m_static_key.GetPubKey()), authority_key); m_authority_pubkey = XOnlyPubKey(authority_key.GetPubKey()); diff --git a/src/test/sv2_noise_tests.cpp b/src/test/sv2_noise_tests.cpp index 4998e6acb3f1f2..080e6eb2a19617 100644 --- a/src/test/sv2_noise_tests.cpp +++ b/src/test/sv2_noise_tests.cpp @@ -43,6 +43,10 @@ BOOST_AUTO_TEST_CASE(certificate_test) uint32_t valid_from = now; uint32_t valid_to = std::numeric_limits::max(); + // TODO: Stratum v2 spec requires signing the static key using the authority key, + // but SRI currently implements this incorrectly. + alice_authority_key = alice_static_key; + auto alice_certificate = Sv2SignatureNoiseMessage(version, valid_from, valid_to, XOnlyPubKey(alice_static_key.GetPubKey()), alice_authority_key); @@ -88,6 +92,9 @@ BOOST_AUTO_TEST_CASE(handshake_and_transport_test) uint32_t valid_from = static_cast(std::chrono::duration_cast(epoch_now).count()); uint32_t valid_to = std::numeric_limits::max(); + // TODO: Stratum v2 spec requires signing the static key using the authority key, + // but SRI currently implements this incorrectly. + bob_authority_key = bob_static_key; auto bob_certificate = Sv2SignatureNoiseMessage(version, valid_from, valid_to, XOnlyPubKey(bob_static_key.GetPubKey()), bob_authority_key); diff --git a/src/test/sv2_transport_tests.cpp b/src/test/sv2_transport_tests.cpp index f6f672cc77dcfa..96c59e2d2da852 100644 --- a/src/test/sv2_transport_tests.cpp +++ b/src/test/sv2_transport_tests.cpp @@ -64,6 +64,9 @@ class Sv2TransportTester uint32_t valid_from = static_cast(std::chrono::duration_cast(epoch_now).count()); uint32_t valid_to = std::numeric_limits::max(); + // TODO: Stratum v2 spec requires signing the static key using the authority key, + // but SRI currently implements this incorrectly. + responder_authority_key = responder_static_key; auto responder_certificate = Sv2SignatureNoiseMessage(version, valid_from, valid_to, XOnlyPubKey(responder_static_key.GetPubKey()), responder_authority_key);