From f5c09c85fbbc9dadd96eee9df0e9371dc5fc6be5 Mon Sep 17 00:00:00 2001 From: Zac Holme <79027434+Zacholme7@users.noreply.github.com> Date: Mon, 17 Feb 2025 01:44:23 -0600 Subject: [PATCH] Signature mismatch fix (#142) --- anchor/common/ssv_types/src/message.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/anchor/common/ssv_types/src/message.rs b/anchor/common/ssv_types/src/message.rs index 1da0008e..11db3252 100644 --- a/anchor/common/ssv_types/src/message.rs +++ b/anchor/common/ssv_types/src/message.rs @@ -311,8 +311,19 @@ impl SignedSSVMessage { self.operator_ids.extend(signed_msg.operator_ids); } - self.signatures.sort(); - self.operator_ids.sort(); + // Maintain id <-> sig pairing during sorting + let mut sig_pairs: Vec<_> = self + .signatures + .iter() + .cloned() + .zip(self.operator_ids.iter()) + .collect(); + + sig_pairs.sort_by_key(|&(_, op_id)| *op_id); + + let (sorted_signatures, sorted_operator_ids) = sig_pairs.into_iter().unzip(); + self.signatures = sorted_signatures; + self.operator_ids = sorted_operator_ids; } // Validate the signed message to ensure that it is well formed for qbft processing