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

StackOverflow https://stackoverflow.com/questions/6395651

Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

The next version of the Flash player (11) will support real hardware accelerated graphics, thus exposing the possibility to run pixel shaders on the graphics card. They could atleast in theory be used for general purpose computing.

There are some examples on Thibault Imberts blog.

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top