wcDecodeIss function
Decode a did:key issuer string back to the 32-byte Ed25519 public key.
Implementation
Uint8List wcDecodeIss(String iss) {
const prefix = 'did:key:';
if (!iss.startsWith(prefix)) {
throw FormatException('not a did:key: $iss');
}
final multibase = iss.substring(prefix.length);
if (!multibase.startsWith(_multicodecEd25519Header)) {
throw FormatException('unexpected multibase prefix');
}
final decoded = _base58Decode(multibase.substring(1));
if (decoded.length < 2 ||
decoded[0] != _ed25519PubMulticodec[0] ||
decoded[1] != _ed25519PubMulticodec[1]) {
throw FormatException('unexpected multicodec prefix');
}
return Uint8List.fromList(decoded.sublist(2));
}