Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to calculate sha256 hashes in the browser using the user's video card, eg. by using WebGL or Flash?

Is it possible to calculate sha256 hashes in the browser using the user's video card, eg. by using WebGL or Flash?

I'm afraid this is all there is to ask, but if more elaboration is needed please do not hesitate to tell me in a comment.

Thanks.

like image 904
Tom Avatar asked Jun 18 '11 11:06

Tom


2 Answers

This should be possible. Given an implementation of SHA as a fragment shader, you should be able to read back the results using readPixels:

Read Back Pixels [5.13.12] Pixels in the current framebuffer can be read back into an ArrayBufferView object.

void readPixels(int x, int y, long width, long height, enum format, enum type, Object pixels)

format: RGBA

type: UNSIGNED_BYTE

From the Kronos WebGL reference card (PDF)

For extra credit, do it all in an offscreen framebuffer, as described here.

like image 107
laslowh Avatar answered Oct 15 '22 17:10

laslowh


Looks like this can be done (although in this case it's not SHA256). The following is an example of a JavaScript library that uses WebGL2 to calculate hash values on the client side, for the Curl hashing algoritm: https://github.com/iotaledger/curl.lib.js/

In this case it's used to do Proof of Work for an IOTA transaction (https://www.iota.org/get-started/what-is-iota). This basically comes down to brute-forcing random inputs into the same hash function until the result matches a certain output. Therefore the gained hashing speed by using WebGL is very relevant. I have used it, and it works!

like image 34
Job Schipper Avatar answered Oct 15 '22 17:10

Job Schipper