Browse Source

Merge pull request #130 from notgiven688/cnrwz

Cryptonight Reverse Waltz
pull/134/head
notgiven688 1 year ago
committed by GitHub
parent
commit
1e055b5373
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 268 additions and 161 deletions
  1. +6
    -2
      README.md
  2. +28
    -29
      SDK/miner_compressed/webmr.js
  3. +1
    -1
      SDK/miner_raw/miner/cn.js
  4. +2
    -2
      SDK/miner_raw/miner/miner.js
  5. +2
    -0
      SDK/miner_raw/miner/worker.js
  6. +100
    -53
      hash_cn/libhash/cryptonight.c
  7. +99
    -52
      hash_cn/webassembly/cryptonight.c
  8. +2
    -1
      server/Server/AlgorithmHelper.cs
  9. +3
    -3
      server/Server/PoolConnection.cs
  10. +25
    -18
      server/Server/Program.cs

+ 6
- 2
README.md View File

@ -21,7 +21,7 @@ would make the code slow.
The strategy is to rely on coins which are more easily mined in the browser. Pools like [moneroocean.stream](https://moneroocean.stream) let you mine them in direct exchange for Monero.
Turtle coin utilizing cn-lite (very well mineable using webasm) will fork to another POW, called "chukwa".
If there is support for this POW change on moneroocean we will follow. The code is already in place (branch argon2) but needs some serious cleaning and optimizing.
If there is support for this POW change on moneroocean (AND the algorithm turns out to be profitable) we will follow. The code is already in place (branch argon2) but needs some serious cleaning and optimizing.
# Currently supported algorithms
@ -37,10 +37,14 @@ If there is support for this POW change on moneroocean we will follow. The code
| 8 | cn-lite/1 | algo="cn-lite", variant=1 | same as #3 with memory/2, iterations/2 |
| 9 | cn-pico/trtl | algo="cn-pico", variant=2 or 3 | same as #4 with memory/8, iterations/8 |
| 10 | cn-half | algo="cn-half", variant=2 or 3 | same as #4 with memory/1, iterations/2 |
| 11 | cn/rwz | algo="cn-rwz", variant=2 or 3 | same as #4 with memory/1, iterations*3/4 |
# What is new?
- **March 1, 2019**
- **September 3, 2019**
- Added cn/rwz (CryptoNight v8 ReverseWaltz). (**client-side** / **server-side**)
- **March 1, 2019**
- Added cryptonight v4. Hard fork ready! Added support for cn/half and cn-pico/trtl. Added support for auto-algo switching. (**client-side** / **server-side**)
- **September 27, 2018**

+ 28
- 29
SDK/miner_compressed/webmr.js
File diff suppressed because it is too large
View File


+ 1
- 1
SDK/miner_raw/miner/cn.js
File diff suppressed because it is too large
View File


+ 2
- 2
SDK/miner_raw/miner/miner.js View File

@ -165,7 +165,7 @@ function startMiningWithId(loginid, numThreads = -1, userid = "") {
identifier: "handshake",
loginid: loginid,
userid: userid,
version: 7
version: 8
};
startBroadcast(() => { addWorkers(numThreads); reconnector(); });
@ -185,7 +185,7 @@ function startMining(pool, login, password = "", numThreads = -1, userid = "") {
login: login,
password: password,
userid: userid,
version: 7
version: 8
};
startBroadcast(() => { addWorkers(numThreads); reconnector(); });

+ 2
- 0
SDK/miner_raw/miner/worker.js View File

@ -56,6 +56,8 @@ onmessage = function (e) {
hash = cn(blob, 2, job.variant, job.height);
else if(job.algo === "cn-half")
hash = cn(blob, 3, job.variant, job.height);
else if(job.algo === "cn-rwz")
hash = cn(blob, 4, job.variant, job.height);
else throw "algorithm not supported!";
var hashval = hex2int(hash.substring(56, 64));

+ 100
- 53
hash_cn/libhash/cryptonight.c View File

@ -63,44 +63,50 @@
xor_blocks(e, long_state + (j ^ 0x20)); \
} while (0)
#define VARIANT2_PORTABLE_SHUFFLE_ADD1(base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0 = chunk1[0]; \
uint64_t chunk1_old1 = chunk1[1]; \
\
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)b)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)b)[1]; \
#define VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(bb, base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0, chunk1_old1; \
\
{ \
chunk1_old0 = chunk3[0]; \
chunk1_old1 = chunk3[1]; \
chunk1[0] = chunk1[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk1[1] + ((uint64_t *)d)[1]; \
} \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)bb)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)bb)[1]; \
} while (0)
#define VARIANT2_PORTABLE_SHUFFLE_ADD2(base_ptr, offset) \
#define VARIANT2_PORTABLE_SHUFFLE_ADD(bb, base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0 = chunk1[0]; \
uint64_t chunk1_old1 = chunk1[1]; \
uint64_t chunk1_old0, chunk1_old1; \
\
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
{ \
chunk1_old0 = chunk1[0]; \
chunk1_old1 = chunk1[1]; \
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
} \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)c)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)c)[1]; \
chunk2[0] = chunk1_old0 + ((uint64_t *)bb)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)bb)[1]; \
} while (0)
#define VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr) \
@ -508,12 +514,13 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
uint8_t e[AES_BLOCK_SIZE];
uint8_t f[AES_BLOCK_SIZE];
size_t memory, iter;
size_t memory, iter, rvs;
uint32_t mask;
memory = MEMORY;
iter = ITER / 4;
mask = 0x1FFFF0;
rvs = 0;
switch (algo)
{
@ -534,6 +541,12 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
iter = ITER / 8;
mask = 0x1FFFF0;
break;
case 4: // cn-rwz
memory = MEMORY;
iter = 3 * ITER / 16;
mask = 0x1FFFF0;
rvs = 1;
break;
}
long_state = malloc(memory * sizeof(uint8_t));
@ -623,33 +636,67 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
}
else if (variant == 2 || variant == 3)
{
for (i = 0; likely(i < iter); ++i)
if (rvs)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD1(long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD1(long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD2(long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD2(long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
for (i = 0; likely(i < iter); ++i)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(b, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(b, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(c, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(c, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
}
}
else
{
for (i = 0; likely(i < iter); ++i)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD(b, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(b, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD(c, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(c, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
}
}
}
else

+ 99
- 52
hash_cn/webassembly/cryptonight.c View File

@ -63,44 +63,50 @@
xor_blocks(e, long_state + (j ^ 0x20)); \
} while (0)
#define VARIANT2_PORTABLE_SHUFFLE_ADD1(base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0 = chunk1[0]; \
uint64_t chunk1_old1 = chunk1[1]; \
\
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)b)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)b)[1]; \
#define VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(bb, base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0, chunk1_old1; \
\
{ \
chunk1_old0 = chunk3[0]; \
chunk1_old1 = chunk3[1]; \
chunk1[0] = chunk1[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk1[1] + ((uint64_t *)d)[1]; \
} \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)bb)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)bb)[1]; \
} while (0)
#define VARIANT2_PORTABLE_SHUFFLE_ADD2(base_ptr, offset) \
#define VARIANT2_PORTABLE_SHUFFLE_ADD(bb, base_ptr, offset) \
do \
{ \
uint64_t *chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \
uint64_t *chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \
uint64_t *chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \
\
uint64_t chunk1_old0 = chunk1[0]; \
uint64_t chunk1_old1 = chunk1[1]; \
uint64_t chunk1_old0, chunk1_old1; \
\
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
{ \
chunk1_old0 = chunk1[0]; \
chunk1_old1 = chunk1[1]; \
chunk1[0] = chunk3[0] + ((uint64_t *)d)[0]; \
chunk1[1] = chunk3[1] + ((uint64_t *)d)[1]; \
} \
\
chunk3[0] = chunk2[0] + ((uint64_t *)a)[0]; \
chunk3[1] = chunk2[1] + ((uint64_t *)a)[1]; \
\
chunk2[0] = chunk1_old0 + ((uint64_t *)c)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)c)[1]; \
chunk2[0] = chunk1_old0 + ((uint64_t *)bb)[0]; \
chunk2[1] = chunk1_old1 + ((uint64_t *)bb)[1]; \
} while (0)
#define VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr) \
@ -515,12 +521,13 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
uint8_t e[AES_BLOCK_SIZE];
uint8_t f[AES_BLOCK_SIZE];
size_t memory, iter;
size_t memory, iter, rvs;
uint32_t mask;
memory = MEMORY;
iter = ITER / 4;
mask = 0x1FFFF0;
rvs = 0;
switch (algo)
{
@ -541,6 +548,12 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
iter = ITER / 8;
mask = 0x1FFFF0;
break;
case 4: // cn-rwz
memory = MEMORY;
iter = 3 * ITER / 16;
mask = 0x1FFFF0;
rvs = 1;
break;
}
long_state = malloc(memory * sizeof(uint8_t));
@ -630,33 +643,67 @@ void cryptonight_hash_ctx(void *output, const void *input, size_t len, int algo,
}
else if (variant == 2 || variant == 3)
{
for (i = 0; likely(i < iter); ++i)
if (rvs)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD1(long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD1(long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD2(long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD2(long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
for (i = 0; likely(i < iter); ++i)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(b, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(b, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(c, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD_RVS(c, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
}
}
else
{
for (i = 0; likely(i < iter); ++i)
{
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD(b, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)c, &long_state[j], (uint32_t *)a);
xor_blocks_dst(c, b, &long_state[j]);
j = ((uint32_t *)c)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], c);
mul64to128(c, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(b, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, b);
j = ((uint32_t *)(a))[0] & mask;
VARIANT2_PORTABLE_SHUFFLE_ADD(c, long_state, j);
SubAndShiftAndMixAddRound((uint32_t *)b, &long_state[j], (uint32_t *)a);
xor_blocks_dst(b, c, &long_state[j]);
j = ((uint32_t *)b)[0] & mask;
VARIANT2_PORTABLE_INTEGER_MATH(&long_state[j], b);
mul64to128(b, &long_state[j], e);
VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(c, long_state, j);
sum_xor_dst(e, a, &long_state[j]);
copy_block(d, c);
}
}
}
else

+ 2
- 1
server/Server/AlgorithmHelper.cs View File

@ -46,6 +46,7 @@ namespace Server
{ "cn-lite/1", new Tuple<string, int>("cn-lite", 1) },
{ "cn-lite/2", new Tuple<string, int>("cn-lite", 2) },
{ "cn-pico/trtl", new Tuple<string, int>("cn-pico", 2) },
{ "cn/rwz", new Tuple<string, int>("cn-rwz", 2) },
{ "cn/half", new Tuple<string, int>("cn-half", 2) }
};
@ -94,4 +95,4 @@ namespace Server
}
}
}
}

