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

Propose an implementation of noise_sv2 with optional no_std #1238

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Georges760
Copy link

@Georges760 Georges760 commented Oct 29, 2024

Following @rrybarczyk comment on #1130.

Some equivalent conversion have been done (does not change any functionality, just using the no_std equivalents) :

  • std::ptr -> core::ptr
  • std::boxed::Box -> alloc::boxed::Box
  • std::vec::Vec -> alloc::vec::Vec
  • std::string::{String, ToString} -> alloc::string::{String, ToString}
  • std::convert::TryInto -> core::convert::TryInto
  • std::fmt::{Debug, Formatter, Result} -> core::fmt::{Debug, Formatter, Result}
  • std::time::Duration -> core::time::Duration

To have a no-std version, the --no-default-features must be used.

Current public API (std dependant) is unchanged.
Additional public API for no_std compliance is available using the *_with_rng and *_with_now suffix, and the corresponding arguments. This delegate the choice of the Ramdom Number Generator and the current System Time to the caller, instead of assuming using the ones from std.

  • Initiator::new_with_rng(), Initiator::from_raw_k_with_rng(), Initiator::without_pk_with_rng(), Responder::new_with_rng(), Responder::from_authority_kp_with_rng() and Responder::generate_key_with_rng() take an additional argument: rng implementing rand::Rng + ?Sized
  • SignatureNoiseMessage::sign_with_rng() take an additional argument: rng implementing rand::Rng + rand::CryptoRng
  • Initiator::step_2_with_now() and SignatureNoiseMessage::verify_with_now() take an additional argument: now for the current system time epoch
  • Responder::step_1()_with_now_rng take two additional arguments: rng implementing rand::Rng + rand::CryptoRng and now for the current system time epoch

@Georges760 Georges760 marked this pull request as draft October 29, 2024 10:41
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 63.15789% with 14 lines in your changes missing coverage. Please review.

Project coverage is 19.27%. Comparing base (dbc349b) to head (26f8be3).

Files with missing lines Patch % Lines
protocols/v2/noise-sv2/src/initiator.rs 50.00% 7 Missing ⚠️
protocols/v2/noise-sv2/src/responder.rs 58.82% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1238      +/-   ##
==========================================
- Coverage   19.30%   19.27%   -0.04%     
==========================================
  Files         164      164              
  Lines       10853    10913      +60     
==========================================
+ Hits         2095     2103       +8     
- Misses       8758     8810      +52     
Flag Coverage Δ
binary_codec_sv2-coverage 0.00% <0.00%> (ø)
binary_serde_sv2-coverage 3.56% <0.00%> (-0.09%) ⬇️
binary_sv2-coverage 5.36% <0.00%> (-0.13%) ⬇️
bip32_derivation-coverage 0.00% <ø> (ø)
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <0.00%> (?)
common_messages_sv2-coverage 0.13% <0.00%> (-0.01%) ⬇️
const_sv2-coverage 0.00% <0.00%> (ø)
error_handling-coverage 0.00% <ø> (ø)
framing_sv2-coverage ?
jd_client-coverage 0.00% <ø> (ø)
jd_server-coverage 7.79% <ø> (ø)
job_declaration_sv2-coverage 0.00% <0.00%> (ø)
key-utils-coverage 2.39% <ø> (ø)
mining-coverage 2.45% <0.00%> (-0.06%) ⬇️
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage ?
pool_sv2-coverage 1.38% <ø> (ø)
protocols 24.63% <63.15%> (-0.11%) ⬇️
roles 6.54% <ø> (ø)
roles_logic_sv2-coverage 7.95% <0.00%> (-0.17%) ⬇️
sv2_ffi-coverage 0.00% <0.00%> (ø)
template_distribution_sv2-coverage 0.00% <0.00%> (ø)
translator_sv2-coverage 9.60% <ø> (ø)
utils ?
v1-coverage 2.42% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@Sjors
Copy link
Collaborator

Sjors commented Dec 6, 2024

Is it possible to run tests on both the regular and no_std build?

@Georges760
Copy link
Author

Georges760 commented Dec 6, 2024

Is it possible to run tests on both the regular and no_std build?

#![no_std] for noise_sv2 (this PR) is a proposal currently, because it require to break its API, so I am waiting for @Shourya742 review of the new proposed API (maybe need to be improved/extended/simplified/etc), then I will work on adapting all depending crate to the new API.

At the end there will not be such a 'std' version of noise_sv2, it will be no_std by nature, which means not dependant to std.

