Post
Topic
Board Gambling discussion
Re: bustabit.com - New seeding event
by
leomedina
on 01/03/2024, 01:22:40 UTC
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 ...


You need to use the previous hash. So, if prevGameHash is the hash of game #10002812, you have to validate the signature of game #10002813, and so on. I didn't try to run your code, but you probably want to use hexToBytes instead of Uint8Array(Buffer.from(foo)) where you declare prevGameHash and vxSignature.