How to use the js-sha256.sha256.array function in js-sha256

To help you get started, we’ve selected a few js-sha256 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 dogethereum / dogethereum-contracts / test / utils.js View on Github external
function calcBlockSha256Hash(blockHeader) {
  const headerBin = module.exports.fromHex(blockHeader).slice(0, 80);
  return `0x${Buffer.from(sha256.array(sha256.arrayBuffer(headerBin))).reverse().toString('hex')}`;
}
github loomnetwork / dashboard / src / whitelist / store / index.ts View on Github external
export async function generateSeeds(context: WhiteListContext) {
  feedbackModule.setTask(i18n.t("feedback_msg.task.new_key").toString())
  feedbackModule.setStep(i18n.t("feedback_msg.step.generating_new_key").toString())

  const mnemonic = generateMnemonic()
  const seed = mnemonicToSeedSync(mnemonic)
  const privateKeyUint8ArrayFromSeed = CryptoUtils.generatePrivateKeyFromSeed(new Uint8Array(sha256.array(seed)))
  const privateKeyB64 = CryptoUtils.Uint8ArrayToB64(privateKeyUint8ArrayFromSeed)
  const publicKey = await plasmaModule.getPublicAddrePriaKeyUint8Array({ privateKey: privateKeyUint8ArrayFromSeed })

  feedbackModule.endTask()

  context.state.seed.mnemonic = mnemonic
  context.state.seed.publicAddress = publicKey
}
github OpenFuturePlatform / open-chain-ui / src / utils / crypto.ts View on Github external
const hashDelegateTransaction = (unsignedTransaction: IDelegateCandidate): string => {
  const { timestamp, fee, senderAddress, amount, delegateKey } = unsignedTransaction;
  const byteArray = [
    ...toByteArray(timestamp),
    ...toByteArray(fee),
    ...toByteArray(senderAddress),
    ...toByteArray(delegateKey),
    ...toByteArray(amount),
  ];
  return sha256(sha256.array(byteArray));
};
github OpenFuturePlatform / open-chain-ui / src / utils / crypto.ts View on Github external
const hashTransaction = (unsignedTransaction: IUnsignedTransaction): string => {
  const { timestamp, fee, senderAddress, amount, recipientAddress, data } = unsignedTransaction;

  let byteArray = [
    ...toByteArray(timestamp),
    ...toByteArray(fee),
    ...toByteArray(senderAddress),
    ...toByteArray(amount)
  ];
  if (recipientAddress) {
    byteArray = [...byteArray, ...toByteArray(recipientAddress)]
  }
  if (data) {
    byteArray = [...byteArray, ...toByteArray(data)]
  }
  return sha256(sha256.array(byteArray));
};