From 04d583232c81dd0e03aa4f4b82bfdc1eb9cdd253 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Oct 2017 16:57:11 +0300 Subject: [PATCH 1/3] Test --- iguana/dpow/dpow_network.c | 10 +++++----- iguana/exchanges/LP_nativeDEX.c | 6 +++--- iguana/iguana777.h | 2 +- iguana/iguana_mofn.c | 28 ++++++++++++++++++++++------ iguana/main.c | 6 +++++- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 9899b9cac..c3e8ed36b 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -170,7 +170,7 @@ int32_t signed_nn_recv(void **freeptrp,struct supernet_info *myinfo,uint8_t nota vcalc_sha256(0,packethash.bytes,(void *)&sigpacket->nonce,(int32_t)(sigpacket->packetlen+sizeof(sigpacket->nonce)+sizeof(sigpacket->packetlen))); if ( bits256_cmp(packethash,sigpacket->packethash) == 0 && sigpacket->packethash.bytes[0] == 0 ) { - if ( bitcoin_recoververify(myinfo->ctx,"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) + if ( bitcoin_recoververify(myinfo->ctx[1],"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) { char *notary0 = "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828"; // expand to official notaries @@ -2020,7 +2020,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo pfd.events = NN_POLLOUT; if ( nn_poll(&pfd,1,100) > 0 ) { - sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); + sentbytes = signed_nn_send(myinfo,myinfo->ctx[2],myinfo->persistent_priv,myinfo->dpowsock,np,size); break; } usleep(1000); @@ -2168,13 +2168,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) //printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size)); if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) { - signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); + signed_nn_send(myinfo,myinfo->ctx[1],myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); //printf("send back[%ld]\n",strlen(retstr)+1); free(retstr); if ( broadcastflag != 0 ) { printf("BROADCAST dexp request.[%d]\n",size); - signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx[1],myinfo->persistent_priv,myinfo->dexsock,dexp,size); //signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); } } @@ -2183,7 +2183,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( (m= myinfo->numdpowipbits) > 0 ) { r = myinfo->dpowipbits[rand() % m]; - signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); + signed_nn_send(myinfo,myinfo->ctx[1],myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); printf("REP.%08x <- rand ip m.%d %x\n",dexp->crc32,m,r); } else printf("illegal state without dpowipbits?\n"); if ( dex_packetcheck(myinfo,dexp,size) == 0 ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 2f5ca02de..2365e1d9c 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -19,14 +19,14 @@ // marketmaker // // dPoW security -> 4: KMD notarized, 5: BTC notarized -// dICO allocation script // sign critical api calls (pubkey reg, listunspent, orders?) - +// // process stats.log local file -// verify portfolio, pricearray, interest to KMD withdraw // handles <-> pubkeys // deal with offline pubkeys, reputations, etc. +// // alice only coins GAME UNO BTM ANC: GAME BTCD PPC RDD XZC POT EAC FTC BASH SPR WDC UNO XPM XCN BELA CHC DIME MEC NAUT MED AUR MAX DGC RIC EB3 DOT BTM GEO ANC CANN ICASH WBB SRC PTC ADZ TIPS EQT START EFL FST FJC NYC GCN +// verify portfolio, pricearray, interest to KMD withdraw #include diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 74412e6f0..62539d3d0 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -150,7 +150,7 @@ struct supernet_info struct queueitem *DEX_quotes; cJSON *Cunspents,*Cspends; struct basilisk_swap *swaps[256]; int32_t numswaps; struct basilisk_message *messagetable; portable_mutex_t messagemutex; queue_t msgQ,p2pQ; - void *ctx; + void *ctx[4]; uint8_t *pingbuf; struct basilisk_request DEXaccept; FILE *dexfp; diff --git a/iguana/iguana_mofn.c b/iguana/iguana_mofn.c index 2756def45..946833dd1 100755 --- a/iguana/iguana_mofn.c +++ b/iguana/iguana_mofn.c @@ -238,19 +238,35 @@ int32_t gfshare_test(struct supernet_info *myinfo,int32_t M,int32_t N,int32_t da return ok!=1; } +void *bitcoin_ctx() +{ + void *ptr; + ptr = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + secp256k1_pedersen_context_initialize(ptr); + secp256k1_rangeproof_context_initialize(ptr); + return(ptr); +} + void iguana_fixsecp(struct supernet_info *myinfo) { - myinfo->ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - secp256k1_pedersen_context_initialize(myinfo->ctx); - secp256k1_rangeproof_context_initialize(myinfo->ctx); + int32_t i; + for (i=0; ictx)/sizeof(*myinfo->ctx); i++) + { + myinfo->ctx[i] = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + secp256k1_pedersen_context_initialize(myinfo->ctx[i]); + secp256k1_rangeproof_context_initialize(myinfo->ctx[i]); + } } void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]) { uint32_t i,x = 1; - myinfo->ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - secp256k1_pedersen_context_initialize(myinfo->ctx); - secp256k1_rangeproof_context_initialize(myinfo->ctx); + for (i=0; ictx)/sizeof(*myinfo->ctx); i++) + { + myinfo->ctx[i] = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + secp256k1_pedersen_context_initialize(myinfo->ctx[i]); + secp256k1_rangeproof_context_initialize(myinfo->ctx[i]); + } for (i=0; i<255; i++) { _exps[i] = x; diff --git a/iguana/main.c b/iguana/main.c index b3f9078f0..3444d336b 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -74,10 +74,14 @@ void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len) init_hexbytes_noT(str,hex,len); } +void *bitcoin_ctx(); struct supernet_info *SuperNET_MYINFO(char *passphrase) { - if ( MYINFO.ctx == 0 ) + int32_t i; + if ( MYINFO.ctx[0] == 0 ) { + for (i=0; i Date: Wed, 18 Oct 2017 16:58:35 +0300 Subject: [PATCH 2/3] Test --- iguana/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/main.c b/iguana/main.c index 3444d336b..b4ff56136 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -71,7 +71,7 @@ int32_t SuperNET_str2hex(uint8_t *hex,char *str) void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len) { - init_hexbytes_noT(str,hex,len); + init_hexbytes_noT(str,hex,len); } void *bitcoin_ctx(); From 443935c0525896e25133b5ab61df67d99b2a341f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 18 Oct 2017 17:05:32 +0300 Subject: [PATCH 3/3] Test --- iguana/iguana_notary.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index c6f98f4f2..4e0015366 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -60,14 +60,14 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che int32_t dpow_txhasnotarization(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid) { - cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; + cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 ) { if ( (vins= jarray(&numvins,txobj,"vin")) != 0 ) { if ( numvins >= DPOW_MIN_ASSETCHAIN_SIGS ) { - numnotaries = 0; + notarymask = numnotaries = 0; for (i=0; i