async signTransaction(tx) {
          if (!tx.active) throw new Error("Active data is not defined");
          const hash = sha256_1.sha256(utils_1.decodeBase64(tx.active));
          const [compSignature, recovery] = await secp.sign(
            hash,
            this.privateKey,
            {
              recovered: true,
              canonical: true,
              der: false, // compact signature
            }
          );
          const compactSignature = new Uint8Array(65);
          compactSignature.set([recovery + 31], 0);
          compactSignature.set(compSignature, 1);
          tx.signature_data = utils_1.encodeBase64(compactSignature);
          const multihash = `0x1220${utils_1.toHexString(hash)}`; // 12: code sha2-256. 20: length (32 bytes)
          tx.id = multihash;
          return tx;
        }
/**
         * Function to sign a transaction. It's important to remark that
         * the transaction parameter is modified inside this function.
         * @param tx - Unsigned transaction
         * @returns
         */
Function to sign a transaction. It's important to remark that
the transaction parameter is modified inside this function.
@param tx - Unsigned transaction
@returns
Function to sign a transaction . It ' s important to remark that the transaction parameter is modified inside this function . @param tx - Unsigned transaction @returns
async signTransaction(tx) {
          if (!tx.active) throw new Error("Active data is not defined");
          const hash = sha256_1.sha256(utils_1.decodeBase64(tx.active));
          const [compSignature, recovery] = await secp.sign(
            hash,
            this.privateKey,
            {
              recovered: true,
              canonical: true,
              der: false, 
            }
          );
          const compactSignature = new Uint8Array(65);
          compactSignature.set([recovery + 31], 0);
          compactSignature.set(compSignature, 1);
          tx.signature_data = utils_1.encodeBase64(compactSignature);
          const multihash = `0x1220${utils_1.toHexString(hash)}`; 
          tx.id = multihash;
          return tx;
        }
async signTransaction ( tx ) { if ( ! tx . active ) throw new Error ( "Active data is not defined" ) ; const hash = sha256_1 . sha256 ( utils_1 . decodeBase64 ( tx . active ) ) ; const [ compSignature , recovery ] = await secp . sign ( hash , this . privateKey , { recovered : true , canonical : true , der : false , } ) ; const compactSignature = new Uint8Array ( 65 ) ; compactSignature . set ( [ recovery + 31 ] , 0 ) ; compactSignature . set ( compSignature , 1 ) ; tx . signature_data = utils_1 . encodeBase64 ( compactSignature ) ; const multihash = ` ${ utils_1 . toHexString ( hash ) } ` ; tx . id = multihash ; return tx ; }
Function to sign a transaction.
Function to sign a transaction .
// compact signature // 12: code sha2-256. 20: length (32 bytes)