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

Fix Account Deserialization error from verifying key mismatch #831

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
8 changes: 6 additions & 2 deletions crates/threshold-signature-server/src/user/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub struct UserRegistrationInfo {
pub value: Vec<u8>,
/// 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<SubxtAccountId32>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs

}

/// Type that gets stored for request limit checks
Expand Down Expand Up @@ -331,6 +333,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,
Expand Down Expand Up @@ -414,8 +417,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 signature request account".to_string())
})?,
)
.await?;

Expand Down
5 changes: 5 additions & 0 deletions crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<KeyParams>".to_vec(),
proactive_refresh: false,
sig_request_address: Some(signature_request_account.clone()),
};

let signed_message = serde_json::to_string(
Expand Down