From 57b46191446fbbc46ebd31ce7bc6d6c39463052c Mon Sep 17 00:00:00 2001 From: bc Date: Wed, 23 Oct 2024 12:22:58 +0800 Subject: [PATCH] update --- classicdice_new.html | 67 +++++------- coinflip_new.html | 27 ++++- ringOfFortune_new.html | 226 +++++++++++++++++++++++----------------- roulettesingle_new.html | 30 +++++- 4 files changed, 207 insertions(+), 143 deletions(-) diff --git a/classicdice_new.html b/classicdice_new.html index 51d3ad0..23897ba 100644 --- a/classicdice_new.html +++ b/classicdice_new.html @@ -48,33 +48,25 @@

Output


Results

-
- - -
- +
Final Result
+ +
Calculation Process
+

Using the formula `hmac_sha256(client_seed:nonce, server_seed)`,

+

We get the hash result:

+

`{{result_hash}}`.

+
+
    +
  1. Take the first 15 characters, resulting in `{{baseHash}}`.
  2. +
  3. Convert this to decimal, which gives: `{{BigInt('0x' + baseHash)}}`.
  4. +
  5. Perform modulus 47(47 is fixed constant), and we get a remainder of {{index}}.
  6. +
  7. Starting from the index, take 14 characters, resulting in `{{newHash}}`.
  8. +
  9. Convert this to decimal, resulting in: `{{BigInt('0x' + newHash)}}`.
  10. +
  11. Divide by 8(8 is a fixed constant), resulting in: `{{BigInt('0x' + newHash) / BigInt(8)}}`.
  12. +
  13. Multiply by 2^-53(2^-53 is a fixed constant), resulting in: `{{Number(BigInt('0x' + newHash) / BigInt(8)) * Math.pow(2, -53)}}`.
  14. +
  15. Multiply by 10000(10000 is a fixed constant), resulting in: `{{Number(BigInt('0x' + newHash) / BigInt(8)) * Math.pow(2, -53) * 10000}}`.
  16. +
  17. Finally, take the integer part of the result, which gives: `{{numResult}}`.
  18. +
