@@ -78,12 +78,12 @@ use crate::factors::TranscryptionInfo;
7878use crate :: factors:: {
7979 AttributeRekeyInfo , PseudonymRekeyInfo , PseudonymizationInfo , RerandomizeFactor ,
8080} ;
81+ #[ cfg( feature = "offline" ) ]
82+ use crate :: keys:: { AttributeGlobalPublicKey , PseudonymGlobalPublicKey } ;
8183use crate :: keys:: {
8284 AttributeSessionPublicKey , AttributeSessionSecretKey , PseudonymSessionPublicKey ,
8385 PseudonymSessionSecretKey ,
8486} ;
85- #[ cfg( feature = "offline" ) ]
86- use crate :: keys:: { AttributeGlobalPublicKey , PseudonymGlobalPublicKey } ;
8787use derive_more:: { Deref , From } ;
8888use rand_core:: { CryptoRng , Rng } ;
8989#[ cfg( feature = "serde" ) ]
@@ -1164,7 +1164,8 @@ fn to_bytes_padded_impl<T: ElGamalEncryptable>(items: &[T]) -> Result<Vec<u8>, E
11641164
11651165 if let Some ( original_count) = is_external_padding_block ( & last_block) {
11661166 // We have external padding, use the encoded original block count
1167- if original_count > items. len ( ) {
1167+ // Check for underflow: original_count must be at least 1
1168+ if original_count == 0 || original_count > items. len ( ) {
11681169 return Err ( Error :: new (
11691170 ErrorKind :: InvalidData ,
11701171 "External padding contains invalid block count" ,
0 commit comments