This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const secp256k1 = require('secp256k1'); | |
// or require('secp256k1/elliptic') | |
// if you want to use pure js implementation in node | |
const msg = process.argv[2]; // message to be signed you pass | |
const digested = digest(msg); | |
console.log(`0) Alice's message: | |
message: ${msg} | |
message digest: ${digested.toString("hex")}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scientificToDecimal = function (num) { | |
var nsign = Math.sign(num); | |
//remove the sign | |
num = Math.abs(num); | |
//if the number is in scientific notation remove it | |
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) { | |
var zero = '0', | |
parts = String(num).toLowerCase().split('e'), //split into coeff and exponent | |
e = parts.pop(), //store the exponential part | |
l = Math.abs(e), //get the number of zeros |