Skip to content

Port of iota.lib.js kerl functions (address creation / bundle / signing) utilizing a native build of keccak and some other tweaks

License

Notifications You must be signed in to change notification settings

SteppoFF/iota.keccak.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to iota.keccak.js!

This lib is not made nor audited by the IOTA Foundation - It is community code and comes without any warranty! Do not use this library for moving big amount of funds - unless you checked the code!

There are not many input checks! Please be aware of this fact while using this module!

This node.js module provides a replacement for most of the kerl, curl and net functions from the iota.lib.js. It can be used to build tools and/or high performance node-js spammers but is also capable of signing inputs for value bundles. All the files in the helper folder I took from the official iota.lib.js and optimized them for my needs. Using a smart implementation and remote PoW, this script is easily capable of performing > 100 TPS - IRI is the bottleneck here.

Provided functions - check source code for options:

  • convertTransferAddress(address,options) - will create the corresponding transfer address of an Ed25519 address (check source code and transfer address example for more info)
  • getAddressFromSeedKeccak(seed,offset,count,options) - kerl function to create addresses
  • createBundleKeccak(bundles,options) - kerl function to create bundles
  • createBundleHashKeccakfunction(bundle, maxSecLevel) - kerl function to create the bunde hash
  • getAddressKeccak(normalizedBundleHash, signatureFragments, quick) - kerl function get the address
  • singleSignatureFragmentKeccak(curFragment, targetIndex, quick) - kerl signing function
  • getKeyKeccak(seed, index, length, quick) - kerl function to get the key fragment from seed
  • getTXHash(trytes) - curl function get the tx hash
  • doPoWPureJS(trytes, maxrounds, mwm) - pure JS implementation of PoW (more an easter egg as it is way too slow)
  • doPoW(trytes,trunkTransaction,branchTransaction,minWeightMagnitude) - requires the ffi version and ccurl (check source code and local spammer example for more info!)
  • transactionObject(transactionTrytes) - transforms trytes into a transaction object
  • transactionTrytes(transaction) - transforms a transaction object back into its trytes
  • validateMilestone(transactionTrytes,cooAddress,curlMode,milestoneKeyNum) - validates milestone transactions
  • connectHttp(node) - will enable the keep-alive feature for network functions (!the node needs to support it!)
  • storeAndBroadcast(node,trytes) - chaining of store and broadcast command to publish transactions
  • attachToTangle(node,trunkTransaction,branchTransaction,minWeightMagnitude,trytes) - remote PoW
  • getTransactionsToApprove(node,depth,reference) - the regular getTransactionsToApprove call towards the node
  • getBalances(node,addresses) - the regular getBalances call towards the node
  • wereAddressesSpentFrom(node,addresses) - the regular wereAddressesSpentFrom call towards the node
  • getNodeInfo(node) - perform a getNodeInfo call towards the node

During installation at least these three modules will be installed as well (slim):

Keccak npm / github

crypto-js npm / github

blakejs npm / github

If you install the full version with local PoW support (master) this module will be installed as well:

ffi npm / github

To-do

  • better documentation
  • input validation for other functions than createBundleKeccak
  • create npm project

Quickstart:

Install:

If you want to use the local PoW, please use the master branch

npm install git+https://github.com/SteppoFF/iota.keccak.js/#master

OR

If you just want to have the kerl/curl/net functions, you can go with the slim branch

npm install git+https://github.com/SteppoFF/iota.keccak.js/#slim

Using local PoW

In order to use local PoW with the master branch, the libccurl lib must be present in the folder where the final script is started from. Please check the local spammer example for more information.

Usage:

Generating addresses

const iotakeccak = require('iota.keccak.js');
var addresscount=100;
var seed="BSSDLSHPEFDULVWVCSDCUIIGWGVEDJHFWZCBYNDYSDB9GECGUFGKYBSOPEBUXVJUX9QGEBHKKZCTYH9VX";
var seclevel=2;
console.log("Seed set to: "+seed);
console.log("Creating "+addresscount+" addresses");
var addresses=iotakeccak.getAddressFromSeedKeccak(seed,0,addresscount,{secLevel:seclevel,quick:false});
console.log(addresses);

Bundle creation

const iotakeccak = require('iota.keccak.js');
var spam = [{
    address:"IOTA9KECCAK9JS",
    message:"JOHN",
    tag:"DOE"
}];

iotakeccak.createBundleKeccak(spam,{skipInputValidation:true,ignoreValue:false,quick:true})
.then(function(result){
	console.log(result);
});

For more examples check the expamples folder. You will find several examples there how to use this module.

Benchmark for address creation and signing

Seed set to: IBYMRX......

Comparing address gen function without checksum:
iota.keccak.js for 100 addresses: 21315ms
iota.keccak.js quick for 100 addresses: 8063ms
iota.lib.js for 100 addresses: 57042ms
Comparing results: match

Comparing address gen function with checksum:
iota.keccak.js for 100 addresses: 21012ms
iota.keccak.js quick for 100 addresses: 7953ms
iota.lib.js for 100 addresses: 56574ms
Comparing results: match

Comparing bundle creating/signing function - Iri call bypassed:
iota.keccak.js without provided address for 100 inputs: 31837ms
iota.keccak.js quick without provided address for 100 inputs: 12773ms
iota.keccak.js with provided address and validation for 100 inputs: 21152ms
iota.keccak.js quick with provided address and validation for 100 inputs: 8584ms
iota.keccak.js with provided address for 100 inputs: 10869ms
iota.keccak.js quick with provided address for 100 inputs: 4767ms
iota.lib.js for 100 provided inputs: 29722ms

Donations

This tool is completely free.. If you wish to donate anyhow, feel free to send IOTA to:

KYDDREOOQZDXYJPGMHUQADIBHKMKFYDPFJNOCZHZE9ZBZZIZKBYTTPPLAWAMEWMOHKLNJDUYVHMQMBGXXCRKOANBDC

Donation Address

About

Port of iota.lib.js kerl functions (address creation / bundle / signing) utilizing a native build of keccak and some other tweaks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published