readPublicKey static method

String readPublicKey(
  1. String hex,
  2. Uint8List b
)

Implementation

static String readPublicKey(String hex, Uint8List b) {
  if (hex.length != 66 && hex.length != 68) {
    throw new Exception("Incorrect hex length, ${hex.length} to parse a key");
  }
  var hint = hex.substring(0, 2);
  if (hint == "00") {
    return GenerateKeys.readKeysWithHint(
        b, GenerateKeys.keyPrefixes[PrefixEnum.edpk]!);
  } else if (hint == "01" && hex.length == 68) {
    return GenerateKeys.readKeysWithHint(
        b, GenerateKeys.keyPrefixes[PrefixEnum.sppk]!);
  } else if (hint == "02" && hex.length == 68) {
    return GenerateKeys.readKeysWithHint(
        b, GenerateKeys.keyPrefixes[PrefixEnum.p2pk]!);
  } else {
    throw new Exception('Unrecognized key type');
  }
}