Menu

React, etc. Tech Stack

React, Flux, GraphQL, Hack, HHVM...? All of this and more!

Facebook could mint BitCoins in the browser with JavaScript and your GPU

While the cloud and it's massive capacity to perform computation on a scale is impressive, it's good to remember that the our clients are not dumb terminals like they were in the early days of mainframe computing.

Your average smartphone packs a punch and with JavaScript, it could be harnessed by malicious crimilals or simply large web providers such as Facebook to perform calculations for profit.

BitCoins are a form of currency that require computation power to be earned. Once a BitCoin has been created it's value will depend on the general value of the virtual currency. The amount of computation done for one individual BitCoin grows over time, so earning becomes evermore laboursome.

This is where large web operators could hook into their clients to use their computation power in their advantage. Projects such as [email protected] and Distributed.net applied distributed computing a long time ago, but required a separate client application to perform the computing.

With today's powerful JavaScript engines running into computers, heavy computation can be done distributedly in browsers. The GPU is a dedicated chip to perform graphics processing, but it is also very efficient at creating BitCoins.

With JavaScript libraries such as WebMonkeys, running a distributed BitCoin Crypto-currency mining operation using client GPU's is within reach of pretty much anyone with basic JavaScript skills:

monkeys.set("blockhash", [blockhash]);
monkeys.set("monkeyNonce", monkeyNonce);
monkeys.set("result", [0]);
monkeys.work(totalMonkeys, `
  const float attempts = ${attemptsPerMonkey.toFixed(1)};
  float bhash = blockhash(0);
  float startNonce = monkeyNonce(i);
  float mined = 0.0;
  for (float nonce = startNonce; nonce < startNonce+attempts; ++nonce){
    // Yes, this hash function is stupid
    float hash = mod(bhash * (nonce+1.0), pow(2.0,31.0) - 1.0);
    if (hash >= 0.0 && hash <= 3000.0)
      mined = nonce;
  };
  result(mined > 0.0 ? 0 : 1) := mined;
`);
// Will be set if mined a block
console.log(monkeys.get("result"));

Malicious attentions aside, providing computation resources might become a form of currency in itself in the future. The Facebook terms of use, for example, could be updated to allow the use of your device resources at their disposal.

You could agree with Facebook that they will have access to 10% of your GPU time when you are connected to a power outlet. The last piece is important, since battery life continues to be an issue for mobile devices. Much more so than CPU or GPU.

This type of distributed on-off computing with long latencies and no guarantee on if a process will ever be completed is not suitable for everything, but it could be useful for a number of things. Duplicating tasks wouldn't really be an issue for Facebook itself as it would not need to pay for the resources of these duplicate calculations.

In the past you could pay with eyeballs through advertising, a part of paying in the future might be paying with computing resources. Individual impact is low, but at large scale it becomes significant. Seems more viable than Facebook turning to Patent Trolling to making a profit.

Written by Jorgé on Friday August 26, 2016

Permalink -

« Fetch is the native AJAX API to replace jQuery.get() - Async/Await support for ES5 browsers pushed to TypeScript 2.1 »