Browse Source

aeon webasm update

pull/123/head
notgiven688 3 years ago
parent
commit
47b5ea5323
12 changed files with 63 additions and 28 deletions
  1. +2
    -2
      SDK/aeon/miner_compressed/miner.js
  2. +1
    -1
      SDK/aeon/miner_raw/miner/cn.js
  3. +2
    -2
      SDK/aeon/miner_raw/miner/miner.js
  4. +1
    -1
      SDK/xmr/miner_compressed/miner.js
  5. +2
    -2
      SDK/xmr/miner_raw/miner/miner.js
  6. +2
    -2
      example/aeon/webmr.js
  7. +1
    -1
      example/xmr/webmr.js
  8. +5
    -1
      hash_cn/webassembly/aeon/Makefile
  9. +1
    -7
      hash_cn/webassembly/aeon/cn.html
  10. +44
    -1
      hash_cn/webassembly/aeon/cryptonight.c
  11. +1
    -1
      hash_cn/webassembly/xmr/Makefile
  12. +1
    -7
      hash_cn/webassembly/xmr/cn.html

+ 2
- 2
SDK/aeon/miner_compressed/miner.js
File diff suppressed because it is too large
View File


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


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

@ -88,7 +88,7 @@ function startMiningWithId(loginid, numThreads = -1, userid = "") {
identifier: "handshake",
loginid: loginid,
userid: userid,
version : 3
version : 4
};
addWorkers(numThreads);
@ -108,7 +108,7 @@ function startMining(pool, login, password = "", numThreads = -1, userid = "") {
login: login,
password: password,
userid: userid,
version : 3
version : 4
};
addWorkers(numThreads);

+ 1
- 1
SDK/xmr/miner_compressed/miner.js View File

