dashpay / x11-hash-js Goto Github PK
View Code? Open in Web Editor NEWx11 javascript hashing algorithm in pure javascript
License: MIT License
x11 javascript hashing algorithm in pure javascript
License: MIT License
In index.js at the end of the digest function where the output format is computed we have the following code:
// output 32-bit array
if (outputFormat === 2) {
return h.int32Buffer2Bytes(a);
}
// output 8-bit array
else if (outputFormat === 1) {
return a;
}
// output string
return h.int32ArrayToHexString(a);
and in test.js we have these 2 tests:
it('buffer outputFormat=1 -> 8 bit', function () {
expect(x11.digest(buffer, 1, 1)).to.deep.equal([
25431772,
2140696654,
1013368572,
-1390505884,
708325244,
481603428,
-318219067,
201326592
]);
});
it('buffer outputFormat=2 -> 32 bit', function () {
expect(x11.digest(buffer, 1, 2)).to.deep.equal([
1,
132,
14,
220,
127,
152,
112,
78,
60,
102,
198,
252,
173,
30,
144,
100,
42,
56,
47,
124,
28,
180,
175,
100,
237,
8,
92,
197,
12,
0,
0,
0
]);
});
which implies that an inversion has happened. Currently the tests pass so it's hard to say what the intended order was. This function is called in dashcore-lib with the outputFormat parameter 1 and its result is then converted into an 8-bit buffer using Buffer.from() but that causes data loss if the input of the function is a 32-bit array so that points to a mistake in the implementation.
I did notice that these output types have been inverted in this commit history of this repo a few times.
x13 adds Hamsi and Fugue to the end of x11, x14 adds Shabal to x13 and x15 adds Whirlpool after x14 (all hashes listed here are 512bits)
x16r and x16 does something weird with their hash
I see x11-hash-js in some repositories with bitcore.
I am porting a coin to bitcore, it is working insight app, but I have not used the hash anyway.
So, why need x11 hash in JS?
Sorry for the silly question.
Reference to other libraries:
Ideas:
For https://github.com/dashpay/x11-hash-js/blob/master/lib/cubehash.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.