From 9f74f6c16dd1164c0719095c6e6b98f1f324e4db Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Mon, 3 Aug 2026 17:50:43 +0200 Subject: [PATCH] Remove bogus MaxEncodedLen and TypeInfo impls from ProverState --- CHANGELOG.md | 3 +++ src/ring/mod.rs | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4d804..7800e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,9 @@ All changes are relative to 0.2.0, the last published version. - ark-serialize validation is enabled when decoding types that may come from untrusted sources - **Reject trailing bytes when deserializing signatures and proofs** ([#48](https://github.com/paritytech/verifiable/pull/48)) - Enforces a canonical encoding, preventing malleability via appended bytes +- **Remove bogus `MaxEncodedLen`/`ArkScaleMaxEncodedLen`/`TypeInfo` impls from `ProverState`** + - The impls reported a zero maximum encoded length while real encodings are hundreds of + kilobytes; there is no meaningful type-level bound since the size depends on the domain - **Reject the identity point in member validation and construction** ([#57](https://github.com/paritytech/verifiable/pull/57)) - The neutral element passed `is_member_valid` but made `push_members` panic inside the ring backend; both paths now reject it with `Error::InvalidMember` diff --git a/src/ring/mod.rs b/src/ring/mod.rs index 491dc57..c5a3880 100644 --- a/src/ring/mod.rs +++ b/src/ring/mod.rs @@ -301,6 +301,30 @@ impl Get for MaxRingVrfSignatureLen { macro_rules! impl_common_traits { ($type_name:ident, $size_expr:expr) => { + impl_common_traits!($type_name); + + impl scale::MaxEncodedLen for $type_name { + fn max_encoded_len() -> usize { + $size_expr + } + } + + impl ark_scale::ArkScaleMaxEncodedLen for $type_name { + fn max_encoded_len(_compress: ark_serialize::Compress) -> usize { + $size_expr + } + } + + impl scale_info::TypeInfo for $type_name { + type Identity = Self; + fn type_info() -> scale_info::Type { + let mut info = >::type_info(); + info.path = scale_info::Path::new(stringify!($type_name), module_path!()); + info + } + } + }; + ($type_name:ident) => { impl Decode for $type_name { fn decode( input: &mut I, @@ -352,27 +376,6 @@ macro_rules! impl_common_traits { impl scale::EncodeLike for $type_name {} - impl scale::MaxEncodedLen for $type_name { - fn max_encoded_len() -> usize { - $size_expr - } - } - - impl ark_scale::ArkScaleMaxEncodedLen for $type_name { - fn max_encoded_len(_compress: ark_serialize::Compress) -> usize { - $size_expr - } - } - - impl scale_info::TypeInfo for $type_name { - type Identity = Self; - fn type_info() -> scale_info::Type { - let mut info = >::type_info(); - info.path = scale_info::Path::new(stringify!($type_name), module_path!()); - info - } - } - impl core::cmp::PartialEq for $type_name { fn eq(&self, other: &Self) -> bool { self.encode() == other.encode() @@ -485,7 +488,7 @@ pub struct ProverState { pub(crate) prover_key: ark_vrf::ring::RingProverKey, } -impl_common_traits!(ProverState, 0); +impl_common_traits!(ProverState); impl core::fmt::Debug for ProverState { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {