@@ -427,15 +427,15 @@ impl Drop for Decrypter {
427
427
enum WorkerState {
428
428
/// Obtains the threshold decryption key from DKG bundles.
429
429
///
430
- /// A node can recover its threshold decryption key in two ways:
430
+ /// A node can recover its threshold decryption key in two ways:
431
431
/// 1. **Consensus**: by combining DKG bundles extracted directly from candidate lists produced
432
432
/// by peers.
433
433
/// 2. **Network**: by receiving and combining an agreed-upon subset of DKG bundles from a
434
434
/// designated set of peers.
435
435
///
436
- /// For the initial DKG, method (1) is used.
437
- /// For resharing, method (2) is used, with the source peers being the previous committee.
438
- /// When catching up—whether during the initial DKG or after resharing—the node also uses
436
+ /// For the initial DKG, method (1) is used.
437
+ /// For resharing, method (2) is used, with the source peers being the previous committee.
438
+ /// When catching up—whether during the initial DKG or after resharing—the node also uses
439
439
/// method (2), but obtains the bundles from the current committee.
440
440
DkgPending ( HashMap < PublicKey , DkgSubset > ) ,
441
441
/// Active mode with decryption key ready.
@@ -448,7 +448,7 @@ impl Default for WorkerState {
448
448
}
449
449
}
450
450
451
- /// A `Worker` handles the production, exchange, and combination of decryption shares
451
+ /// A `Worker` handles the production, exchange, and combination of decryption shares
452
452
/// in coordination with other peers. See [`Decrypter`] for details.
453
453
#[ derive( Builder ) ]
454
454
struct Worker {
@@ -1546,7 +1546,6 @@ mod tests {
1546
1546
time:: Instant ,
1547
1547
} ;
1548
1548
use test_utils:: ports:: alloc_port;
1549
- use timeboost_config:: DECRYPTER_PORT_OFFSET ;
1550
1549
use timeboost_utils:: types:: logging;
1551
1550
1552
1551
use cliquenet:: AddressableCommittee ;
@@ -1573,7 +1572,6 @@ mod tests {
1573
1572
const TEST_SEQNO : u64 = 10 ;
1574
1573
const RETAIN_ROUNDS : usize = 100 ;
1575
1574
const COM1 : u64 = 1 ;
1576
- const COM2 : u64 = 2 ;
1577
1575
1578
1576
// Pre-generated deterministic keys for consistent testing
1579
1577
// Generated via: `just mkconfig_local 5 --seed 42`
@@ -1585,14 +1583,6 @@ mod tests {
1585
1583
"6LMMEuoPRCkpDsnxnANCRCBC6JagdCHs2pjNicdmQpQE" ,
1586
1584
] ;
1587
1585
1588
- const COM2_SIGNATURE_PRIVATE_KEY_STRINGS : [ & str ; COMMITTEE_SIZE ] = [
1589
- "6YJc9asDJQsFFHHg8iX23oL1sySx2EgTGM8CqDd71WMa" ,
1590
- "6NZdk8EGRSVS7sSjcjMiC8vL4KcSY41ELU6HaKyk1Drk" ,
1591
- "AMJEYXVhS4FfoqfD6VL5nZTNbzJQdtgdxBcVEAwZnLJ3" ,
1592
- "5mLCMSVT4f8HPqCqdKChxugpMcQ3x1C7hwfEnsTApFfp" ,
1593
- "4yhZYmNvAouKFpiYomrV9aH8kUZTLRH2hiCZtJzcAASa" ,
1594
- ] ;
1595
-
1596
1586
const COM1_DH_PRIVATE_KEY_STRINGS : [ & str ; COMMITTEE_SIZE ] = [
1597
1587
"BB3zUfFQGfw3sL6bpp1JH1HozK6ehEDmRGoiCpQH62rZ" ,
1598
1588
"4hjtciEvuoFVT55nAzvdP9E76r18QwntWwFoeginCGnP" ,
@@ -1601,14 +1591,6 @@ mod tests {
1601
1591
"39wAn3bQzpn19oa8CiaNUFd8GekQAJMMuzrbp8Jt3FKz" ,
1602
1592
] ;
1603
1593
1604
- const COM2_DH_PRIVATE_KEY_STRINGS : [ & str ; COMMITTEE_SIZE ] = [
1605
- "Ho9ZZCkP1i6f12fkWGUZucJxX2qbv9L3UbB56sqwjvkw" ,
1606
- "F5E9cp5qUe4z2wdaRYvEhFMYXaLy4sEX1rwCWRcTH69i" ,
1607
- "5zhwDWJ1ut6q871aHCHmH7QRCHDykXjUSEriGTLkwezL" ,
1608
- "2PojAT3g5iqGTrgLhTRKKHqwbeoFhRkzkYLM9AttFoKK" ,
1609
- "Bk2wY7o2YE9gpu6jxiRSbWiMU88H8s9D9MQGMaF2LJ7h" ,
1610
- ] ;
1611
-
1612
1594
const COM1_DKG_PRIVATE_KEY_STRINGS : [ & str ; COMMITTEE_SIZE ] = [
1613
1595
"BW8gq8MARtDkSJL6daobPtGQm22TKkXdbLNrNGngNGTB" ,
1614
1596
"ARtqWGmRWrBqZUr4MmiLaPgzjsiKp5USsC9iQNRMZYy4" ,
@@ -1617,18 +1599,10 @@ mod tests {
1617
1599
"GFvv2wcQmiGpk5rFp1FGpeUjnVUyZmGM9k8VHb1Jn7EG" ,
1618
1600
] ;
1619
1601
1620
- const COM2_DKG_PRIVATE_KEY_STRINGS : [ & str ; COMMITTEE_SIZE ] = [
1621
- "GLNPt6EYeFQbq8cCX5nKMA4LbCKdrUN5o5hmWTPJbkJZ" ,
1622
- "2n3Pz5NeUAVu5YaWgXN9CCrS6rC7NZwVZ48AG8m7JRqF" ,
1623
- "AGxRDhGvgovb1DZMjL3Y6Q4hF6UUpFCtpPD6sTJd827U" ,
1624
- "A3GUHxG3cPKvCch6XowztrHrrvaGS5JH3CuXQKCxQEnv" ,
1625
- "216zC1MgfV54cJJtt3AKdjJHhqfgZLZCmEyCkFN1bPoF" ,
1626
- ] ;
1627
-
1628
- #[ test]
1629
1602
/// Tests the local DKG (Distributed Key Generation) end-to-end flow without networking.
1630
1603
/// Verifies that committee members can generate threshold decryption keys and perform
1631
1604
/// threshold encryption/decryption operations.
1605
+ #[ test]
1632
1606
fn test_local_dkg_e2e ( ) {
1633
1607
logging:: init_logging ( ) ;
1634
1608
let mut rng = thread_rng ( ) ;
@@ -1949,9 +1923,9 @@ mod tests {
1949
1923
) ;
1950
1924
}
1951
1925
1952
- #[ tokio:: test]
1953
1926
/// Tests integrated DKG to ensure it terminates with consistent public encryption keys
1954
1927
/// across all committee members in a networked environment.
1928
+ #[ tokio:: test]
1955
1929
async fn test_dkg_termination ( ) {
1956
1930
logging:: init_logging ( ) ;
1957
1931
let ( mut decrypters, setup) = setup (
@@ -1985,174 +1959,22 @@ mod tests {
1985
1959
}
1986
1960
}
1987
1961
1988
- #[ tokio:: test]
1989
1962
/// Tests the complete DKG and decryption phase end-to-end flow in a networked environment.
1990
1963
/// Verifies that encrypted transactions can be properly decrypted after DKG completion.
1964
+ #[ tokio:: test]
1991
1965
async fn test_dkg_and_decryption_phase_e2e ( ) {
1992
1966
run_dkg_and_decryption_phase_e2e ( false ) . await ;
1993
1967
}
1994
1968
1995
- #[ tokio:: test]
1996
1969
/// Tests the complete DKG and decryption phase end-to-end flow in a networked environment.
1997
1970
/// Verifies that encrypted transactions can be properly decrypted after DKG completion.
1998
1971
/// The node that is catching up will not have the dealings locally enqueued but will instead
1999
1972
/// fetch the dealings from other nodes to obtain the DKG key material.
1973
+ #[ tokio:: test]
2000
1974
async fn test_dkg_and_decryption_phase_e2e_with_catchup ( ) {
2001
1975
run_dkg_and_decryption_phase_e2e ( true ) . await ;
2002
1976
}
2003
1977
2004
- #[ tokio:: test]
2005
- /// Tests the full spectrum of Decrypter states:
2006
- /// 1. Initial committee completes dkg and decrypts transactions.
2007
- /// 2. NextCommittee and UseCommittee events are triggered adding nodes to the network.
2008
- /// 3. Resharing is done in the background among new/old committee members.
2009
- /// 4. Old committee decrypts its last inclusion list triggering committee switch.
2010
- /// 5. New committee decrypts its first inclusion list using key from resharing.
2011
- async fn run_dkg_handover_decryption_phase_e2e ( ) {
2012
- logging:: init_logging ( ) ;
2013
-
2014
- let ( mut com1_decrypters, com1_setup) = setup (
2015
- COM1 ,
2016
- & COM1_SIGNATURE_PRIVATE_KEY_STRINGS ,
2017
- & COM1_DH_PRIVATE_KEY_STRINGS ,
2018
- & COM1_DKG_PRIVATE_KEY_STRINGS ,
2019
- None ,
2020
- )
2021
- . await ;
2022
- tracing:: info!( "COM1 decrypters and setup initialized" ) ;
2023
-
2024
- let com1_round = RoundNumber :: new ( DECRYPTION_ROUND ) ;
2025
-
2026
- enqueue_all_dkg_bundles ( & mut com1_decrypters, None ) . await ;
2027
- tracing:: info!( "All DKG bundles enqueued for COM1" ) ;
2028
-
2029
- for cell in com1_setup. dec_keys ( ) {
2030
- cell. read ( ) . await ;
2031
- }
2032
- tracing:: info!( "COM1 DKG keys generated and available" ) ;
2033
-
2034
- let encryption_key = com1_setup. dec_keys ( ) [ 0 ]
2035
- . get ( )
2036
- . expect ( "encryption key should be generated after DKG" ) ;
2037
-
2038
- let com2_round = RoundNumber :: new ( DECRYPTION_ROUND + 1 ) ;
2039
- let ( mut com2_decrypters, com2_setup) = setup (
2040
- COM2 ,
2041
- & COM2_SIGNATURE_PRIVATE_KEY_STRINGS ,
2042
- & COM2_DH_PRIVATE_KEY_STRINGS ,
2043
- & COM2_DKG_PRIVATE_KEY_STRINGS ,
2044
- Some ( com1_setup. clone ( ) ) ,
2045
- )
2046
- . await ;
2047
- tracing:: info!( "COM2 decrypters and setup initialized with previous committee" ) ;
2048
-
2049
- // trigger NextCommittee event at each decrypter in COM1
2050
- for decrypter in com1_decrypters. iter_mut ( ) {
2051
- let mut sf_addr = com2_setup. addr_comm ( ) . clone ( ) ;
2052
- sf_addr. update_addresses ( |a| a. clone ( ) . with_port ( a. port ( ) - DECRYPTER_PORT_OFFSET ) ) ;
2053
- decrypter
2054
- . next_committee ( sf_addr, com2_setup. key_store ( ) . clone ( ) )
2055
- . await
2056
- . expect ( "next committee event succeeds" ) ;
2057
- }
2058
- tracing:: info!( "NextCommittee event triggered for all COM1 decrypters" ) ;
2059
-
2060
- let priority_tx_message = b"Priority message for old committee" ;
2061
- let regular_tx_message = b"Non-priority message for old committee" ;
2062
-
2063
- let encrypted_inclusion_list = create_encrypted_inclusion_list (
2064
- com1_round,
2065
- com1_setup. addr_comm ( ) . committee ( ) . clone ( ) ,
2066
- com1_setup. sig_keys ( ) ,
2067
- encryption_key. pubkey ( ) ,
2068
- priority_tx_message,
2069
- regular_tx_message,
2070
- ) ;
2071
- tracing:: info!( "Encrypted inclusion list created for COM1 round" ) ;
2072
-
2073
- // enqueues the same inclusion list to all nodes in COM1
2074
- for decrypter in com1_decrypters. iter_mut ( ) {
2075
- decrypter
2076
- . enqueue ( encrypted_inclusion_list. clone ( ) )
2077
- . await
2078
- . expect ( "Inclusion list should be enqueued successfully" ) ;
2079
- }
2080
- tracing:: info!( "Encrypted inclusion list enqueued to all COM1 decrypters" ) ;
2081
-
2082
- let _ = collect_inclusion_lists ( & mut com1_decrypters) . await ;
2083
- tracing:: info!( "Decrypted inclusion lists collected from COM1 decrypters" ) ;
2084
-
2085
- // enqueue resharing bundles (for COM2) at each decrypter in COM1
2086
- enqueue_all_dkg_bundles ( & mut com1_decrypters, Some ( com2_setup. key_store ( ) . clone ( ) ) ) . await ;
2087
- tracing:: info!( "Resharing bundles enqueued for COM2 at all COM1 decrypters" ) ;
2088
-
2089
- // trigger UseCommittee event for COM2
2090
- for decrypter in com2_decrypters. iter_mut ( ) {
2091
- decrypter
2092
- . use_committee ( Round :: new ( com2_round, COM2 ) )
2093
- . await
2094
- . expect ( "use committee event succeeds" ) ;
2095
- }
2096
- tracing:: info!( "UseCommittee event triggered for COM2 decrypters" ) ;
2097
-
2098
- let priority_tx_message = b"Priority message for new committee" ;
2099
- let regular_tx_message = b"Non-priority message for new committee" ;
2100
-
2101
- let encrypted_inclusion_list = create_encrypted_inclusion_list (
2102
- com2_round,
2103
- com2_setup. addr_comm ( ) . committee ( ) . clone ( ) ,
2104
- com2_setup. sig_keys ( ) ,
2105
- encryption_key. pubkey ( ) , // same encryption key
2106
- priority_tx_message,
2107
- regular_tx_message,
2108
- ) ;
2109
- tracing:: info!( "Encrypted inclusion list created for COM2 round" ) ;
2110
-
2111
- for new_decrypter in com2_decrypters. iter_mut ( ) {
2112
- new_decrypter
2113
- . enqueue ( encrypted_inclusion_list. clone ( ) )
2114
- . await
2115
- . expect ( "Inclusion list should be enqueued successfully" ) ;
2116
- }
2117
- tracing:: info!( "Encrypted inclusion list enqueued to all COM2 decrypters" ) ;
2118
-
2119
- let decrypted_inclusion_lists = collect_inclusion_lists ( & mut com2_decrypters) . await ;
2120
- tracing:: info!( "Decrypted inclusion lists collected from COM2 decrypters" ) ;
2121
-
2122
- // Verify that all decrypted inclusion lists are correct
2123
- for decrypted_list in decrypted_inclusion_lists {
2124
- assert_eq ! (
2125
- decrypted_list. round( ) ,
2126
- com2_round,
2127
- "Decrypted list should have the expected round number"
2128
- ) ;
2129
- assert_eq ! (
2130
- decrypted_list. priority_bundles( ) . len( ) ,
2131
- 1 ,
2132
- "Should have exactly one priority bundle"
2133
- ) ;
2134
- assert_eq ! (
2135
- decrypted_list. regular_bundles( ) . len( ) ,
2136
- 1 ,
2137
- "Should have exactly one regular bundle"
2138
- ) ;
2139
-
2140
- let decrypted_priority_data = decrypted_list. priority_bundles ( ) [ 0 ] . bundle ( ) . data ( ) ;
2141
- let decrypted_regular_data = decrypted_list. regular_bundles ( ) [ 0 ] . data ( ) ;
2142
-
2143
- assert_eq ! (
2144
- decrypted_priority_data. to_vec( ) ,
2145
- priority_tx_message. to_vec( ) ,
2146
- "Decrypted priority transaction should match original"
2147
- ) ;
2148
- assert_eq ! (
2149
- decrypted_regular_data. to_vec( ) ,
2150
- regular_tx_message. to_vec( ) ,
2151
- "Decrypted regular transaction should match original"
2152
- ) ;
2153
- }
2154
- }
2155
-
2156
1978
/// Helper to run DKG and decryption phase E2E test.
2157
1979
async fn run_dkg_and_decryption_phase_e2e ( catchup : bool ) {
2158
1980
logging:: init_logging ( ) ;
0 commit comments