Skip to content

Commit 7fc6912

Browse files
committed
chore(ecdsa): [CON-1326] deprecate KeyTranscriptsLayout
1 parent 8311999 commit 7fc6912

File tree

6 files changed

+6
-123
lines changed

6 files changed

+6
-123
lines changed

rs/consensus/src/consensus/metrics.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,7 @@ impl EcdsaPayloadMetrics {
877877
"xnet_reshare_agreements",
878878
count_by_master_public_key_id(payload.xnet_reshare_agreements.keys(), &expected_keys),
879879
);
880-
self.payload_metrics_set_without_key_id_label(
881-
"payload_layout_multiple_keys",
882-
payload.is_multiple_keys_layout() as usize,
883-
);
880+
self.payload_metrics_set_without_key_id_label("payload_layout_multiple_keys", 1);
884881
self.payload_metrics_set_without_key_id_label(
885882
"payload_layout_generalized_pre_signatures",
886883
1,

rs/consensus/src/ecdsa/payload_builder.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ fn create_summary_payload_helper(
303303
ecdsa_summary.uid_generator.update_height(height)?;
304304
update_summary_refs(height, &mut ecdsa_summary, block_reader)?;
305305

306-
ecdsa_summary.use_multiple_keys_layout();
307-
308306
Ok(Some(ecdsa_summary))
309307
}
310308

@@ -570,8 +568,6 @@ pub(crate) fn create_data_payload_helper(
570568
log,
571569
)?;
572570

573-
ecdsa_payload.use_multiple_keys_layout();
574-
575571
Ok(Some(ecdsa_payload))
576572
}
577573

rs/protobuf/def/types/v1/idkg.proto

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "types/v1/signature.proto";
99
import "types/v1/types.proto";
1010

1111
message EcdsaPayload {
12-
reserved 2, 3, 4;
12+
reserved 2, 3, 4, 9, 11, 12;
1313
repeated CompletedSignature signature_agreements = 1;
1414
registry.subnet.v1.IDkgTranscriptId next_unused_transcript_id = 5;
1515
repeated registry.subnet.v1.IDkgTranscript idkg_transcripts = 6;
@@ -19,10 +19,6 @@ message EcdsaPayload {
1919
repeated EcdsaKeyTranscript key_transcripts = 13;
2020
repeated AvailablePreSignature available_pre_signatures = 14;
2121
repeated PreSignatureInProgress pre_signatures_in_creation = 15;
22-
// TODO: retire these fields, once we start using `key_transcripts`.
23-
UnmaskedTranscriptWithAttributes current_key_transcript = 9;
24-
KeyTranscriptCreation next_key_in_creation = 11;
25-
registry.crypto.v1.EcdsaKeyId key_id = 12;
2622
// TODO: retire these fields, once we start using `pre_signatures`.
2723
bool generalized_pre_signatures = 16;
2824
}

rs/protobuf/src/gen/types/types.v1.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,6 @@ pub struct EcdsaPayload {
402402
pub available_pre_signatures: ::prost::alloc::vec::Vec<AvailablePreSignature>,
403403
#[prost(message, repeated, tag = "15")]
404404
pub pre_signatures_in_creation: ::prost::alloc::vec::Vec<PreSignatureInProgress>,
405-
/// TODO: retire these fields, once we start using `key_transcripts`.
406-
#[prost(message, optional, tag = "9")]
407-
pub current_key_transcript: ::core::option::Option<UnmaskedTranscriptWithAttributes>,
408-
#[prost(message, optional, tag = "11")]
409-
pub next_key_in_creation: ::core::option::Option<KeyTranscriptCreation>,
410-
#[prost(message, optional, tag = "12")]
411-
pub key_id: ::core::option::Option<super::super::registry::crypto::v1::EcdsaKeyId>,
412405
/// TODO: retire these fields, once we start using `pre_signatures`.
413406
#[prost(bool, tag = "16")]
414407
pub generalized_pre_signatures: bool,

rs/types/types/src/consensus/idkg.rs

Lines changed: 2 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,10 @@ pub enum CompletedSignature {
6161
Unreported(crate::batch::ConsensusResponse),
6262
}
6363

64-
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
65-
#[cfg_attr(test, derive(ExhaustiveSet))]
66-
/// The original layout of the ecdsa payload.
67-
/// Since the payload produced by the older replica version might use a single key transcript as a
68-
/// field, we need this extra bit information in order to know how to serialize it back to the
69-
/// proto format readable by that replica version.
70-
pub(crate) enum EcdsaPayloadLayout {
71-
/// The obsolete layout of the ecdsa payload:
72-
/// 1. The `current_key_transcript`, `next_key_in_creation`, and `key_id` fields in
73-
/// `pb::EcdasPayload` are are set to `Some` values;
74-
/// 2. The `Hash` implementation uses the only key transcript in the payload.
75-
SingleKeyTranscript,
76-
/// The new layout of the ecdsa payload:
77-
/// 1. The `current_key_transcript`, `next_key_in_creation`, and `key_id` fields in
78-
/// `pb::EcdasPayload` are are set to `None` values;
79-
/// 2. The `Hash` implementation uses the whole collection of the key transcripts.
80-
MultipleKeyTranscripts,
81-
}
82-
8364
/// Common data that is carried in both `EcdsaSummaryPayload` and `EcdsaDataPayload`.
8465
/// published on every consensus round. It represents the current state of the
8566
/// protocol since the summary block.
86-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
67+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
8768
pub struct EcdsaPayload {
8869
/// Collection of completed signatures.
8970
pub signature_agreements: BTreeMap<PseudoRandomId, CompletedSignature>,
@@ -108,32 +89,6 @@ pub struct EcdsaPayload {
10889

10990
/// State of the key transcripts.
11091
pub key_transcripts: BTreeMap<MasterPublicKeyId, EcdsaKeyTranscript>,
111-
112-
/// Temporary field.
113-
/// Once all ecdsa payload have been using the new proto style, this field should be dropped.
114-
pub(crate) layout: EcdsaPayloadLayout,
115-
}
116-
117-
impl Hash for EcdsaPayload {
118-
fn hash<H: Hasher>(&self, state: &mut H) {
119-
self.signature_agreements.hash(state);
120-
self.available_pre_signatures.hash(state);
121-
self.pre_signatures_in_creation.hash(state);
122-
self.uid_generator.hash(state);
123-
self.idkg_transcripts.hash(state);
124-
self.ongoing_xnet_reshares.hash(state);
125-
self.xnet_reshare_agreements.hash(state);
126-
match self.layout {
127-
EcdsaPayloadLayout::SingleKeyTranscript => {
128-
// This is safe as there is always at least one key transcript in the payload
129-
self.key_transcripts.values().next().unwrap().hash(state);
130-
}
131-
EcdsaPayloadLayout::MultipleKeyTranscripts => {
132-
self.key_transcripts.hash(state);
133-
}
134-
}
135-
// ignoring the [`EcdsaPayload::layout`] field on purpose
136-
}
13792
}
13893

13994
impl EcdsaPayload {
@@ -155,19 +110,9 @@ impl EcdsaPayload {
155110
idkg_transcripts: BTreeMap::new(),
156111
ongoing_xnet_reshares: BTreeMap::new(),
157112
xnet_reshare_agreements: BTreeMap::new(),
158-
layout: EcdsaPayloadLayout::MultipleKeyTranscripts,
159113
}
160114
}
161115

162-
/// Return true if this payload uses the new layout supporting multiple key transcripts
163-
pub fn is_multiple_keys_layout(&self) -> bool {
164-
matches!(self.layout, EcdsaPayloadLayout::MultipleKeyTranscripts)
165-
}
166-
167-
pub fn use_multiple_keys_layout(&mut self) {
168-
self.layout = EcdsaPayloadLayout::MultipleKeyTranscripts;
169-
}
170-
171116
/// Returns the reference to the current key transcript of the given [`MasterPublicKeyId`].
172117
pub fn current_key_transcript(
173118
&self,
@@ -1778,28 +1723,6 @@ impl From<&EcdsaPayload> for pb::EcdsaPayload {
17781723
.map(pb::EcdsaKeyTranscript::from)
17791724
.collect();
17801725

1781-
// Populate the deprecated singular fields in the proto if and only if we are using the
1782-
// [`EcdsaPayloadLayout::SingleKeyTranscript'] layout.
1783-
let pb::EcdsaKeyTranscript {
1784-
key_id,
1785-
current: current_key_transcript,
1786-
next_in_creation: next_key_in_creation,
1787-
master_key_id: _,
1788-
} = match payload.layout {
1789-
EcdsaPayloadLayout::SingleKeyTranscript => key_transcripts
1790-
.first()
1791-
.cloned()
1792-
.unwrap_or_else(pb::EcdsaKeyTranscript::default),
1793-
EcdsaPayloadLayout::MultipleKeyTranscripts => pb::EcdsaKeyTranscript::default(),
1794-
};
1795-
1796-
// Populate the new repeated field in the proto if and only if we are using the
1797-
// [`EcdsaPayloadLayout::MultipleKeyTranscripts'] layout.
1798-
let key_transcripts = match payload.layout {
1799-
EcdsaPayloadLayout::SingleKeyTranscript => vec![],
1800-
EcdsaPayloadLayout::MultipleKeyTranscripts => key_transcripts,
1801-
};
1802-
18031726
Self {
18041727
signature_agreements,
18051728
available_pre_signatures,
@@ -1811,9 +1734,6 @@ impl From<&EcdsaPayload> for pb::EcdsaPayload {
18111734
xnet_reshare_agreements,
18121735
key_transcripts,
18131736
// Kept for backwards compatibility
1814-
current_key_transcript,
1815-
next_key_in_creation,
1816-
key_id,
18171737
generalized_pre_signatures: true,
18181738
}
18191739
}
@@ -1831,26 +1751,9 @@ impl TryFrom<(&pb::EcdsaPayload, Height)> for EcdsaPayload {
18311751
impl TryFrom<&pb::EcdsaPayload> for EcdsaPayload {
18321752
type Error = ProxyDecodeError;
18331753
fn try_from(payload: &pb::EcdsaPayload) -> Result<Self, Self::Error> {
1834-
let key_transcripts_protos = if !payload.key_transcripts.is_empty() {
1835-
payload.key_transcripts.clone()
1836-
} else {
1837-
vec![pb::EcdsaKeyTranscript {
1838-
key_id: payload.key_id.clone(),
1839-
current: payload.current_key_transcript.clone(),
1840-
next_in_creation: payload.next_key_in_creation.clone(),
1841-
master_key_id: None,
1842-
}]
1843-
};
1844-
1845-
let layout = if payload.key_id.is_some() {
1846-
EcdsaPayloadLayout::SingleKeyTranscript
1847-
} else {
1848-
EcdsaPayloadLayout::MultipleKeyTranscripts
1849-
};
1850-
18511754
let mut key_transcripts = BTreeMap::new();
18521755

1853-
for key_transcript_proto in key_transcripts_protos {
1756+
for key_transcript_proto in &payload.key_transcripts {
18541757
let key_transcript = EcdsaKeyTranscript::try_from(key_transcript_proto)?;
18551758

18561759
key_transcripts.insert(key_transcript.key_id(), key_transcript);
@@ -1970,7 +1873,6 @@ impl TryFrom<&pb::EcdsaPayload> for EcdsaPayload {
19701873
xnet_reshare_agreements,
19711874
uid_generator,
19721875
key_transcripts,
1973-
layout,
19741876
})
19751877
}
19761878
}

rs/types/types/src/exhaustive.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::consensus::idkg::common::{PreSignatureInCreation, PreSignatureRef};
55
use crate::consensus::idkg::ecdsa::{QuadrupleInCreation, ThresholdEcdsaSigInputsRef};
66
use crate::consensus::idkg::{
77
CompletedReshareRequest, CompletedSignature, EcdsaKeyTranscript, EcdsaPayload,
8-
EcdsaPayloadLayout, EcdsaReshareRequest, EcdsaUIDGenerator, HasMasterPublicKeyId,
9-
KeyTranscriptCreation, MaskedTranscript, PreSigId, PseudoRandomId, RandomTranscriptParams,
8+
EcdsaReshareRequest, EcdsaUIDGenerator, HasMasterPublicKeyId, KeyTranscriptCreation,
9+
MaskedTranscript, PreSigId, PseudoRandomId, RandomTranscriptParams,
1010
RandomUnmaskedTranscriptParams, RequestId, ReshareOfMaskedParams, ReshareOfUnmaskedParams,
1111
UnmaskedTimesMaskedParams, UnmaskedTranscript, UnmaskedTranscriptWithAttributes,
1212
};
@@ -774,7 +774,6 @@ impl ExhaustiveSet for EcdsaPayload {
774774
ongoing_xnet_reshares: payload.ongoing_xnet_reshares,
775775
xnet_reshare_agreements: payload.xnet_reshare_agreements,
776776
key_transcripts: replace_by_singleton_if_empty(payload.key_transcripts, rng),
777-
layout: EcdsaPayloadLayout::MultipleKeyTranscripts,
778777
})
779778
.collect()
780779
}

0 commit comments

Comments
 (0)