decodeIss function

Uint8List decodeIss(
  1. String issuer
)

Implementation

Uint8List decodeIss(String issuer) {
  final split = issuer.split(DID_DELIMITER);
  final prefix = split[0];
  final method = split[1];
  final multicodec = split[2];
  if (prefix != DID_PREFIX || method != DID_METHOD) {
    throw WCException('Issuer must be a DID with method "key"');
  }
  final base = multicodec.substring(0, 1);
  if (base != MULTICODEC_ED25519_BASE) {
    throw WCException('Issuer must be a key in mulicodec format');
  }
  final bytes = base58.decode(multicodec.substring(1));
  final type = base58.encode(bytes.sublist(0, 2));
  if (type != MULTICODEC_ED25519_HEADER) {
    throw WCException('Issuer must be a public key with type "Ed25519"');
  }
  final publicKey = bytes.sublist(2);
  if (publicKey.length != MULTICODEC_ED25519_LENGTH) {
    throw WCException('Issuer must be a public key with length 32 bytes');
  }
  return publicKey;
}