message: Added verify signature function in PublicAccount class
diff: * limitations under the License.
  */
  +import { KeyPair, convert } from 'nem2-library';
  import { NetworkType } from '../blockchain/NetworkType';
  import { Address } from './Address';
  @@ -53,6 +54,48 @@ export class PublicAccount {
  return new PublicAccount(publicKey, address);
  }
  + /**
  + * Verify a signature.
  + *
  + * @param {string} publicKey - The public key to use for verification.
  + * @param {string} data - The data to verify.
  + * @param {string} signature - The signature to verify.
  + *
  + * @return {boolean} - True if the signature is valid, false otherwise.
  + */
  + static verifySignature(publicKey: string, data: string, signature: string): boolean {
  + if (!publicKey || !data || !signature) {
  + throw new Error('Missing argument !');
  + }
  +
  + if (publicKey.length !== 64 && publicKey.length !== 66) {
  + throw new Error('Not a valid public key');
  + }
  +
  + if (convert.isHexString(signature)) {
  + throw new Error('Signature must be hexadecimal only !');
  + }
  +
  + if (signature.length !== 128) {
  + throw new Error('Signature length is incorrect !');
  + }
  +
  + // Convert signature key to Uint8Array
  + const _signature = convert.hexToUint8(signature);
  +
  + let _data;
  +
  + // Convert data to hex if data is not hex
  + if (!convert.isHexString(data)) {
  + _data = convert.utf8ToHex(data);
  + }
  +
  + // Convert to Uint8Array
  + _data = convert.hexToUint8(_data);
  +
  + return KeyPair.verify(publicKey, _data, _signature);
  + }
  +
  /**
  * Compares public accounts for equality.
  * @param publicAccount
  @@ -61,4 +104,5 @@ export class PublicAccount {
  equals(publicAccount: PublicAccount) {
  return this.publicKey === publicAccount.publicKey && this.address.plain() === publicAccount.address.plain();
  }
  +
  }
  