@@ -26,6 +26,7 @@ use qos_core::protocol::{
2626 } ,
2727 } ,
2828 QosHash ,
29+ ProtocolError ,
2930} ;
3031use qos_crypto:: { sha_256, sha_384, sha_512} ;
3132use qos_nsm:: {
@@ -2024,22 +2025,18 @@ pub(crate) fn dangerous_dev_boot<P: AsRef<Path>>(
20242025 pub_key : quorum_public_der. clone ( ) ,
20252026 } ;
20262027
2027- // Shard it with N=1, K=1
2028- let share = {
2029- let mut shares = qos_crypto:: shamir:: shares_generate (
2030- quorum_pair. to_master_seed ( ) ,
2031- 2 ,
2032- 2 ,
2033- )
2034- . unwrap ( ) ;
2035-
2036- assert_eq ! (
2037- shares. len( ) ,
2038- 2 ,
2039- "Error generating shares - did not get exactly two share."
2040- ) ;
2041- shares. remove ( 0 )
2042- } ;
2028+ // Shard it with N=2, K=2
2029+ let shares = qos_crypto:: shamir:: shares_generate (
2030+ quorum_pair. to_master_seed ( ) ,
2031+ 2 ,
2032+ 2 ,
2033+ )
2034+ . unwrap ( ) ;
2035+ assert_eq ! (
2036+ shares. len( ) ,
2037+ 2 ,
2038+ "Error generating shares - did not get exactly two share."
2039+ ) ;
20432040
20442041 // Read in the pivot
20452042 let pivot = fs:: read ( & pivot_path) . expect ( "Failed to read pivot binary." ) ;
@@ -2068,7 +2065,7 @@ pub(crate) fn dangerous_dev_boot<P: AsRef<Path>>(
20682065 members : vec ! [ member. clone( ) ] ,
20692066 } ,
20702067 share_set : ShareSet {
2071- threshold : 1 ,
2068+ threshold : 2 ,
20722069 // The only member is the quorum member
20732070 members : vec ! [ member. clone( ) ] ,
20742071 } ,
@@ -2122,16 +2119,30 @@ pub(crate) fn dangerous_dev_boot<P: AsRef<Path>>(
21222119 } ,
21232120 } ;
21242121
2125- // Post the share
2126- let req = ProtocolMsg :: ProvisionRequest {
2122+ // Post the share a first time. It won't work because it'll be the first share.
2123+ let req1 = ProtocolMsg :: ProvisionRequest {
21272124 share : eph_pub
2128- . encrypt ( & share )
2125+ . encrypt ( & shares [ 0 ] )
21292126 . expect ( "Failed to encrypt share to eph key." ) ,
2130- approval,
2127+ approval : approval . clone ( ) ,
21312128 } ;
2132- match request:: post ( uri, & req) . unwrap ( ) {
2129+ match request:: post ( uri, & req1) . unwrap ( ) {
2130+ ProtocolMsg :: ProvisionResponse { reconstructed } => {
2131+ assert ! ( !reconstructed, "Quorum Key should NOT be reconstructed (1/2)" ) ;
2132+ }
2133+ r => panic ! ( "Unexpected response: {r:?}" ) ,
2134+ } ;
2135+
2136+ // Post the second share; expected to reconstruct.
2137+ let req2 = ProtocolMsg :: ProvisionRequest {
2138+ share : eph_pub
2139+ . encrypt ( & shares[ 1 ] )
2140+ . expect ( "Failed to encrypt share to eph key." ) ,
2141+ approval : approval. clone ( ) ,
2142+ } ;
2143+ match request:: post ( uri, & req2) . unwrap ( ) {
21332144 ProtocolMsg :: ProvisionResponse { reconstructed } => {
2134- assert ! ( reconstructed, "Quorum Key was not reconstructed" ) ;
2145+ assert ! ( reconstructed, "Quorum Key should be reconstructed (2/2) " ) ;
21352146 }
21362147 r => panic ! ( "Unexpected response: {r:?}" ) ,
21372148 } ;
0 commit comments