And usage (test included) will have to provide a System Time and a Random Number Generator to the crate, they can comme from std (currently the 'enforced' case), or from a dedicated Hardware (often the case in embedded system aka no_std).
In tests, I will be able to provide them from std, to have the current state, or from a mocked embedded provider to simulat real HW.

@Sjors
Copy link
Collaborator

Sjors commented Dec 6, 2024

I see. But I wonder if it's possible & safer to keep two versions, because IIUC no_std misses various safety features.

https://docs.rust-embedded.org/book/intro/no-std.html

@Georges760
Copy link
Author

Georges760 commented Dec 6, 2024

I see. But I wonder if it's possible & safer to keep two versions, because IIUC no_std misses various safety features.

https://docs.rust-embedded.org/book/intro/no-std.html

I see, you refer to stack overflow protection missing in no_std, I didn't know that, thanks to point it to me.

A double API conditioned by the std feature ? yeah why not ! I will push that this weekend.

@Georges760
Copy link
Author

After reflexion, I think that a #![no_std] lib crate still does not enforce the main crate (the one choosing to link against std or not) so stack overflow protection is only lost if and only if the main crate choose to be #![no_std] (real embedded system).

If the main crate is std aware, even if it use some #![no_std] lib as dep, it will profit from the std security features.

handshake example is a good exemple of a 'main' std crate (using std::rand and std::time) using a #![no_std] lib dep (noise_sv2) and providing the Random Number Generator and System Time (of std) through the lib API so the lib does require std itself.

Breaking the API is a problem for std enviroement, and I fully agree it should be broken. So I will push this dual API (std unchanged, no_std new) according to a std feature enabled by default, in order to keep backward compat.

Copy link
Contributor

github-actions bot commented Dec 7, 2024

🐰 Bencher Report

