findCommonPublicKey function
Returns the single public key present in both lists, throwing if there is not exactly one. Used with two PasskeyKeypair.signAndRecover results.
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;
}