Post
Topic
Board Gambling discussion
Re: bustabit.com - New seeding event
by
KloNEM
on 29/02/2024, 11:42:03 UTC
Yeah, thanks, I probably missed it. It just looks like it needs lot of modules/dependencies for a "webrunning", which I don't need, so I'm transferring the code to the Node.JS format (I hope I'm close now, otherwise I'll think about re-writing the code into Python, someday Smiley ).

Just a question to a second part of code (generating vxSignature) :

Code:
import { bls12_381 as bls } from "@noble/curves/bls12-381";
import { concatBytes, utf8ToBytes } from "@noble/hashes/utils";

const VX_PUBKEY = "b40c94495f6e6e73619aeb54ec2fc84c5333f7a88ace82923946fc5b6c8635b08f9130888dd96e1749a1d5aab00020e4";

function validateSignature(
  gameSalt: string, // the hash of block 831500
  prevGameHash: Uint8Array,
  vxSignature: Uint8Array
) {
  const message = concatBytes(prevGameHash, utf8ToBytes(gameSalt));
  return bls.verify(vxSignature, message, VX_PUBKEY);
}

What is input for the validateSignature function, are they the results from the previous hash ? So, if I'm finding e.g. vxSignature for game #10002813, do I have to find and input here prevGameHash of game #10002812, and the vxSignature of this game as well?

Yeah, that's correct. We concatenate the previous game hash with our game salt, and ask Vx to sign the message. Vx gives us as a signature (which reveals the previous game to Vx) and then what that function does is to verify that the signature is authentic. By the way, there is also a crash demo here, in case you haven't seen it.

Interesting. I tried to "re-make" second part of code for Node.js and game #10002812, in that way :

Code:
const BLS = require('./node_modules/@noble/curves/bls12-381.js');
const CB = require('./node_modules/@noble/hashes/utils.js');
const U8TB = require('./node_modules/@noble/hashes/utils.js');

const VX_PUBKEY = "b40c94495f6e6e73619aeb54ec2fc84c5333f7a88ace82923946fc5b6c8635b08f9130888dd96e1749a1d5aab00020e4";

// this is prevGameHash for the game #10002812
var prevGameHash1 = "cde36243fc801dc2c77ba6284c81c5fc047039f217e704eb0edafc14e3d1b0a2";
let prevGameHash = new Uint8Array(Buffer.from(prevGameHash1));
  console.log(prevGameHash.length);
  console.log(prevGameHash);
var gameSalt = "000000000000000000011f6e135efe67d7463dfe7bb955663ef88b1243b2deea";
// this is vxSignature for the game #10002812
var vxSignature1 = "8b1ac9ffd6f0594be105c248a56c23e628b088ba4d6c8407c4dd4f406a977a2f68afc83f82a002a36c10df0cd2a3a9430703beec34ae1f218458237c49d39bef0ede106f53d1c3036fef3442d32900af207d03cfe9c46e49ac1d0c304d35ceff";
// this is vxSignature for the game #10002813
//var vxSignature1 = "8f2466a009be4b370d12fe90a9fcc89dbefe1ac08240877a82e16a6e2c0be6a4a0db43bc52dd5eab886fb61dc13d714504af001f4377b0ca2fc269fa3f5fc871c1c61ef6e9f2cd5e862354d5955c0a9c8674dcd7d291a82c448e4f3c68126bad";
let vxSignature = new Uint8Array(Buffer.from(vxSignature1));
  console.log(vxSignature.length);
  console.log(vxSignature);
const message = CB.concatBytes(prevGameHash, U8TB.utf8ToBytes(gameSalt));
  console.log(message.length);
  console.log(message);
return BLS.bls12_381.verify(vxSignature, message, VX_PUBKEY);

When I use vxSignature for the game #10002812, it gives me node_modules/@noble/curves/bls12-381.js:144 throw new Error('No root'); . When I change vxSignature for the game #10002813, it gives me node_modules/@noble/curves/abstract/weierstrass.js:258 throw new Error('bad point: not in prime-order subgroup');.

Just for sure - the length of the prevGameHash is 64 bytes, length of the vxSignature 192 bytes and lenght of the message 128 bytes, correct ? Maybe there will be some issue with the re-code of string to Uint8Array in Node.js ...