tryParse static method
Attempts to parse a stateless reset packet from bytes. Returns null if the packet is too small or doesn't have a token at the end.
Implementation
static StatelessResetPacket? tryParse(Uint8List bytes) {
if (bytes.length < minPacketSize) {
return null;
}
// Extract last 16 bytes as potential token
final tokenBytes = bytes.sublist(bytes.length - StatelessResetToken.length);
final token = StatelessResetToken(tokenBytes);
// Extract random bytes
final randomBytes = bytes.sublist(0, bytes.length - StatelessResetToken.length);
return StatelessResetPacket(
token: token,
randomBytes: randomBytes,
);
}