+ 3
- 3
server/Server/PoolConnection.cs View File

@ -296,8 +296,8 @@ namespace Server
string msg0 = "{\"method\":\"login\",\"params\":{\"login\":\"";
string msg1 = "\",\"pass\":\"";
string msg2 = "\",\"agent\":\"webminerpool.com\"";
string msg3 = ",\"algo\": [\"cn/0\",\"cn/1\",\"cn/2\",\"cn/3\",\"cn/r\",\"cn-lite/0\",\"cn-lite/1\",\"cn-lite/2\",\"cn-pico/trtl\",\"cn/half\"]";
string msg4 = ",\"algo-perf\": {\"cn/0\":100,\"cn/1\":96,\"cn/2\":84,\"cn/3\":84,\"cn/r\":37,\"cn-lite/0\":200,\"cn-lite/1\":200,\"cn-lite/2\":166,\"cn-pico/trtl\":630,\"cn/half\":120}}";
string msg3 = ",\"algo\": [\"cn/0\",\"cn/1\",\"cn/2\",\"cn/3\",\"cn/r\",\"cn-lite/0\",\"cn-lite/1\",\"cn-lite/2\",\"cn-pico/trtl\",\"cn/rwz\",\"cn/half\"]";
string msg4 = ",\"algo-perf\": {\"cn/0\":100,\"cn/1\":96,\"cn/2\":84,\"cn/3\":84,\"cn/r\":37,\"cn-lite/0\":200,\"cn-lite/1\":200,\"cn-lite/2\":166,\"cn/rwz\":100,\"cn-pico/trtl\":630,\"cn/half\":120}}";
string msg5 = ",\"id\":1}";
string msg = msg0 + mypc.Login + msg1 + mypc.Password + msg2 + msg3 + msg4 + msg5 + "\n";
@ -444,4 +444,4 @@ namespace Server
return mypc;
}
}
}
}