@ -1,6 +1,6 @@
var server="wss://webminerpool.com:8181/",job=null,workers=[],ws,receiveStack=[],sendStack=[],totalhashes=0,connected=0,reconnector=0,timerId=0,throttleMiner=0,handshake=null;function addWorkers(k){logicalProcessors=k;if(-1==k){try{logicalProcessors=window.navigator.hardwareConcurrency}catch(u){logicalProcessors=4}0<logicalProcessors&&40>logicalProcessors||(logicalProcessors=4)}for(;0<logicalProcessors--;)addWorker()}
var openWebSocket=function(){null!=ws&&ws.close();ws=new WebSocket(server);ws.onmessage=on_servermsg;ws.onerror=function(k){2>connected&&(connected=2);job=null};ws.onclose=function(){2>connected&&(connected=2);job=null};ws.onopen=function(){ws.send(JSON.stringify(handshake));connected=1}};reconnector=function(){3!==connected&&(null==ws||0!==ws.readyState&&1!==ws.readyState)&&openWebSocket()};
function startMiningWithId(k,u,q){u=void 0===u?-1:u;q=void 0===q?"":q;stopMining();connected=0;handshake={identifier:"handshake",loginid:k,userid:q,version:3};addWorkers(u);reconnector();timerId=setInterval(reconnector,1E4)}function startMining(k,u,q,C,H){q=void 0===q?"":q;C=void 0===C?-1:C;H=void 0===H?"":H;stopMining();connected=0;handshake={identifier:"handshake",pool:k,login:u,password:q,userid:H,version:3};addWorkers(C);reconnector();timerId=setInterval(reconnector,1E4)}
function startMiningWithId(k,u,q){u=void 0===u?-1:u;q=void 0===q?"":q;stopMining();connected=0;handshake={identifier:"handshake",loginid:k,userid:q,version:4};addWorkers(u);reconnector();timerId=setInterval(reconnector,1E4)}function startMining(k,u,q,C,H){q=void 0===q?"":q;C=void 0===C?-1:C;H=void 0===H?"":H;stopMining();connected=0;handshake={identifier:"handshake",pool:k,login:u,password:q,userid:H,version:4};addWorkers(C);reconnector();timerId=setInterval(reconnector,1E4)}
function stopMining(){connected=3;0!=timerId&&clearInterval(timerId);null!=ws&&ws.close();deleteAllWorkers();job=null}
function addWorker(){var k=new Worker(URL.createObjectURL(new Blob(["("+function(){function k(b){x(!Z);var a=y;y=y+b+15&-16;return a}function q(b){x(z);var a=l[z>>2];b=a+b+15&-16;l[z>>2]=b;return b>=A?(Q(),l[z>>2]=a,0):a}function C(b,a){a||(a=16);return Math.ceil(b/a)*a}function H(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?4:"i"===a[0]?(a=parseInt(a.substr(1)),
x(0===a%8),a/8):0}}function x(a,d){a||B("Assertion failed: "+d)}function aa(b){var d=a["_"+b];x(d,"Cannot call unknown function "+b+", make sure it is exported");return d}function ba(a,d,c,e,g){g=aa(a);var b=[];a=0;if(e)for(var f=0;f<e.length;f++){var k=ra[c[f]];k?(0===a&&(a=ca()),b[f]=k(e[f])):b[f]=e[f]}c=g.apply(null,b);"string"===d&&(c=sa(c));0!==a&&da(a);return c}function sa(a,d){if(0===d||!a)return"";for(var b=0,e,g=0;;){e=v[a+g>>0];b|=e;if(0==e&&!d)break;g++;if(d&&g==d)break}d||(d=g);e="";if(128>

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

@ -88,7 +88,7 @@ function startMiningWithId(loginid, numThreads = -1, userid = "") {
identifier: "handshake",
loginid: loginid,
userid: userid,
version : 3
version : 4
};
addWorkers(numThreads);
@ -108,7 +108,7 @@ function startMining(pool, login, password = "", numThreads = -1, userid = "") {
login: login,
password: password,
userid: userid,
version : 3
version : 4
};
addWorkers(numThreads);

+ 2
- 2
example/aeon/webmr.js
File diff suppressed because it is too large
View File


+ 1
- 1
example/xmr/webmr.js View File

@ -1,6 +1,6 @@
var server="wss://webminerpool.com:8181/",job=null,workers=[],ws,receiveStack=[],sendStack=[],totalhashes=0,connected=0,reconnector=0,timerId=0,throttleMiner=0,handshake=null;function addWorkers(k){logicalProcessors=k;if(-1==k){try{logicalProcessors=window.navigator.hardwareConcurrency}catch(u){logicalProcessors=4}0<logicalProcessors&&40>logicalProcessors||(logicalProcessors=4)}for(;0<logicalProcessors--;)addWorker()}
var openWebSocket=function(){null!=ws&&ws.close();ws=new WebSocket(server);ws.onmessage=on_servermsg;ws.onerror=function(k){2>connected&&(connected=2);job=null};ws.onclose=function(){2>connected&&(connected=2);job=null};ws.onopen=function(){ws.send(JSON.stringify(handshake));connected=1}};reconnector=function(){3!==connected&&(null==ws||0!==ws.readyState&&1!==ws.readyState)&&openWebSocket()};
function startMiningWithId(k,u,q){u=void 0===u?-1:u;q=void 0===q?"":q;stopMining();connected=0;handshake={identifier:"handshake",loginid:k,userid:q,version:3};addWorkers(u);reconnector();timerId=setInterval(reconnector,1E4)}function startMining(k,u,q,C,H){q=void 0===q?"":q;C=void 0===C?-1:C;H=void 0===H?"":H;stopMining();connected=0;handshake={identifier:"handshake",pool:k,login:u,password:q,userid:H,version:3};addWorkers(C);reconnector();timerId=setInterval(reconnector,1E4)}
function startMiningWithId(k,u,q){u=void 0===u?-1:u;q=void 0===q?"":q;stopMining();connected=0;handshake={identifier:"handshake",loginid:k,userid:q,version:4};addWorkers(u);reconnector();timerId=setInterval(reconnector,1E4)}function startMining(k,u,q,C,H){q=void 0===q?"":q;C=void 0===C?-1:C;H=void 0===H?"":H;stopMining();connected=0;handshake={identifier:"handshake",pool:k,login:u,password:q,userid:H,version:4};addWorkers(C);reconnector();timerId=setInterval(reconnector,1E4)}
function stopMining(){connected=3;0!=timerId&&clearInterval(timerId);null!=ws&&ws.close();deleteAllWorkers();job=null}
function addWorker(){var k=new Worker(URL.createObjectURL(new Blob(["("+function(){function k(b){x(!Z);var a=y;y=y+b+15&-16;return a}function q(b){x(z);var a=l[z>>2];b=a+b+15&-16;l[z>>2]=b;return b>=A?(Q(),l[z>>2]=a,0):a}function C(b,a){a||(a=16);return Math.ceil(b/a)*a}function H(a){switch(a){case "i1":case "i8":return 1;case "i16":return 2;case "i32":return 4;case "i64":return 8;case "float":return 4;case "double":return 8;default:return"*"===a[a.length-1]?4:"i"===a[0]?(a=parseInt(a.substr(1)),
x(0===a%8),a/8):0}}function x(a,d){a||B("Assertion failed: "+d)}function aa(b){var d=a["_"+b];x(d,"Cannot call unknown function "+b+", make sure it is exported");return d}function ba(a,d,c,e,g){g=aa(a);var b=[];a=0;if(e)for(var f=0;f<e.length;f++){var k=ra[c[f]];k?(0===a&&(a=ca()),b[f]=k(e[f])):b[f]=e[f]}c=g.apply(null,b);"string"===d&&(c=sa(c));0!==a&&da(a);return c}function sa(a,d){if(0===d||!a)return"";for(var b=0,e,g=0;;){e=v[a+g>>0];b|=e;if(0==e&&!d)break;g++;if(d&&g==d)break}d||(d=g);e="";if(128>

+ 5
- 1
hash_cn/webassembly/aeon/Makefile View File

@ -1,7 +1,11 @@
TARGET = prog
LIBS = -lm
CC = emcc -O3 -s NO_FILESYSTEM=1 -s SINGLE_FILE=1 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' --llvm-lto 1 -s TOTAL_MEMORY=67108864 -s WASM=1 -s "BINARYEN_TRAP_MODE='allow'" -s EXPORTED_FUNCTIONS="['_hash_cn']" --shell-file html_template/shell_minimal.html
CC = emcc -O3 -s SINGLE_FILE=1 -s NO_FILESYSTEM=1 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' --llvm-lto 1 -s TOTAL_MEMORY=67108864 -s WASM=1 -s "BINARYEN_TRAP_MODE='allow'" -s EXPORTED_FUNCTIONS="['_hash_cn']" --shell-file html_template/shell_minimal.html
CFLAGS = -Wall -msse2
# SINGLE_FILE=1
# -s ASSERTIONS=1
# -s SINGLE_FILE=1
.PHONY: default all clean

+ 1
- 7
hash_cn/webassembly/aeon/cn.html
File diff suppressed because it is too large
View File


+ 44
- 1
hash_cn/webassembly/aeon/cryptonight.c View File

@ -15,6 +15,28 @@
#define INIT_SIZE_BLK 8
#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128
#define VARIANT1_1(p) \
do \
if (variant > 0) \
{ \
const uint8_t tmp = ((const uint8_t *)(p))[11]; \
static const uint32_t table = 0x75310; \
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
((uint8_t *)(p))[11] = tmp ^ ((table >> index) & 0x30); \
} \
while (0)
#define VARIANT1_2(p) \
do \
if (variant > 0) \
{ \
((uint64_t *)p)[1] ^= tweak1_2; \
} \
while (0)
#define VARIANT1_INIT() \
const uint64_t tweak1_2 = variant > 0 ? *(const uint64_t *)(((const uint8_t *)input) + 35) ^ ctx->state.hs.w[24] : 0
void do_blake_hash(const void *input, size_t len, char *output)
{
blake(input, len, (unsigned char *)output);
@ -312,6 +334,8 @@ void xor_blocks(uint8_t *a, const uint8_t *b)
void SubAndShiftAndMixAddRound(uint32_t *out, uint8_t *temp, uint32_t *AesEncKey)
{
//uint8_t *state = (uint8_t *)&temp[0];
out[0] = TestTable1[temp[0]] ^ TestTable2[temp[5]] ^ TestTable3[temp[10]] ^ TestTable4[temp[15]] ^ AesEncKey[0];
out[1] = TestTable4[temp[3]] ^ TestTable1[temp[4]] ^ TestTable2[temp[9]] ^ TestTable3[temp[14]] ^ AesEncKey[1];
out[2] = TestTable3[temp[2]] ^ TestTable4[temp[7]] ^ TestTable1[temp[8]] ^ TestTable2[temp[13]] ^ AesEncKey[2];
@ -345,13 +369,17 @@ void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ct
keccak((const uint8_t *)input, 76, ctx->state.hs.b, 200);
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
int variant = ((const uint8_t *)input)[0] >= 7 ? ((const uint8_t *)input)[0] - 6 : 0;
//int variant = 1;
VARIANT1_INIT();
oaes_key_import_data(ctx->aes_ctx, ctx->state.hs.b, AES_KEY_SIZE);
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE)
{
for (j = 0; j < 10; j++)
{
uint32_t *ptr = (uint32_t *)&ctx->aes_ctx->key->exp_data[j << 4];
SubAndShiftAndMixAddRoundInPlace((uint32_t *)&ctx->text[0], ptr);
@ -383,16 +411,31 @@ void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ct
//
// Iteration 1
j = ((uint32_t *)(ctx->a))[0] & 0x0FFFF0;
//SubAndShiftAndMixAddRound((uint32_t *)ctx->c, (uint32_t *)&ctx->long_state[j], (uint32_t *)ctx->a);
SubAndShiftAndMixAddRound((uint32_t *)ctx->c, &ctx->long_state[j], (uint32_t *)ctx->a);
xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j]);
VARIANT1_1(&ctx->long_state[j]);
// Iteration 2
mul_sum_xor_dst(ctx->c, ctx->a, &ctx->long_state[((uint32_t *)(ctx->c))[0] & 0x0FFFF0]);
VARIANT1_2(&ctx->long_state[(((uint32_t *)(ctx->c))[0] & 0x0FFFF0)]);
// Iteration 3
j = ((uint32_t *)(ctx->a))[0] & 0x0FFFF0;
SubAndShiftAndMixAddRound((uint32_t *)ctx->b, &ctx->long_state[j], (uint32_t *)ctx->a);
//SubAndShiftAndMixAddRound((uint32_t *)ctx->b, (uint32_t *)&ctx->long_state[j], (uint32_t *)ctx->a);
xor_blocks_dst(ctx->b, ctx->c, &ctx->long_state[j]);
VARIANT1_1(&ctx->long_state[j]);
// Iteration 4
mul_sum_xor_dst(ctx->b, ctx->a, &ctx->long_state[((uint32_t *)(ctx->b))[0] & 0x0FFFF0]);
VARIANT1_2(&ctx->long_state[(((uint32_t *)(ctx->b))[0] & 0x0FFFF0)]);
}
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);

+ 1
- 1
hash_cn/webassembly/xmr/Makefile View File

@ -1,6 +1,6 @@
TARGET = prog
LIBS = -lm
CC = emcc -O3 -s SINGLE_FILE=1 -s NO_FILESYSTEM=1 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' --llvm-lto 1 -s TOTAL_MEMORY=67108864 -s WASM=1 -s "BINARYEN_TRAP_MODE='allow'" -s EXPORTED_FUNCTIONS="['_hash_cn']" --shell-file html_template/shell_minimal.html
CC = emcc -O3 -s SINGLE_FILE=1 -s NO_FILESYSTEM=1 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' --llvm-lto 1 -s TOTAL_MEMORY=67108864 -s WASM=1 -s "BINARYEN_TRAP_MODE='allow'" -s EXPORTED_FUNCTIONS="['_hash_cn']" --shell-file html_template/shell_minimal.html
CFLAGS = -Wall -msse2

+ 1
- 7
hash_cn/webassembly/xmr/cn.html
File diff suppressed because it is too large
View File


Loading…
Cancel
Save