+
@@ -96,19 +88,14 @@
Bytes to Number
result_hash_list () { return String(this.result_hash) }, - results () { - let list = this.result_hash_list - let res = { - dec: [], - hex: [] - } - for (let i = 0; i < list.length; i += 2) { - let dext = list[i] + list[i + 1] - let hext = parseInt(dext, 16) - res.dec.push(dext) - res.hex.push(hext) - } - return res + baseHash () { + return this.result_hash_list.substring(0, 15) + }, + index () { + return Number(BigInt('0x' + this.result_hash_list.substring(0, 15)) % BigInt(47)) + }, + newHash () { + return this.result_hash_list.substring(this.index, this.index + 14) }, numResult () { return slideWindowNumber(this.result_hash_list, 10001) / 100; diff --git a/coinflip_new.html b/coinflip_new.html index 80b2bde..1fd0bae 100644 --- a/coinflip_new.html +++ b/coinflip_new.html @@ -106,15 +106,34 @@

Input

Output

{ - Array(state.round).fill(1).map((item, index) => { - const hmacSha256Result = getHashString(state.serverSeed, state.clientSeed, state.nonce, index+1); + Array(state.round).fill(1).map((item, idx) => { + const hmacSha256Result = getHashString(state.serverSeed, state.clientSeed, state.nonce, idx+1); const finalResult = getResult(hmacSha256Result); + const baseHash = hmacSha256Result.substring(0, 15); + const index = Number(BigInt('0x' + baseHash) % BigInt(47)); + const newHash = hmacSha256Result.substring(index, index + 14); return ( -
-

Round: {index + 1}

+
+

Round: {idx + 1}

+
Calculation Process
+

Using the formula `hmac_sha256(client_seed:nonce, server_seed)`,

+

We get the hash result:

+

{hmacSha256Result}.

+
+
    +
  1. Take the first 15 characters, resulting in {baseHash}.
  2. +
  3. Convert this to decimal, which gives: {BigInt('0x' + baseHash)}.
  4. +
  5. Perform modulus 47(47 is fixed constant), and we get a remainder of {index}.
  6. +
  7. Starting from the index, take 14 characters, resulting in {newHash}.
  8. +
  9. Convert this to decimal, resulting in: {BigInt('0x' + newHash)}.
  10. +
  11. Divide by 8(8 is a fixed constant), resulting in: {BigInt('0x' + newHash) / BigInt(8)}.
  12. +
  13. Multiply by 2^-53(2^-53 is a fixed constant), resulting in: {Number(BigInt('0x' + newHash) / BigInt(8)) * Math.pow(2, -53)}.
  14. +
  15. Multiply by 2(2 is a fixed constant), resulting in: {Number(BigInt('0x' + newHash) / BigInt(8)) * Math.pow(2, -53) * 2}.
  16. +
  17. Finally, take the integer part of the result, which gives: {finalResult}.
  18. +
) diff --git a/ringOfFortune_new.html b/ringOfFortune_new.html index 69649e0..972e122 100644 --- a/ringOfFortune_new.html +++ b/ringOfFortune_new.html @@ -1,5 +1,6 @@ + @@ -13,115 +14,148 @@ + - -
-

Ring of fortune verify

-
- -

Input

-
- -
-
- -
-
- -
-
- -
- -
-
-

Output

-
- - -
-
- - -
-
+ +
+

Ring of fortune verify

+
+
+

Input

+
+ +
+
+ +
+
+ +
+
+ +
+

-
-

Results

-
- - -
+ +

Output

+
+ + +
+
+ + +
+ +
+
+ +

Results

+
Final Result
+ +
Calculation Process
+

Using the formula `hmac_sha256(client_seed:nonce, server_seed)`,

+

We get the hash result:

+

`{{result_hash}}`.

+
+
    +
  1. Take the first 15 characters, resulting in `{{baseHash}}`.
  2. +
  3. Convert this to decimal, which gives: `{{BigInt('0x' + baseHash)}}`.
  4. +
  5. Perform modulus 47(47 is fixed constant), and we get a remainder of {{index}}.
  6. +
  7. Starting from the index, take 14 characters, resulting in `{{newHash}}`. +
  8. +
  9. Convert this to decimal, resulting in: `{{BigInt('0x' + newHash)}}`.
  10. +
  11. Divide by 8(8 is a fixed constant), resulting in: `{{BigInt('0x' + newHash) / BigInt(8)}}`.
  12. +
  13. Multiply by 2^-53(2^-53 is a fixed constant), resulting in: `{{Number(BigInt('0x' + newHash) / + BigInt(8)) * Math.pow(2, -53)}}`.
  14. +
  15. Finally, Multiply by 1000(1000 is a fixed constant), resulting in: `{{Number(BigInt('0x' + newHash) / + BigInt(8)) * Math.pow(2, -53) * 1000}}`.
  16. +
+
+
0~495 = {{range1}}
496~825 = {{range2}}
826~990 = {{range3}}
991~1000 = {{range4}}
-
+
-
+
+ \ No newline at end of file diff --git a/roulettesingle_new.html b/roulettesingle_new.html index 8d672ab..d4ed483 100644 --- a/roulettesingle_new.html +++ b/roulettesingle_new.html @@ -61,18 +61,24 @@ const resultArr = [state.clientSeed, state.nonce]; const hmacSha256Result = String(CryptoJS.HmacSHA256(resultArr.join(":"), state.serverSeed)); const finalResult = getResult(hmacSha256Result); + const baseHash = hmacSha256Result.substring(0, 15); + const index = Number(BigInt('0x' + baseHash) % BigInt(47)); + const newHash = hmacSha256Result.substring(index, index + 14); return { serverSeedHash, hmacSha256Result, finalResult, - resultList + resultList, + baseHash, + index, + newHash, } }, [state]); const {resultList, finalResult} = result; return (
-

Roulette single verify

+

Roulette single verify


Input

@@ -80,10 +86,28 @@

Input

-

Output

+

Results

+
Final Result
+
Calculation Process
+

Using the formula `hmac_sha256(client_seed:nonce, server_seed)`,

+

We get the hash result:

+

{result.hmacSha256Result}.

+
+
    +
  1. Take the first 15 characters, resulting in {result.baseHash}.
  2. +
  3. Convert this to decimal, which gives: {BigInt('0x' + result.baseHash)}.
  4. +
  5. Perform modulus 47(47 is fixed constant), and we get a remainder of {result.index}.
  6. +
  7. Starting from the index, take 14 characters, resulting in {result.newHash}.
  8. +
  9. Convert this to decimal, resulting in: {BigInt('0x' + result.newHash)}.
  10. +
  11. Divide by 8(8 is a fixed constant), resulting in: {BigInt('0x' + result.newHash) / BigInt(8)}.
  12. +
  13. Multiply by 2^-53(2^-53 is a fixed constant), resulting in: {Number(BigInt('0x' + result.newHash) / BigInt(8)) * Math.pow(2, -53)}.
  14. +
  15. Multiply by 37(37 is a fixed constant), resulting in: {Number(BigInt('0x' + result.newHash) / BigInt(8)) * Math.pow(2, -53) * 37}.
  16. +
  17. Finally, take the integer part of the result, which gives: {result.finalResult}.
  18. +
+
);