Author

Topic: RIPEMD-160 progressive hashing? (Read 654 times)

legendary
Activity: 2114
Merit: 1015
April 09, 2016, 07:31:28 AM
#5
Does it? Extract from their doc:

Code:
Progressive Hashing

var sha256 = CryptoJS.algo.SHA256.create();
sha256.update("Message Part 1");
sha256.update("Message Part 2");
sha256.update("Message Part 3");
var hash = sha256.finalize();



holy shit, it looks exactly what I have been looking for. I need to test this out now, thank you  very much!

edit:
hopefully finalize function is not computationally very expensive, so the hash is gradually calculated during the calls to the update function. I have yet to verify if it's really the case.
looking at their documentation I am pretty confident that it is the case

edit 2:
So I have included ripemd160.js from here in my project and the following code actually is exactly what I needed.
Code:
    var ripemd160 = CryptoJS.algo.RIPEMD160.create(); 
    ripemd160.update("Message Part 1");
    ripemd160.update("Message Part 2");
    ripemd160.update("Message Part 3");
    var hash = ripemd160.finalize();
    alert(hash);
sr. member
Activity: 467
Merit: 267
April 09, 2016, 07:29:57 AM
#4
Does it? Extract from their doc:

Code:
Progressive Hashing

var sha256 = CryptoJS.algo.SHA256.create();
sha256.update("Message Part 1");
sha256.update("Message Part 2");
sha256.update("Message Part 3");
var hash = sha256.finalize();

legendary
Activity: 2114
Merit: 1015
April 09, 2016, 06:59:37 AM
#3
You can use crypto-js.

Yes, I am actually already using it. However, RIPEMD-160 and other hashing functions typically require the whole data to be hashed as an argument. In my case I can only provide 20 bytes of data at a time.
sr. member
Activity: 467
Merit: 267
April 09, 2016, 06:27:25 AM
#2
You can use crypto-js.
legendary
Activity: 2114
Merit: 1015
April 09, 2016, 05:43:33 AM
#1
This may or may not be a suitable question for this subforum but since Bitcoin utilizes RIPEMD-160 then perhaps there are people here who know the technical essence of this hashing algorithm.

I would like to know whether it is possible to calculate a RIPEMD-160 hash of a byte string on the go. For example, I need to calculate the hash of some binary data with an unknown length. I am receiving that data chunk-by-chunk and every chunk could be the last one. However, I cannot keep all of the data in the memory at once.

How to calculate the RIPEMD-160 hash of a byte string in such conditions? Eventually I would have to do it in JavaScript. Perhaps it is really easy? For example the current hash would be the hash of the concatenation of the last hash and the current 20 chunk of 20 bytes of data (just guessing).
Jump to: