File tree 4 files changed +22
-5
lines changed 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ pub struct Config {
27
27
/// the TLS connection is active. Data which can be decrypted after the TLS
28
28
/// connection will be decrypted for free.
29
29
pub ( crate ) max_recv_online : usize ,
30
+ /// Maximum number of received bytes.
31
+ #[ allow( unused) ]
32
+ pub ( crate ) max_recv : usize ,
30
33
}
31
34
32
35
impl Config {
@@ -44,24 +47,35 @@ impl ConfigBuilder {
44
47
+ self
45
48
. max_sent
46
49
. ok_or ( ConfigBuilderError :: UninitializedField ( "max_sent" ) ) ?;
47
- let max_recv_online = MIN_RECV
48
- + self
49
- . max_recv_online
50
- . ok_or ( ConfigBuilderError :: UninitializedField ( "max_recv_online" ) ) ?;
50
+ let mut max_recv_online = self
51
+ . max_recv_online
52
+ . ok_or ( ConfigBuilderError :: UninitializedField ( "max_recv_online" ) ) ?;
53
+ let max_recv = self
54
+ . max_recv
55
+ . ok_or ( ConfigBuilderError :: UninitializedField ( "max_recv" ) ) ?;
56
+
57
+ if max_recv_online > max_recv {
58
+ return Err ( ConfigBuilderError :: ValidationError (
59
+ "max_recv_online must be less than or equal to max_recv" . to_string ( ) ,
60
+ ) ) ;
61
+ }
62
+
63
+ max_recv_online += MIN_RECV ;
51
64
52
65
let max_sent_records = self
53
66
. max_sent_records
54
67
. unwrap_or_else ( || MIN_SENT_RECORDS + max_sent. div_ceil ( 16384 ) ) ;
55
68
let max_recv_records = self
56
69
. max_recv_records
57
- . unwrap_or_else ( || MIN_RECV_RECORDS + max_recv_online . div_ceil ( 16384 ) ) ;
70
+ . unwrap_or_else ( || MIN_RECV_RECORDS + max_recv . div_ceil ( 16384 ) ) ;
58
71
59
72
Ok ( Config {
60
73
defer_decryption,
61
74
max_sent_records,
62
75
max_sent,
63
76
max_recv_records,
64
77
max_recv_online,
78
+ max_recv,
65
79
} )
66
80
}
67
81
}
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ async fn mpc_tls_test() {
28
28
. defer_decryption ( false )
29
29
. max_sent ( 1 << 13 )
30
30
. max_recv_online ( 1 << 13 )
31
+ . max_recv ( 1 << 13 )
31
32
. build ( )
32
33
. unwrap ( ) ;
33
34
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ impl ProverConfig {
53
53
. defer_decryption ( self . defer_decryption_from_start )
54
54
. max_sent ( self . protocol_config . max_sent_data ( ) )
55
55
. max_recv_online ( self . protocol_config . max_recv_data_online ( ) )
56
+ . max_recv ( self . protocol_config . max_recv_data ( ) )
56
57
. build ( )
57
58
. unwrap ( )
58
59
}
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ impl VerifierConfig {
46
46
Config :: builder ( )
47
47
. max_sent ( protocol_config. max_sent_data ( ) )
48
48
. max_recv_online ( protocol_config. max_recv_data_online ( ) )
49
+ . max_recv ( protocol_config. max_recv_data ( ) )
49
50
. build ( )
50
51
. unwrap ( )
51
52
}
You can’t perform that action at this time.
0 commit comments