From 6cc108a6d4cd212b5eefbf0cb84cefcd2a39efe7 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Wed, 8 May 2024 17:27:33 -0400 Subject: [PATCH 1/4] add rpc insecure url --- crates/client/src/chain_api.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/client/src/chain_api.rs b/crates/client/src/chain_api.rs index 1e83fb1d4..db4189453 100644 --- a/crates/client/src/chain_api.rs +++ b/crates/client/src/chain_api.rs @@ -45,7 +45,8 @@ pub async fn get_api(url: &str) -> Result, subxt::Er /// Creates a rpc instance to talk to chain /// Chain endpoint set on launch pub async fn get_rpc(url: &str) -> Result, subxt::Error> { - let rpc_client = RpcClient::from_url(url).await?; + // insecure url is fine since binaries are on the same machine + let rpc_client = RpcClient::from_insecure_url(url).await?; let rpc_methods = LegacyRpcMethods::::new(rpc_client); Ok(rpc_methods) } From 9f844ee0c64f1a0627beaab54795772b443da0f7 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Mon, 13 May 2024 16:42:44 -0400 Subject: [PATCH 2/4] Fix account deserilization error --- .../threshold-signature-server/src/signing_client/api.rs | 1 + crates/threshold-signature-server/src/user/api.rs | 7 +++++-- crates/threshold-signature-server/src/user/tests.rs | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/threshold-signature-server/src/signing_client/api.rs b/crates/threshold-signature-server/src/signing_client/api.rs index 17beca6d7..8c5c4bd6c 100644 --- a/crates/threshold-signature-server/src/signing_client/api.rs +++ b/crates/threshold-signature-server/src/signing_client/api.rs @@ -143,6 +143,7 @@ pub async fn proactive_refresh( key, value: serialized_key_share, proactive_refresh: true, + sig_request_address: None, }; app_state.kv_store.kv().delete(&new_key_info.key).await?; diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index 5949792e0..bd6b16b57 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -95,6 +95,7 @@ pub struct UserRegistrationInfo { pub value: Vec, /// Is this a proactive refresh message pub proactive_refresh: bool, + pub sig_request_address: Option, } /// Type that gets stored for request limit checks @@ -331,6 +332,7 @@ async fn setup_dkg( key: string_verifying_key, value: serialized_key_share, proactive_refresh: false, + sig_request_address: Some(sig_request_address.clone()), }; send_key( &api, @@ -414,8 +416,9 @@ pub async fn receive_key( let registering = is_registering( &api, &rpc, - &SubxtAccountId32::from_str(&user_registration_info.key) - .map_err(|_| UserErr::StringError("Account Conversion"))?, + &user_registration_info.sig_request_address.ok_or_else(|| { + UserErr::OptionUnwrapError("Failed to unwrap account".to_string()) + })?, ) .await?; diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index e9e32d55c..eed597016 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -790,6 +790,7 @@ async fn test_send_and_receive_keys() { let alice = AccountKeyring::Alice; let program_manager = AccountKeyring::Dave; + let signature_request_account = subxtAccountId32(alice.pair().public().0); let cxt = test_context_stationary().await; setup_client().await; @@ -805,6 +806,7 @@ async fn test_send_and_receive_keys() { key: alice.to_account_id().to_string(), value: share.clone(), proactive_refresh: false, + sig_request_address: Some(signature_request_account.clone()), }; let (signer_alice, _) = get_signer_and_x25519_secret_from_mnemonic(DEFAULT_MNEMONIC).unwrap(); @@ -888,6 +890,7 @@ async fn test_send_and_receive_keys() { key: alice.to_account_id().to_string(), value: some_other_share.clone(), proactive_refresh: false, + sig_request_address: Some(signature_request_account.clone()), }; let signed_message = serde_json::to_string( @@ -929,6 +932,7 @@ async fn test_send_and_receive_keys() { key: "MNEMONIC".to_string(), value: share.clone(), proactive_refresh: false, + sig_request_address: Some(signature_request_account.clone()), }; let signed_message = serde_json::to_string( @@ -958,6 +962,7 @@ async fn test_send_and_receive_keys() { key: alice.to_account_id().to_string(), value: b"This will not deserialize to KeyShare".to_vec(), proactive_refresh: false, + sig_request_address: Some(signature_request_account.clone()), }; let signed_message = serde_json::to_string( From 464144409ec5e8fbad8c6f5f0ac2b19304deb740 Mon Sep 17 00:00:00 2001 From: JesseAbram <33698952+JesseAbram@users.noreply.github.com> Date: Mon, 13 May 2024 18:36:28 -0700 Subject: [PATCH 3/4] Update crates/threshold-signature-server/src/user/api.rs Co-authored-by: Hernando Castano --- crates/threshold-signature-server/src/user/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index bd6b16b57..7dcaf7d9c 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -417,7 +417,7 @@ pub async fn receive_key( &api, &rpc, &user_registration_info.sig_request_address.ok_or_else(|| { - UserErr::OptionUnwrapError("Failed to unwrap account".to_string()) + UserErr::OptionUnwrapError("Failed to unwrap signature request account".to_string()) })?, ) .await?; From a1a5c0588cddae95ff5be28a87f7d885f60a26f4 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Mon, 13 May 2024 21:37:39 -0400 Subject: [PATCH 4/4] add missing doc --- crates/threshold-signature-server/src/user/api.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index 7dcaf7d9c..b243c383e 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -95,6 +95,7 @@ pub struct UserRegistrationInfo { pub value: Vec, /// Is this a proactive refresh message pub proactive_refresh: bool, + /// The sig_req_account to check if user is registering pub sig_request_address: Option, }