Skip to content

Commit 3c015d2

Browse files
committed
refactor(common): gate Rigid scheme variant of ProtocolMessage behind 'future_snark'
1 parent f6e1fcb commit 3c015d2

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

mithril-common/src/entities/protocol_message.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub enum ProtocolMessageHashScheme {
8383
Legacy,
8484

8585
/// Lagrange SNARK-friendly hash scheme.
86+
#[cfg(feature = "future_snark")]
8687
#[serde(rename = "rigid")]
8788
Rigid,
8889
}
@@ -224,27 +225,27 @@ impl ProtocolMessage {
224225
self.message_parts.get(key)
225226
}
226227

227-
/// Return `true` if the protocol message uses the [ProtocolMessageHashScheme::Rigid] hash
228-
/// scheme.
228+
/// Return `true` if the protocol message uses the rigid hash scheme. Always `false` when
229+
/// the `future_snark` feature is disabled (the variant does not exist there).
229230
pub fn is_rigid(&self) -> bool {
230-
if cfg!(feature = "future_snark") {
231+
#[cfg(feature = "future_snark")]
232+
{
231233
self.hash_scheme == ProtocolMessageHashScheme::Rigid
232-
} else {
234+
}
235+
#[cfg(not(feature = "future_snark"))]
236+
{
237+
let _ = self;
233238
false
234239
}
235240
}
236241

237242
/// Compute the hex-encoded SHA-256 hash of the protocol message, dispatching over
238-
/// [ProtocolMessage::hash_scheme]. The rigid scheme requires `future_snark`; without it,
239-
/// rigid messages fall back to the legacy hash (signals misconfiguration via signature
240-
/// mismatch downstream).
243+
/// [ProtocolMessage::hash_scheme].
241244
pub fn compute_hash(&self) -> String {
242245
match self.hash_scheme {
243246
ProtocolMessageHashScheme::Legacy => self.compute_legacy_hash(),
244247
#[cfg(feature = "future_snark")]
245248
ProtocolMessageHashScheme::Rigid => self.compute_rigid_hash(),
246-
#[cfg(not(feature = "future_snark"))]
247-
ProtocolMessageHashScheme::Rigid => self.compute_legacy_hash(),
248249
}
249250
}
250251

0 commit comments

Comments
 (0)