findCommonPublicKey function
Returns the single public key present in both candidate lists; throws if there isn't exactly one common key.
Implementation
PasskeyPublicKey findCommonPublicKey(
List<PasskeyPublicKey> a, List<PasskeyPublicKey> b) {
final matches = <PasskeyPublicKey>[];
for (final x in a) {
for (final y in b) {
if (x.equals(y)) matches.add(x);
}
}
if (matches.length != 1) {
throw ArgumentError('No unique public key found');
}
return matches.first;
}