addAuthorizedKey method

Transaction addAuthorizedKey(
  1. dynamic publicKey,
  2. dynamic encryptedSecretKey
)

Add an authorized public key for secret decryption to the transaction with its encrypted secret key @param {String | Uint8List} publicKey Authorized public key (hexadecimal or or binary buffer) @param {String | Uint8List} encryptedSecretKey Encrypted secret key for the given public key (hexadecimal or binary buffer)

Implementation

Transaction addAuthorizedKey(publicKey, encryptedSecretKey) {
  if (!(publicKey is Uint8List) && !(publicKey is String)) {
    throw "'publicKey' must be a string or Uint8List";
  }

  if (!(encryptedSecretKey is Uint8List) && !(encryptedSecretKey is String)) {
    throw "'encryptedSecretKey' must be a string or Uint8List";
  }

  if (publicKey is String) {
    if (!isHex(publicKey)) {
      throw "'publicKey' must be an hexadecimal string";
    }
  } else {
    publicKey = uint8ListToHex(publicKey);
  }

  if (encryptedSecretKey is String) {
    if (!isHex(encryptedSecretKey)) {
      throw "'encryptedSecretKey' must be an hexadecimal string";
    }
  } else {
    encryptedSecretKey = uint8ListToHex(encryptedSecretKey);
  }

  AuthorizedKey authorizedKey = new AuthorizedKey(
      publicKey: publicKey, encryptedKey: encryptedSecretKey);
  if (this.data!.keys!.authorizedKeys!.contains(publicKey) == false) {
    this.data!.keys!.authorizedKeys!.add(authorizedKey);
  }

  return this;
}