{{$t("provably_fair.header_1")}}

{{$t("provably_fair.paragraph_1")}}

{{$t("provably_fair.header_2")}}

{{$t("provably_fair.paragraph_2")}}

{{$t("provably_fair.header_3")}}

{{$t("provably_fair.header_4")}}

	let crypto = require('crypto');

	class FairGenerator {
		constructor(server_seed, client_seed) {
			this.server_seed = (server_seed || crypto.randomBytes(16).toString('hex')).toLowerCase();
			this.client_seed = (client_seed || crypto.randomBytes(16).toString('hex')).toLowerCase();
		}
		get server_hash() {
			let hash = crypto.createHash('SHA256');
			hash.write(this.server_seed);

			return hash.digest().toString('hex');
		}
		get round_result() {
			let hmac = crypto.createHmac('SHA512', this.server_seed);
			hmac.write(this.client_seed);

			let buf = hmac.digest();
			return buf.readUInt32BE() / Math.pow(2, 32) * 100;
		}
	}
			

{{$t("provably_fair.paragraph_5b")}}

{{$t("provably_fair.paragraph_5d")}}

	//create a new fair generator with your round's server and client seed
	let my_generator = new FairGenerator("3e9b04fb057da725bcce13fc2b021ec8", "d597c1f72790f244b1bd59e177606dba");

	console.log(my_generator.server_hash); //should print the server hash you originally got
	console.log(my_generator.round_result); //should print something like 5.0939911743626