bestKeyFor method

PackageKey? bestKeyFor(
  1. List<String> supportedAlgos, {
  2. String use = SecretSharingAlgos.useEnc,
})

The first key in supportedAlgos order (strongest first) that this key package advertises for use. Returns null if the package and supportedAlgos have no algorithm in common.

Implementation

PackageKey? bestKeyFor(List<String> supportedAlgos,
    {String use = SecretSharingAlgos.useEnc}) {
  for (final alg in supportedAlgos) {
    for (final key in keys) {
      if (key.alg == alg && key.use == use) {
        return key;
      }
    }
  }
  return null;
}