Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificate generation and validation #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/common/sv2_noise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ uint256 Sv2SignatureNoiseMessage::GetHash()
ss << m_version
<< m_valid_from
<< m_valid_to
// TODO: Stratum v2 spec requires signing the static key, but SRI currently
// implements this incorrectly.
// << m_static_key
<< m_static_key
;

CSHA256 hasher;
Expand Down
3 changes: 0 additions & 3 deletions src/node/sv2_template_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ Sv2TemplateProvider::Sv2TemplateProvider(ChainstateManager& chainman, CTxMemPool
// Start validity a little bit in the past to account for clock difference
uint32_t valid_from = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(epoch_now).count()) - 3600;
uint32_t valid_to = std::numeric_limits<unsigned int>::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);

// TODO: get rid of Init() ???
Expand Down
7 changes: 0 additions & 7 deletions src/test/sv2_noise_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ BOOST_AUTO_TEST_CASE(certificate_test)
uint32_t valid_from = now;
uint32_t valid_to = std::numeric_limits<unsigned int>::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);

Expand Down Expand Up @@ -117,9 +113,6 @@ BOOST_AUTO_TEST_CASE(handshake_and_transport_test)
uint32_t valid_from = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(epoch_now).count());
uint32_t valid_to = std::numeric_limits<unsigned int>::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);

Expand Down
3 changes: 0 additions & 3 deletions src/test/sv2_template_provider_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ BOOST_AUTO_TEST_CASE(Sv2TemplateProvider_Connection_test)
uint32_t valid_from = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(epoch_now).count());
uint32_t valid_to = std::numeric_limits<unsigned int>::max();

// TODO: Stratum v2 spec requires signing the static key using the authority key,
// but SRI currently implements this incorrectly.
authority_key = static_key;
auto certificate = Sv2SignatureNoiseMessage(version, valid_from, valid_to,
XOnlyPubKey(static_key.GetPubKey()), authority_key);

Expand Down
3 changes: 0 additions & 3 deletions src/test/sv2_transport_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class Sv2TransportTester
uint32_t valid_from = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(epoch_now).count());
uint32_t valid_to = std::numeric_limits<unsigned int>::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);

Expand Down