Summary
Address::from_proto() in starknet-p2p-types can panic on malformed 32-byte public key data instead of returning ProtoError.
Problem
Address::from_proto() checks only that the input length is 32, then calls Address::new(bytes), which reaches PublicKey::from_bytes(bytes). That constructor currently does try_from(...).unwrap().
As a result, invalid Ed25519 public key bytes with the correct length can panic during protobuf decoding.
Fix
Keep this narrow and local:
- validate the 32-byte payload before constructing
Address
- return
ProtoError on invalid key bytes instead of panicking
- add a test covering invalid 32-byte input
If this makes sense, I can open a small PR with the fix and a regression test.
Summary
Address::from_proto()instarknet-p2p-typescan panic on malformed 32-byte public key data instead of returningProtoError.Problem
Address::from_proto()checks only that the input length is 32, then callsAddress::new(bytes), which reachesPublicKey::from_bytes(bytes). That constructor currently doestry_from(...).unwrap().As a result, invalid Ed25519 public key bytes with the correct length can panic during protobuf decoding.
Fix
Keep this narrow and local:
AddressProtoErroron invalid key bytes instead of panickingIf this makes sense, I can open a small PR with the fix and a regression test.