Skip to content

Instantly share code, notes, and snippets.

View nachomazzara's full-sized avatar

Ignacio Mazzara nachomazzara

View GitHub Profile
@akirattii
akirattii / example-alice-bob-message-verify.js
Created June 8, 2017 22:21
Example: Signed message verification (from generate a keypair) for NodeJS
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")}`);
@jiggzson
jiggzson / scientificToDecimal.js
Last active December 25, 2022 21:03
Converts a javascript number from scientific notation to a decimal string
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