How to use the @taquito/utils.hex2buf function in @taquito/utils

To help you get started, we’ve selected a few @taquito/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecadlabs / taquito / packages / taquito-signer / src / taquito-signer.ts View on Github external
async sign(bytes: string, watermark?: Uint8Array) {
    let bb = hex2buf(bytes);
    if (typeof watermark !== 'undefined') {
      bb = mergebuf(watermark, bb);
    }

    const bytesHash = toBuffer(sodium.crypto_generichash(32, bb));

    return this._key.sign(bytes, bytesHash);
  }
github ecadlabs / taquito / packages / taquito-remote-signer / src / taquito-remote-signer.ts View on Github external
async sign(bytes: string, watermark?: Uint8Array) {
    try {
      let bb = hex2buf(bytes);
      if (typeof watermark !== 'undefined') {
        bb = mergebuf(watermark, bb);
      }
      const { signature } = await this.http.createRequest(
        { url: this.createURL(`/keys/${this.pkh}`), method: 'POST' },
        buf2hex(toBuffer(bb))
      );
      let pref = signature.startsWith('sig') ? signature.substr(0, 3) : signature.substr(0, 5);

      const decoded = b58cdecode(signature, prefix[pref]);

      return {
        bytes,
        sig: b58cencode(decoded, prefix.sig),
        prefixSig: signature,
        sbytes: bytes + buf2hex(toBuffer(decoded)),