1 parent 9899f18 commit 7c0eb5dCopy full SHA for 7c0eb5d
1 file changed
crates/cairo-lang-utils/src/bigint.rs
@@ -210,7 +210,8 @@ mod impl_parity_scale_codec {
210
// sign + len packed in the same byte, it allows numbers of byte size up to 63 (2**504),
211
// data.
212
let bits = self.value.bits() as usize;
213
- core::mem::size_of::<u8>() + bits.div_ceil(8)
+ // `encode` always emits at least one data byte (`0` encodes as `[0]`).
214
+ core::mem::size_of::<u8>() + bits.div_ceil(8).max(1)
215
}
216
217
/// /!\ Warning this function panics if the number encoded is too big (>= 2**504).
0 commit comments