isValidKeyEncoding static method

bool isValidKeyEncoding(
  1. List<int> keyBytes,
  2. CryptoKeyEncoding encoding
)
override

Checks whether keyBytes has a valid length for the given encoding under any ML-DSA level.

This check validates only the key length and does not verify whether keyBytes represents a valid public key.

Implementation

static bool isValidKeyEncoding(
  List<int> keyBytes,
  CryptoKeyEncoding encoding,
) {
  return switch (encoding) {
    CryptoKeyEncoding.base
        when MLDSAParams.isValidPublicKeyBytesLength(keyBytes) =>
      true,
    _ => false,
  };
}