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

New noise and framing DO NOT MERGE UNTIL TP IMPLEMENT IT #601

Merged
merged 21 commits into from
Oct 13, 2023

Conversation

Fi3
Copy link
Collaborator

@Fi3 Fi3 commented Jul 27, 2023

No description provided.

@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Attention: 268 lines in your changes are missing coverage. Please review.

Comparison is base (84744a3) 40.28% compared to head (d464344) 40.65%.
Report is 270 commits behind head on dev.

❗ Current head d464344 differs from pull request most recent head 261fae8. Consider uploading reports for the commit 261fae8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #601      +/-   ##
==========================================
+ Coverage   40.28%   40.65%   +0.36%     
==========================================
  Files         152      156       +4     
  Lines       14535    14588      +53     
==========================================
+ Hits         5856     5931      +75     
+ Misses       8679     8657      -22     
Files Coverage Δ
...tocols/v2/binary-sv2/no-serde-sv2/codec/src/lib.rs 8.16% <ø> (ø)
protocols/v2/framing-sv2/src/error.rs 0.00% <ø> (ø)
roles/jd-client/src/downstream.rs 71.16% <100.00%> (+0.15%) ⬆️
roles/jd-client/src/job_declarator/mod.rs 72.96% <100.00%> (+0.35%) ⬆️
roles/jd-client/src/main.rs 79.12% <100.00%> (-0.56%) ⬇️
roles/jd-client/src/proxy_config.rs 100.00% <ø> (ø)
roles/jd-client/src/upstream_sv2/upstream.rs 54.50% <100.00%> (+0.32%) ⬆️
roles/jd-server/src/lib/job_declarator/mod.rs 93.93% <100.00%> (-0.23%) ⬇️
roles/jd-server/src/main.rs 67.76% <ø> (ø)
roles/pool/src/main.rs 87.68% <ø> (ø)
... and 26 more

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

All the type that implement utils/buffer::Buffer now also implement aead::Buffer so that if a type
is Buffer now can be passeed to aead::AeadInPlace::decrypt_in_place and aead::AeadInPlace::encrypt_in_place
The new noise protocol used by SRI deprecate elliptic curve signing algorithm and replace it with
secp256k1, so that can be compatible with bitcoind. Key utils will replace noise_sv1::formats, and
can be used to serialize and deserialize secp256k1 keypairs in base58. It can also be used as an
utility to generate a random keypair.
Updated the SRI encryption and authentication algoritm with a different
flavore of noise. It:
* replace enterly the noise_sv2 crate
* update codec_sv2 to use the new noise and remove the possibility to
  have fragmented noise frames (now a sv2 frame can not be split between
  more sv2 frame that means that sv2 frame max size is 2^24)
* update netwrok_helpers to use the new noise, and improve it that
  change the library API so all the roles need to be updated
* update all the examples, tests and roles to use the improved netwrok_helpers
* update the MG to use the improved netwrok_helpers
* updated all the test and config file to use the new format for private
  and public keys.
New Sv2 framing consists of two or more encrypted messages. The first message
is the encrypted header, while the others are payload chunks, each split into
65,535-byte segments and encrypted. To build a buffer that can be deserialized
into an Sv2 message (header + payload), we need to call the decrypt function at
least twice on the same buffer: first for the header and then for the payload
chunks.

When passing a buffer to the decrypt function, it will attempt to decrypt the
entire buffer starting from the first byte. This behavior is correct only when
decrypting the header. In other cases, we need to "trick" the decrypt function
by making it see a buffer that starts from an index other than 0. For this, the
`danger_set_start` function is used.

Note: This function is currently unreliable and should be used with caution for
the following reasons:
1. It has not been fuzz-tested yet.
2. Users must remember to call `danger_set_start(0)` after decryption is
   complete.
3. While it works as expected with `as_ref` and `as_mut` methods, other
   specific methods still see the buffer starting at index 0.
@Fi3 Fi3 merged commit d8569d1 into stratum-mining:dev Oct 13, 2023
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants