@@ -61,29 +61,10 @@ pub enum CompletedSignature {
61
61
Unreported ( crate :: batch:: ConsensusResponse ) ,
62
62
}
63
63
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
-
83
64
/// Common data that is carried in both `EcdsaSummaryPayload` and `EcdsaDataPayload`.
84
65
/// published on every consensus round. It represents the current state of the
85
66
/// protocol since the summary block.
86
- #[ derive( Clone , Debug , PartialEq , Eq , Serialize , Deserialize ) ]
67
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
87
68
pub struct EcdsaPayload {
88
69
/// Collection of completed signatures.
89
70
pub signature_agreements : BTreeMap < PseudoRandomId , CompletedSignature > ,
@@ -108,32 +89,6 @@ pub struct EcdsaPayload {
108
89
109
90
/// State of the key transcripts.
110
91
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
- }
137
92
}
138
93
139
94
impl EcdsaPayload {
@@ -155,19 +110,9 @@ impl EcdsaPayload {
155
110
idkg_transcripts : BTreeMap :: new ( ) ,
156
111
ongoing_xnet_reshares : BTreeMap :: new ( ) ,
157
112
xnet_reshare_agreements : BTreeMap :: new ( ) ,
158
- layout : EcdsaPayloadLayout :: MultipleKeyTranscripts ,
159
113
}
160
114
}
161
115
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
-
171
116
/// Returns the reference to the current key transcript of the given [`MasterPublicKeyId`].
172
117
pub fn current_key_transcript (
173
118
& self ,
@@ -1778,28 +1723,6 @@ impl From<&EcdsaPayload> for pb::EcdsaPayload {
1778
1723
. map ( pb:: EcdsaKeyTranscript :: from)
1779
1724
. collect ( ) ;
1780
1725
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
-
1803
1726
Self {
1804
1727
signature_agreements,
1805
1728
available_pre_signatures,
@@ -1811,9 +1734,6 @@ impl From<&EcdsaPayload> for pb::EcdsaPayload {
1811
1734
xnet_reshare_agreements,
1812
1735
key_transcripts,
1813
1736
// Kept for backwards compatibility
1814
- current_key_transcript,
1815
- next_key_in_creation,
1816
- key_id,
1817
1737
generalized_pre_signatures : true ,
1818
1738
}
1819
1739
}
@@ -1831,26 +1751,9 @@ impl TryFrom<(&pb::EcdsaPayload, Height)> for EcdsaPayload {
1831
1751
impl TryFrom < & pb:: EcdsaPayload > for EcdsaPayload {
1832
1752
type Error = ProxyDecodeError ;
1833
1753
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
-
1851
1754
let mut key_transcripts = BTreeMap :: new ( ) ;
1852
1755
1853
- for key_transcript_proto in key_transcripts_protos {
1756
+ for key_transcript_proto in & payload . key_transcripts {
1854
1757
let key_transcript = EcdsaKeyTranscript :: try_from ( key_transcript_proto) ?;
1855
1758
1856
1759
key_transcripts. insert ( key_transcript. key_id ( ) , key_transcript) ;
@@ -1970,7 +1873,6 @@ impl TryFrom<&pb::EcdsaPayload> for EcdsaPayload {
1970
1873
xnet_reshare_agreements,
1971
1874
uid_generator,
1972
1875
key_transcripts,
1973
- layout,
1974
1876
} )
1975
1877
}
1976
1878
}
0 commit comments