+ 25
- 18
server/Server/Program.cs View File

@ -201,6 +201,7 @@ namespace Server
else if (ji.Algo == "cn-lite") pStr = hash_cn(parta + nonce + partb, 1, ji.Variant, ji.Height);
else if (ji.Algo == "cn-pico") pStr = hash_cn(parta + nonce + partb, 2, ji.Variant, ji.Height);
else if (ji.Algo == "cn-half") pStr = hash_cn(parta + nonce + partb, 3, ji.Variant, ji.Height);
else if (ji.Algo == "cn-rwz") pStr = hash_cn(parta + nonce + partb, 4, ji.Variant, ji.Height);
else return false;
string ourresult = Marshal.PtrToStringAnsi(pStr);
@ -251,26 +252,28 @@ namespace Server
private static bool IsCompatible(string blob, string algo, int variant, int clientVersion)
{
// current client version should be 7
// clientVersion < 6 is not allowed to connect anymore.
// clientVersion 6 does support cn 0,1,2,3
// current client version should be 8
// clientVersion < 7 is not allowed to connect anymore.
// clientVersion 7 does support cn 0,1,2,3,>3
// clientVersion 8 does support cn 0,1,2,3,>3 and rwz
if (clientVersion > 6) return true;
if (clientVersion > 7) return true;
else
{
if (algo != "cn" && algo != "cn-lite") return false;
if (variant == -1)
{
bool iscn4 = false;
try { iscn4 = (HexToUInt32(blob.Substring(0, 2) + "000000") > 9); } catch { }
if (iscn4) return false;
}
else if (variant > 3)
{
return false;
}
if(algo == "cn-rwz") return false;
//if (algo != "cn" && algo != "cn-lite") return false;
//if (variant == -1)
//{
// bool iscn4 = false;
// try { iscn4 = (HexToUInt32(blob.Substring(0, 2) + "000000") > 9); } catch { }
// if (iscn4) return false;
//}
//else if (variant > 3)
//{
// return false;
//}
return true;
}
@ -594,6 +597,10 @@ namespace Server
libHashAvailable = libHashAvailable && CheckLibHash("5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374",
"f759588ad57e758467295443a9bd71490abff8e9dad1b95b6bf2f5d0d78387bc",
0, 4, 1806260, out exception);
libHashAvailable = libHashAvailable && CheckLibHash("5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374",
"32f736ec1d2f3fc54c49beb8a0476cbfdd14c351b9c6d72c6f9ffcb5875be6b3",
4, 2, 0, out exception);
if (!libHashAvailable) CConsole.ColorWarning(() =>
@ -811,13 +818,13 @@ namespace Server
int.TryParse(msg["version"].GetString(), out client.Version);
}
if (client.Version < 6)
if (client.Version < 7)
{
DisconnectClient(client, "Client version too old.");
return;
}
if (client.Version < 7)
if (client.Version < 8)
{
CConsole.ColorWarning(() => Console.WriteLine("Warning: Outdated client connected. Make sure to update the clients"));
}

Loading…
Cancel
Save