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.29%. Comparing base (1f2c5e8) to head (b115a98).

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.29%   19.29%   -0.01%     
==========================================
  Files         164      162       -2     
  Lines       10852    10895      +43     
==========================================
+ Hits         2094     2102       +8     
- Misses       8758     8793      +35     
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 ?
buffer_sv2-coverage 25.02% <ø> (ø)
codec_sv2-coverage 0.01% <0.00%> (-0.01%) ⬇️
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 0.28% <0.00%> (-0.01%) ⬇️
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.43% <0.00%> (-0.08%) ⬇️
mining_device-coverage 0.00% <ø> (ø)
mining_proxy_sv2-coverage 0.70% <ø> (ø)
noise_sv2-coverage 4.46% <80.00%> (+0.10%) ⬆️
pool_sv2-coverage 1.38% <ø> (ø)
protocols 24.62% <63.15%> (-0.11%) ⬇️
roles 6.54% <ø> (ø)
roles_logic_sv2-coverage 7.92% <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.45
(-0.06%)
8.67
(97.43%)
📈 view plot
🚷 view threshold
3.66
(-1.77%)
3.86
(94.90%)
📈 view plot
🚷 view threshold
5.11
(-2.17%)
5.44
(93.84%)
📈 view plot
🚷 view threshold
10.00
(+21.67%)
15.70
(63.68%)
📈 view plot
🚷 view threshold
94.00
(+3.12%)
96.26
(97.65%)
get_submit📈 view plot
🚷 view threshold
95.35
(-0.01%)
95.63
(99.71%)
📈 view plot
🚷 view threshold
59.26
(-0.25%)
59.70
(99.26%)
📈 view plot
🚷 view threshold
85.08
(-0.29%)
85.81
(99.14%)
📈 view plot
🚷 view threshold
46.00
(+3.75%)
59.78
(76.95%)
📈 view plot
🚷 view threshold
287.00
(+2.36%)
290.54
(98.78%)
get_subscribe📈 view plot
🚷 view threshold
7.96
(-0.53%)
8.23
(96.66%)
📈 view plot
🚷 view threshold
2.76
(-2.08%)
2.94
(93.73%)
📈 view plot
🚷 view threshold
3.83
(-2.50%)
4.14
(92.51%)
📈 view plot
🚷 view threshold
13.00
(+5.72%)
20.39
(63.74%)
📈 view plot
🚷 view threshold
116.00
(+1.31%)
117.82
(98.45%)
serialize_authorize📈 view plot
🚷 view threshold
12.23
(-0.20%)
12.50
(97.84%)
📈 view plot
🚷 view threshold
5.24
(-1.17%)
5.42
(96.60%)
📈 view plot
🚷 view threshold
7.28
(-1.46%)
7.60
(95.78%)
📈 view plot
🚷 view threshold
11.00
(+10.09%)
18.52
(59.39%)
📈 view plot
🚷 view threshold
140.00
(+1.61%)
142.46
(98.27%)
serialize_deserialize_authorize📈 view plot
🚷 view threshold
24.67
(-0.19%)
25.18
(97.95%)
📈 view plot
🚷 view threshold
9.79
(-0.77%)
10.01
(97.77%)
📈 view plot
🚷 view threshold
13.79
(-0.94%)
14.17
(97.29%)
📈 view plot
🚷 view threshold
34.00
(-5.00%)
45.66
(74.47%)
📈 view plot
🚷 view threshold
306.00
(+0.88%)
312.98
(97.77%)
serialize_deserialize_handle_authorize📈 view plot
🚷 view threshold
30.29
(-0.12%)
30.72
(98.59%)
📈 view plot
🚷 view threshold
11.99
(-0.54%)
12.19
(98.39%)
📈 view plot
🚷 view threshold
16.95
(-0.68%)
17.29
(98.02%)
📈 view plot
🚷 view threshold
57.00
(+2.31%)
67.18
(84.85%)
📈 view plot
🚷 view threshold
373.00
(+0.57%)
378.99
(98.42%)
serialize_deserialize_handle_submit📈 view plot
🚷 view threshold
126.46
(+0.01%)
126.78
(99.75%)
📈 view plot
🚷 view threshold
73.12
(-0.19%)
73.53
(99.44%)
📈 view plot
🚷 view threshold
104.76
(-0.24%)
105.50
(99.30%)
📈 view plot
🚷 view threshold
112.00
(+5.44%)
125.54
(89.22%)
📈 view plot
🚷 view threshold
604.00
(+1.11%)
608.54
(99.25%)
serialize_deserialize_handle_subscribe📈 view plot
🚷 view threshold
27.90
(-0.06%)
28.39
(98.25%)
📈 view plot
🚷 view threshold
9.58
(-0.60%)
9.76
(98.13%)
📈 view plot
🚷 view threshold
13.52
(-0.76%)
13.84
(97.70%)
📈 view plot
🚷 view threshold
69.00
(+7.15%)
77.67
(88.84%)
📈 view plot
🚷 view threshold
401.00
(+0.47%)
409.77
(97.86%)
serialize_deserialize_submit📈 view plot
🚷 view threshold
115.17
(-0.06%)
115.71
(99.54%)
📈 view plot
🚷 view threshold
67.89
(-0.25%)
68.41
(99.24%)
📈 view plot
🚷 view threshold
97.36
(-0.31%)
98.27
(99.07%)
📈 view plot
🚷 view threshold
69.00
(+6.69%)
86.05
(80.19%)
📈 view plot
🚷 view threshold
499.00
(+1.24%)
502.29
(99.35%)
serialize_deserialize_subscribe📈 view plot
🚷 view threshold
23.26
(-0.27%)
23.82
(97.64%)
📈 view plot
🚷 view threshold
8.13
(-0.74%)
8.31
(97.76%)
📈 view plot
🚷 view threshold
11.43
(-0.88%)
11.74
(97.31%)
📈 view plot
🚷 view threshold
36.00
(-6.85%)
50.45
(71.35%)
📈 view plot
🚷 view threshold
333.00
(+0.45%)
342.28
(97.29%)
serialize_submit📈 view plot
🚷 view threshold
99.81
(+0.02%)
100.10
(99.71%)
📈 view plot
🚷 view threshold
61.33
(-0.22%)
61.73
(99.35%)
📈 view plot
🚷 view threshold
87.93
(-0.27%)
88.64
(99.20%)
📈 view plot
🚷 view threshold
52.00
(+9.13%)
66.15
(78.61%)
📈 view plot
🚷 view threshold
332.00
(+2.13%)
335.90
(98.84%)
serialize_subscribe📈 view plot
🚷 view threshold
11.44
(+0.36%)
11.59
(98.67%)
📈 view plot
🚷 view threshold
4.11
(-1.31%)
4.28
(95.99%)
📈 view plot
🚷 view threshold
5.69
(-1.69%)
6.00
(94.90%)
📈 view plot
🚷 view threshold
16.00
(+17.70%)
23.40
(68.37%)
📈 view plot
🚷 view threshold
162.00
(+2.30%)
163.76
(98.92%)
🐰 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,526.70
(-0.78%)
6,907.13
(94.49%)
client-submit-serialize-deserialize📈 view plot
🚷 view threshold
7,356.70
(-0.91%)
7,818.82
(94.09%)
client-submit-serialize-deserialize-handle/client-submit-serialize-deserialize-handle📈 view plot
🚷 view threshold
7,954.30
(-1.68%)
9,204.60
(86.42%)
client-sv1-authorize-serialize-deserialize-handle/client-sv1-authorize-serialize-deserialize-handle📈 view plot
🚷 view threshold
866.06
(-0.06%)
936.80
(92.45%)
client-sv1-authorize-serialize-deserialize/client-sv1-authorize-serialize-deserialize📈 view plot
🚷 view threshold
671.70
(-0.35%)
715.83
(93.84%)
client-sv1-authorize-serialize/client-sv1-authorize-serialize📈 view plot
🚷 view threshold
253.44
(+1.57%)
269.63
(94.00%)
client-sv1-get-authorize/client-sv1-get-authorize📈 view plot
🚷 view threshold
156.18
(-0.78%)
165.71
(94.25%)
client-sv1-get-submit📈 view plot
🚷 view threshold
6,254.00
(-1.55%)
6,769.63
(92.38%)
client-sv1-get-subscribe/client-sv1-get-subscribe📈 view plot
🚷 view threshold
278.85
(-1.16%)
321.40
(86.76%)
client-sv1-subscribe-serialize-deserialize-handle/client-sv1-subscribe-serialize-deserialize-handle📈 view plot
🚷 view threshold
740.75
(+1.78%)
775.49
(95.52%)
client-sv1-subscribe-serialize-deserialize/client-sv1-subscribe-serialize-deserialize📈 view plot
🚷 view threshold
604.05
(+2.29%)
626.98
(96.34%)
client-sv1-subscribe-serialize/client-sv1-subscribe-serialize📈 view plot
🚷 view threshold
206.03
(-0.16%)
222.98
(92.40%)
🐰 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.20
(-1.97%)
57.67
(76.64%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
91.47
(+16.32%)
107.46
(85.12%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
14.66
(+0.02%)
14.71
(99.69%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
259.74
(-2.21%)
288.72
(89.96%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
598.82
(-2.28%)
647.35
(92.50%)
client_sv2_open_channel📈 view plot
🚷 view threshold
164.47
(-0.43%)
177.20
(92.81%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
278.02
(-2.32%)
308.29
(90.18%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
382.18
(-0.27%)
406.90
(93.93%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
163.37
(+1.95%)
171.17
(95.44%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
445.03
(-5.41%)
552.41
(80.56%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
966.12
(-3.25%)
1,134.79
(85.14%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Contributor

github-actions bot commented Dec 7, 2024

🐰 Bencher Report

Branchnoise_sv2_no_std
Testbedsv2

🚨 2 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
client_sv2_open_channel_serializeL2 Accesses
accesses
📈 plot
🚨 alert (🔔)
🚷 threshold
50.00
(+37.84%)
48.43
(103.24%)
client_sv2_open_channel_serialize_deserializeL2 Accesses
accesses
📈 plot
🚨 alert (🔔)
🚷 threshold
90.00
(+19.17%)
89.92
(100.08%)
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.84%)
2.23
(97.14%)
📈 view plot
🚷 view threshold
473.00
(-0.09%)
490.93
(96.35%)
📈 view plot
🚷 view threshold
731.00
(-0.67%)
759.93
(96.19%)
📈 view plot
🚷 view threshold
8.00
(+60.75%)
11.97
(66.83%)
📈 view plot
🚷 view threshold
40.00
(+3.69%)
41.67
(95.98%)
client_sv2_handle_message_mining📈 view plot
🚷 view threshold
8.28
(+0.76%)
8.39
(98.75%)
📈 view plot
🚷 view threshold
2,137.00
(-0.00%)
2,138.71
(99.92%)
📈 view plot
🚷 view threshold
3,154.00
(-0.16%)
3,168.20
(99.55%)
📈 view plot
🚷 view threshold
39.00
(+9.62%)
41.92
(93.03%)
📈 view plot
🚷 view threshold
141.00
(+1.02%)
144.20
(97.78%)
client_sv2_mining_message_submit_standard📈 view plot
🚷 view threshold
6.37
(+1.05%)
6.45
(98.75%)
📈 view plot
🚷 view threshold
1,750.00
(-0.03%)
1,767.83
(98.99%)
📈 view plot
🚷 view threshold
2,545.00
(-0.27%)
2,576.23
(98.79%)
📈 view plot
🚷 view threshold
22.00
(+28.23%)
24.67
(89.19%)
📈 view plot
🚷 view threshold
106.00
(+1.34%)
108.67
(97.54%)
client_sv2_mining_message_submit_standard_serialize📈 view plot
🚷 view threshold
14.84
(+0.80%)
14.93
(99.38%)
📈 view plot
🚷 view threshold
4,694.00
(-0.01%)
4,711.83
(99.62%)
📈 view plot
🚷 view threshold
6,740.00
(-0.24%)
6,786.99
(99.31%)
📈 view plot
🚷 view threshold
59.00
(+30.63%)
62.21
(94.84%)
📈 view plot
🚷 view threshold
223.00
(+0.83%)
226.18
(98.59%)
client_sv2_mining_message_submit_standard_serialize_deserialize📈 view plot
🚷 view threshold
27.85
(+0.93%)
28.03
(99.36%)
📈 view plot
🚷 view threshold
10,645.00
(+0.39%)
10,692.04
(99.56%)
📈 view plot
🚷 view threshold
15,496.00
(+0.40%)
15,581.88
(99.45%)
📈 view plot
🚷 view threshold
97.00
(+16.20%)
99.22
(97.77%)
📈 view plot
🚷 view threshold
339.00
(+1.10%)
342.61
(98.95%)
client_sv2_open_channel📈 view plot
🚷 view threshold
4.53
(+2.97%)
4.57
(99.11%)
📈 view plot
🚷 view threshold
1,461.00
(-0.03%)
1,478.93
(98.79%)
📈 view plot
🚷 view threshold
2,152.00
(-0.40%)
2,185.38
(98.47%)
📈 view plot
🚷 view threshold
13.00
(+60.15%)
14.00
(92.84%)
📈 view plot
🚷 view threshold
66.00
(+5.23%)
67.35
(97.99%)
client_sv2_open_channel_serialize📈 view plot
🚷 view threshold
14.17
(+1.11%)
14.20
(99.81%)
📈 view plot
🚷 view threshold
5,064.00
(-0.01%)
5,081.93
(99.65%)
📈 view plot
🚷 view threshold
7,309.00
(-0.23%)
7,353.34
(99.40%)
📈 view plot
🚨 view alert (🔔)
🚷 view threshold
50.00
(+37.84%)
48.43
(103.24%)
📈 view plot
🚷 view threshold
189.00
(+1.60%)
190.97
(98.97%)
client_sv2_open_channel_serialize_deserialize📈 view plot
🚷 view threshold
22.91
(+0.97%)
23.02
(99.53%)
📈 view plot
🚷 view threshold
8,040.00
(+0.11%)
8,056.77
(99.79%)
📈 view plot
🚷 view threshold
11,682.00
(-0.02%)
11,713.81
(99.73%)
📈 view plot
🚨 view alert (🔔)
🚷 view threshold
90.00
(+19.17%)
89.92
(100.08%)
📈 view plot
🚷 view threshold
308.00
(+1.40%)
311.41
(98.91%)
client_sv2_setup_connection📈 view plot
🚷 view threshold
4.75
(+1.28%)
4.79
(99.13%)
📈 view plot
🚷 view threshold
1,502.00
(-0.03%)
1,519.93
(98.82%)
📈 view plot
🚷 view threshold
2,274.00
(-0.20%)
2,301.78
(98.79%)
📈 view plot
🚷 view threshold
12.00
(+27.57%)
15.47
(77.56%)
📈 view plot
🚷 view threshold
69.00
(+2.19%)
70.11
(98.42%)
client_sv2_setup_connection_serialize📈 view plot
🚷 view threshold
16.30
(+0.91%)
16.32
(99.86%)
📈 view plot
🚷 view threshold
5,963.00
(-0.01%)
5,980.93
(99.70%)
📈 view plot
🚷 view threshold
8,648.00
(-0.19%)
8,693.05
(99.48%)
📈 view plot
🚷 view threshold
53.00
(+32.19%)
54.92
(96.50%)
📈 view plot
🚷 view threshold
211.00
(+1.35%)
212.10
(99.48%)
client_sv2_setup_connection_serialize_deserialize📈 view plot
🚷 view threshold
35.79
(+0.57%)
35.92
(99.64%)
📈 view plot
🚷 view threshold
14,888.00
(+0.15%)
14,916.05
(99.81%)
📈 view plot
🚷 view threshold
21,864.00
(+0.11%)
21,914.76
(99.77%)
📈 view plot
🚷 view threshold
112.00
(+19.70%)
118.09
(94.85%)
📈 view plot
🚷 view threshold
382.00
(+0.66%)
385.36
(99.13%)
🐰 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
Copy link
Author

The CI fails because of infra, need to be re-run when CI depending server/files are accessible again

@Shourya742
Copy link
Contributor

The CI fails because of infra, need to be re-run when CI depending server/files are accessible again

Ya I noticed it now... I have opened a PR to address this, #1293

@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.

Georges Palauqui and others added 9 commits January 3, 2025 17:59
- 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
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.

3 participants