From 9518d1cc65927188a50e7a0345040fb45ee23fab Mon Sep 17 00:00:00 2001 From: Masao Hidemitsu Date: Sat, 19 May 2018 02:40:07 +0900 Subject: [PATCH] Added Argon2 as supported algo --- README.md | 16 ++++++++++++++-- lib/algoProperties.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 078b90f8..1ea9442b 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,8 @@ npm update Create the configuration for your coin: -Possible options for `algorithm`: *sha256, scrypt, scrypt-jane, scrypt-n, quark, x11, keccak, blake, -skein, groestl, fugue, shavite3, hefty1, qubit, or sha1*. +Possible options for `algorithm`: *argon2d, argon2i, argon2id, sha256, scrypt, scrypt-jane, scrypt-n, quark, x11, +keccak, blake, skein, groestl, fugue, shavite3, hefty1, qubit, or sha1*. ```javascript var myCoin = { @@ -157,6 +157,18 @@ var myCoin = { }; ``` +If you are using the `argon2d`, `argon2i`, or `argon2id` algorithm there are additional configurations: +```javascript +var myCoin = { + "name": "Unitus", + "symbol": "UIS", + "algorithm": "argon2d", + "tValue": 1, //optional - defaults to 1 + "mValue": 4096, //optional - defaults to 4096 + "pValue": 1 //optional - defaults to 1 +}; +``` + Create and start new pool with configuration options and authentication function diff --git a/lib/algoProperties.js b/lib/algoProperties.js index 7725ee62..b6f4b4d2 100644 --- a/lib/algoProperties.js +++ b/lib/algoProperties.js @@ -5,6 +5,44 @@ var util = require('./util.js'); var diff1 = global.diff1 = 0x00000000ffff0000000000000000000000000000000000000000000000000000; var algos = module.exports = global.algos = { + 'argon2d': { + //Uncomment diff if you want to use hardcoded truncated diff + //diff: '0000ffff00000000000000000000000000000000000000000000000000000000', + multiplier: Math.pow(2, 16), + hash: function(coinConfig){ + var tValue = coinConfig.tValue || 1; + var mValue = coinConfig.mValue || 4096; + var pValue = coinConfig.pValue || 1; + return function(data){ + return multiHashing.argon2d(data,tValue,mValue,pValue); + } + } + }, + 'argon2i': { + //Uncomment diff if you want to use hardcoded truncated diff + //diff: '0000ffff00000000000000000000000000000000000000000000000000000000', + multiplier: Math.pow(2, 16), + hash: function(coinConfig){ + var tValue = coinConfig.tValue || 1; + var mValue = coinConfig.mValue || 4096; + var pValue = coinConfig.pValue || 1; + return function(data){ + return multiHashing.argon2i(data,tValue,mValue,pValue); + } + } + }, + 'argon2id': { + //Uncomment diff if you want to use hardcoded truncated diff + //diff: '0000ffff00000000000000000000000000000000000000000000000000000000', + hash: function(coinConfig){ + var tValue = coinConfig.tValue || 1; + var mValue = coinConfig.mValue || 4096; + var pValue = coinConfig.pValue || 1; + return function(data){ + return multiHashing.argon2id(data,tValue,mValue,pValue); + } + } + }, sha256: { //Uncomment diff if you want to use hardcoded truncated diff //diff: '00000000ffff0000000000000000000000000000000000000000000000000000',