Branchnoise_sv2_no_std
Testbedsv1
Click to view all benchmark results
BenchmarkEstimated CyclesBenchmark Result
1e3 x estimated cycles
(Result Δ%)
Upper Boundary
1e3 x estimated cycles
(Limit %)
InstructionsBenchmark Result
1e3 x instructions
(Result Δ%)
Upper Boundary
1e3 x instructions
(Limit %)
L1 AccessesBenchmark Result
1e3 x accesses
(Result Δ%)
Upper Boundary
1e3 x accesses
(Limit %)
L2 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
RAM AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
get_authorize📈 view plot
🚷 view threshold
8.39
(-0.79%)
8.67
(96.71%)
📈 view plot
🚷 view threshold
3.69
(-0.97%)
3.86
(95.54%)
📈 view plot
🚷 view threshold
5.16
(-1.10%)
5.45
(94.70%)
📈 view plot
🚷 view threshold
9.00
(+6.57%)
16.24
(55.41%)
📈 view plot
🚷 view threshold
91.00
(-0.38%)
96.69
(94.12%)
get_submit📈 view plot
🚷 view threshold
95.19
(-0.18%)
95.61
(99.56%)
📈 view plot
🚷 view threshold
59.35
(-0.10%)
59.71
(99.40%)
📈 view plot
🚷 view threshold
85.22
(-0.10%)
85.82
(99.31%)
📈 view plot
🚷 view threshold
47.00
(+5.17%)
60.20
(78.08%)
📈 view plot
🚷 view threshold
278.00
(-0.94%)
291.58
(95.34%)
get_subscribe📈 view plot
🚷 view threshold
7.87
(-1.58%)
8.23
(95.59%)
📈 view plot
🚷 view threshold
2.77
(-1.69%)
2.94
(93.96%)
📈 view plot
🚷 view threshold
3.85
(-1.93%)
4.14
(92.89%)
📈 view plot
🚷 view threshold
13.00
(+4.07%)
20.65
(62.95%)
📈 view plot
🚷 view threshold
113.00
(-1.32%)
117.91
(95.84%)
serialize_authorize📈 view plot
🚷 view threshold
12.11
(-1.21%)
12.51
(96.82%)
📈 view plot
🚷 view threshold
5.27
(-0.61%)
5.43
(97.06%)
📈 view plot
🚷 view threshold
7.33
(-0.70%)
7.60
(96.41%)
📈 view plot
🚷 view threshold
11.00
(+7.81%)
18.80
(58.50%)
📈 view plot
🚷 view threshold
135.00
(-2.10%)
143.14
(94.31%)
serialize_deserialize_authorize📈 view plot
🚷 view threshold
24.67
(-0.18%)
25.19
(97.95%)
📈 view plot
🚷 view threshold
9.84
(-0.20%)
10.01
(98.29%)
📈 view plot
🚷 view threshold
13.88
(-0.25%)
14.17
(97.90%)
📈 view plot
🚷 view threshold
38.00
(+5.65%)
45.96
(82.69%)
📈 view plot
🚷 view threshold
303.00
(-0.18%)
313.43
(96.67%)
serialize_deserialize_handle_authorize📈 view plot
🚷 view threshold
30.14
(-0.60%)
30.73
(98.09%)
📈 view plot
🚷 view threshold
12.02
(-0.29%)
12.18
(98.61%)
📈 view plot
🚷 view threshold
17.00
(-0.35%)
17.29
(98.30%)
📈 view plot
🚷 view threshold
59.00
(+5.59%)
67.60
(87.27%)
📈 view plot
🚷 view threshold
367.00
(-1.07%)
379.32
(96.75%)
serialize_deserialize_handle_submit📈 view plot
🚷 view threshold
126.28
(-0.14%)
126.78
(99.60%)
📈 view plot
🚷 view threshold
73.20
(-0.07%)
73.53
(99.55%)
📈 view plot
🚷 view threshold
104.91
(-0.09%)
105.50
(99.43%)
📈 view plot
🚷 view threshold
116.00
(+8.74%)
125.97
(92.08%)
📈 view plot
🚷 view threshold
594.00
(-0.61%)
610.08
(97.36%)
serialize_deserialize_handle_subscribe📈 view plot
🚷 view threshold
27.73
(-0.65%)
28.39
(97.68%)
📈 view plot
🚷 view threshold
9.58
(-0.49%)
9.76
(98.20%)
📈 view plot
🚷 view threshold
13.54
(-0.56%)
13.84
(97.84%)
📈 view plot
🚷 view threshold
66.00
(+2.20%)
78.05
(84.57%)
📈 view plot
🚷 view threshold
396.00
(-0.81%)
409.70
(96.66%)
serialize_deserialize_submit📈 view plot
🚷 view threshold
115.18
(-0.06%)
115.71
(99.54%)
📈 view plot
🚷 view threshold
68.06
(+0.00%)
68.42
(99.47%)
📈 view plot
🚷 view threshold
97.65
(-0.00%)
98.29
(99.35%)
📈 view plot
🚷 view threshold
69.00
(+5.48%)
87.37
(78.98%)
📈 view plot
🚷 view threshold
491.00
(-0.46%)
504.55
(97.31%)
serialize_deserialize_subscribe📈 view plot
🚷 view threshold
23.21
(-0.51%)
23.82
(97.43%)
📈 view plot
🚷 view threshold
8.14
(-0.52%)
8.32
(97.92%)
📈 view plot
🚷 view threshold
11.45
(-0.61%)
11.75
(97.49%)
📈 view plot
🚷 view threshold
41.00
(+5.21%)
50.99
(80.41%)
📈 view plot
🚷 view threshold
330.00
(-0.49%)
342.33
(96.40%)
serialize_submit📈 view plot
🚷 view threshold
99.57
(-0.21%)
100.09
(99.48%)
📈 view plot
🚷 view threshold
61.41
(-0.08%)
61.73
(99.47%)
📈 view plot
🚷 view threshold
88.08
(-0.09%)
88.65
(99.37%)
📈 view plot
🚷 view threshold
51.00
(+6.08%)
66.79
(76.36%)
📈 view plot
🚷 view threshold
321.00
(-1.33%)
337.26
(95.18%)
serialize_subscribe📈 view plot
🚷 view threshold
11.31
(-0.75%)
11.60
(97.55%)
📈 view plot
🚷 view threshold
4.12
(-1.06%)
4.28
(96.15%)
📈 view plot
🚷 view threshold
5.71
(-1.27%)
6.00
(95.18%)
📈 view plot
🚷 view threshold
15.00
(+8.05%)
24.04
(62.38%)
📈 view plot
🚷 view threshold
158.00
(-0.31%)
164.41
(96.10%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Dec 7, 2024

🐰 Bencher Report

Branchnoise_sv2_no_std
Testbedsv1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
client-submit-serialize📈 view plot
🚷 view threshold
6,437.20
(-1.79%)
6,930.59
(92.88%)
client-submit-serialize-deserialize📈 view plot
🚷 view threshold
7,394.60
(-0.14%)
7,819.54
(94.57%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle📈 view plot
🚷 view threshold
7,947.90
(-1.85%)
9,444.59
(84.15%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle📈 view plot
🚷 view threshold
882.72
(+1.73%)
944.59
(93.45%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize📈 view plot
🚷 view threshold
691.62
(+2.37%)
721.45
(95.87%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize📈 view plot
🚷 view threshold
247.95
(-0.88%)
274.93
(90.19%)
client-sv1-get-authorize/client-sv1-get-authorize📈 view plot
🚷 view threshold
157.69
(+0.13%)
165.61
(95.22%)
client-sv1-get-submit📈 view plot
🚷 view threshold
6,234.20
(-1.69%)
6,800.72
(91.67%)
client-sv1-get-subscribe/client-sv1-get-subscribe📈 view plot
🚷 view threshold
271.63
(-3.80%)
330.17
(82.27%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle📈 view plot
🚷 view threshold
719.80
(-1.12%)
780.54
(92.22%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize📈 view plot
🚷 view threshold
597.43
(+1.01%)
630.25
(94.79%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize📈 view plot
🚷 view threshold
203.68
(-1.44%)
226.97
(89.74%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Dec 7, 2024

🐰 Bencher Report

Branchnoise_sv2_no_std
Testbedsv2
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
client_sv2_handle_message_common📈 view plot
🚷 view threshold
44.57
(-1.55%)
60.46
(73.72%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
75.60
(-2.59%)
108.35
(69.77%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
14.68
(+0.09%)
14.73
(99.68%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
250.71
(-5.07%)
289.43
(86.62%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
621.25
(+0.76%)
658.94
(94.28%)
client_sv2_open_channel📈 view plot
🚷 view threshold
174.83
(+5.03%)
182.11
(96.00%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
277.70
(-2.88%)
316.55
(87.73%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
392.06
(+2.41%)
403.50
(97.16%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
168.58
(+5.14%)
174.00
(96.88%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
462.01
(-1.59%)
558.87
(82.67%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
995.16
(-0.92%)
1,214.61
(81.93%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Dec 7, 2024

🐰 Bencher Report

Branchnoise_sv2_no_std
Testbedsv2

🚨 1 Alert

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
client_sv2_handle_message_miningL2 Accesses
accesses
📈 plot
🚨 alert (🔔)
🚷 threshold
43.00
(+20.68%)
42.02
(102.34%)
Click to view all benchmark results
BenchmarkEstimated CyclesBenchmark Result
1e3 x estimated cycles
(Result Δ%)
Upper Boundary
1e3 x estimated cycles
(Limit %)
InstructionsBenchmark Result
instructions
(Result Δ%)
Upper Boundary
instructions
(Limit %)
L1 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
L2 AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
RAM AccessesBenchmark Result
accesses
(Result Δ%)
Upper Boundary
accesses
(Limit %)
client_sv2_handle_message_common📈 view plot
🚷 view threshold
2.17
(+2.52%)
2.24
(96.87%)
📈 view plot
🚷 view threshold
473.00
(-0.13%)
490.59
(96.41%)
📈 view plot
🚷 view threshold
732.00
(-0.55%)
759.04
(96.44%)
📈 view plot
🚷 view threshold
7.00
(+38.06%)
11.71
(59.79%)
📈 view plot
🚷 view threshold
40.00
(+3.52%)
41.71
(95.89%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
8.33
(+1.31%)
8.40
(99.21%)
📈 view plot
🚷 view threshold
2,137.00📈 view plot
🚷 view threshold
3,149.00
(-0.31%)
3,167.80
(99.41%)
📈 view plot
🚨 view alert (🔔)
🚷 view threshold
43.00
(+20.68%)
42.02
(102.34%)
📈 view plot
🚷 view threshold
142.00
(+1.65%)
144.55
(98.23%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
6.37
(+1.07%)
6.45
(98.75%)
📈 view plot
🚷 view threshold
1,750.00
(-0.03%)
1,767.59
(99.00%)
📈 view plot
🚷 view threshold
2,544.00
(-0.31%)
2,575.55
(98.77%)
📈 view plot
🚷 view threshold
23.00
(+33.51%)
24.48
(93.95%)
📈 view plot
🚷 view threshold
106.00
(+1.26%)
108.76
(97.46%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
14.84
(+0.78%)
14.94
(99.35%)
📈 view plot
🚷 view threshold
4,694.00
(-0.01%)
4,711.59
(99.63%)
📈 view plot
🚷 view threshold
6,740.00
(-0.23%)
6,786.85
(99.31%)
📈 view plot
🚷 view threshold
59.00
(+29.12%)
63.23
(93.31%)
📈 view plot
🚷 view threshold
223.00
(+0.82%)
226.16
(98.60%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
27.83
(+0.84%)
28.06
(99.20%)
📈 view plot
🚷 view threshold
10,645.00
(+0.36%)
10,697.70
(99.51%)
📈 view plot
🚷 view threshold
15,499.00
(+0.38%)
15,592.38
(99.40%)
📈 view plot
🚷 view threshold
94.00
(+12.26%)
99.17
(94.79%)
📈 view plot
🚷 view threshold
339.00
(+1.04%)
343.16
(98.79%)
client_sv2_open_channel📈 view plot
🚷 view threshold
4.46
(+1.31%)
4.58
(97.42%)
📈 view plot
🚷 view threshold
1,461.00
(-0.04%)
1,478.59
(98.81%)
📈 view plot
🚷 view threshold
2,154.00
(-0.31%)
2,184.77
(98.59%)
📈 view plot
🚷 view threshold
13.00
(+58.48%)
14.10
(92.21%)
📈 view plot
🚷 view threshold
64.00
(+1.83%)
67.60
(94.67%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
14.09
(+0.51%)
14.20
(99.23%)
📈 view plot
🚷 view threshold
5,064.00
(-0.01%)
5,081.59
(99.65%)
📈 view plot
🚷 view threshold
7,315.00
(-0.15%)
7,352.85
(99.49%)
📈 view plot
🚷 view threshold
46.00
(+25.65%)
48.50
(94.85%)
📈 view plot
🚷 view threshold
187.00
(+0.54%)
190.83
(97.99%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
22.85
(+0.66%)
23.06
(99.11%)
📈 view plot
🚷 view threshold
8,040.00
(+0.10%)
8,057.34
(99.78%)
📈 view plot
🚷 view threshold
11,689.00
(+0.04%)
11,713.60
(99.79%)
📈 view plot
🚷 view threshold
84.00
(+10.89%)
89.73
(93.61%)
📈 view plot
🚷 view threshold
307.00
(+0.97%)
312.48
(98.25%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
4.72
(+0.60%)
4.79
(98.51%)
📈 view plot
🚷 view threshold
1,502.00
(-0.04%)
1,519.59
(98.84%)
📈 view plot
🚷 view threshold
2,274.00
(-0.21%)
2,301.02
(98.83%)
📈 view plot
🚷 view threshold
13.00
(+37.63%)
15.41
(84.35%)
📈 view plot
🚷 view threshold
68.00
(+0.64%)
70.09
(97.02%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
16.26
(+0.65%)
16.33
(99.60%)
📈 view plot
🚷 view threshold
5,963.00
(-0.01%)
5,980.59
(99.71%)
📈 view plot
🚷 view threshold
8,650.00
(-0.16%)
8,692.73
(99.51%)
📈 view plot
🚷 view threshold
52.00
(+28.02%)
56.25
(92.44%)
📈 view plot
🚷 view threshold
210.00
(+0.84%)
212.12
(99.00%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
35.80
(+0.57%)
35.95
(99.58%)
📈 view plot
🚷 view threshold
14,888.00
(+0.14%)
14,918.80
(99.79%)
📈 view plot
🚷 view threshold
21,869.00
(+0.12%)
21,918.19
(99.78%)
📈 view plot
🚷 view threshold
106.00
(+12.36%)
119.26
(88.88%)
📈 view plot
🚷 view threshold
383.00
(+0.89%)
385.79
(99.28%)
🐰 View full continuous benchmarking report in Bencher

@Georges760
Copy link
Author

Thanks to @Sjors good comment, the current API is unchanged and an addition one allow no_std.

This is the way secp256k1 crate is doing it too, see sign_schnorr_with_rng.

@Georges760 Georges760 marked this pull request as ready for review December 7, 2024 11:01
Copy link
Contributor

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utack 9f2a908. Will test the PR once with the whole setup up and running. Rest looks ok on first glance with minor nits

protocols/v2/noise-sv2/src/handshake.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/responder.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/responder.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/handshake.rs Show resolved Hide resolved
@Georges760
Copy link
Author

utack 9f2a908. Will test the PR once with the whole setup up and running. Rest looks ok on first glance with minor nits

PR good to merge (for me) nothing more to add, you can test it

Copy link
Contributor

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tack feeb225. Just a few minor nits left, and we’re good to go. The handshake messages look as expected.

protocols/v2/noise-sv2/src/handshake.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/initiator.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/initiator.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/initiator.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/responder.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/responder.rs Show resolved Hide resolved
protocols/v2/noise-sv2/src/responder.rs Show resolved Hide resolved
protocols/v2/noise-sv2/Cargo.toml Outdated Show resolved Hide resolved
@Shourya742
Copy link
Contributor

@Georges760 You’ll need to bump the major version to make CI happy.

@Georges760
Copy link
Author

@Georges760 You’ll need to bump the major version to make CI happy.

do you want me to do it in this PR ?

also should I rebase on main ?

Copy link
Contributor

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These doc comments are exactly similar std counterparts. Could you add a quick note on why we need this with the random number generator? instead of this. Also, we usually skip 'Arguments' and 'Return type' sections in our docs, so if you can update those too, that’d be great!

Copy link
Contributor

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@Georges760 Georges760 force-pushed the noise_sv2_no_std branch 2 times, most recently from 25cbb20 to 3df4528 Compare December 18, 2024 08:27
@Georges760
Copy link
Author

CI is still randomly failing :

  • on last dev call, the re-run made it pass
  • after my last reabse, it PASS
  • after my README last push, it FAIL again (i am unable to re-run the job)

@Georges760
Copy link
Author

AFAIK @Shourya742 already TACK this PR, waiting for @rrybarczyk review.

@Georges760 Georges760 force-pushed the noise_sv2_no_std branch 3 times, most recently from 5449ea3 to aa777e1 Compare January 8, 2025 16:55
Georges Palauqui and others added 9 commits January 8, 2025 17:57
- std::ptr -> core::ptr
- std::boxed::Box -> alloc::boxed::Box
- std::vec::Vec -> alloc::vec::Vec
- std::string::{String, ToString} -> alloc::string::{String, ToString}
- std::convert::TryInto -> core::convert::TryInto
- std::fmt::{Debug, Formatter, Result} -> core::fmt::{Debug, Formatter, Result}
- std::time::Duration -> core::time::Duration

To have a `no-std` version, the `--no-default-features` must be used
public API changed to be able to be `no_std` (delegate the choice of the Ramdom Number Generator and the current System Time to the caller, instead of assuming using the ones from `std`) :
- `Initiator::new()`, `Initiator::from_raw_k()`, `Initiator::without_pk()`, `Responder::new()`, `Responder::from_authority_kp()` and `Responder::generate_key()` take an additional argument implementing rand::Rng + ?Sized
- `Responder::step_1()` and `SignatureNoiseMessage::sign()` take an additional argument implementing rand::Rng + rand::CryptoRng
- `Initiator::step_2()`, `Responder::step_1()`, `Responder::step_2()` and `SignatureNoiseMessage::verify()` take an additional argument for the current system time epoch
Copy link
Collaborator

@rrybarczyk rrybarczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @Georges760.

@plebhash
Copy link
Collaborator

plebhash commented Jan 8, 2025

@Georges760 I think this is almost ready for merging, but commit history looks a bit confusing.

For example, commit title of 771832b is:

utils/key-utils: revert changes, doesn't have to be changed in this PR

I'm not sure how to interpret this... is this commit intended to be on this PR or not?

also some commits could be squashed (or dropped, in case they're not meant to be on this PR)

@plebhash
Copy link
Collaborator

plebhash commented Jan 8, 2025

CI is still randomly failing :

  • on last dev call, the re-run made it pass
  • after my last reabse, it PASS
  • after my README last push, it FAIL again (i am unable to re-run the job)

we're looking into a way to make it deterministic, apologies for that

but doesn't look like anything serious

@Georges760
Copy link
Author

@Georges760 I think this is almost ready for merging, but commit history looks a bit confusing.

For example, commit title of 771832b is:

utils/key-utils: revert changes, doesn't have to be changed in this PR

I'm not sure how to interpret this... is this commit intended to be on this PR or not?

also some commits could be squashed (or dropped, in case they're not meant to be on this PR)

I will squash everything tomorrow;)

@Georges760
Copy link
Author

CI is still randomly failing :

  • on last dev call, the re-run made it pass
  • after my last reabse, it PASS
  • after my README last push, it FAIL again (i am unable to re-run the job)

we're looking into a way to make it deterministic, apologies for that

but doesn't look like anything serious

It was pretty ok lately, the last 5 or 6 rebase were all OK, only get Red on this last one of today.

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.

5 participants