From ce446adfb692cafca083e20d5dcb6062589613e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 4 Feb 2017 21:32:03 +0200 Subject: [PATCH] test --- iguana/dpow/dpow_network.c | 17 +++++++++-------- iguana/iguana_mofn.c | 7 +++++++ includes/iguana_funcs.h | 2 ++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 9a4efab38..4bae54ed2 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -100,7 +100,7 @@ void dex_init(struct supernet_info *myinfo) portable_mutex_init(&myinfo->dexmutex); } -int32_t signed_nn_send(void *ctx,bits256 privkey,int32_t sock,void *packet,int32_t size) +int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,int32_t sock,void *packet,int32_t size) { int32_t i,j,sentbytes,siglen = 0; uint8_t sig[65],pubkey33[33],signpubkey33[33]; struct signed_nnpacket *sigpacket; if ( (sigpacket= calloc(1,size + sizeof(*sigpacket))) != 0 ) @@ -138,6 +138,7 @@ int32_t signed_nn_send(void *ctx,bits256 privkey,int32_t sock,void *packet,int32 } } free(sigpacket); + iguana_fixsecp(myinfo); printf("error signing nnpacket\n"); } return(-1); @@ -1710,7 +1711,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->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); + sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); break; } usleep(1000); @@ -1844,7 +1845,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( dex_packetcheck(myinfo,dexp,size) == 0 ) { //printf("FROM BUS.%08x -> pub\n",dexp->crc32); - signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); dex_packet(myinfo,dexp,size); } //printf("GOT DEX bus PACKET.%d\n",size); @@ -1860,13 +1861,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->ctx,myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); + signed_nn_send(myinfo,myinfo->ctx,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->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); } } else @@ -1874,13 +1875,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( (m= myinfo->numdpowipbits) > 0 ) { r = myinfo->dpowipbits[rand() % m]; - signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); + signed_nn_send(myinfo,myinfo->ctx,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 ) { - signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); - signed_nn_send(myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); //printf("REP.%08x -> dexbus and pub, t.%d lag.%d\n",dexp->crc32,dexp->timestamp,(int32_t)(time(NULL)-dexp->timestamp)); dex_packet(myinfo,dexp,size); } else printf("failed dexpacketcheck\n"); diff --git a/iguana/iguana_mofn.c b/iguana/iguana_mofn.c index 4cca28947..c1866f01f 100755 --- a/iguana/iguana_mofn.c +++ b/iguana/iguana_mofn.c @@ -238,6 +238,13 @@ int32_t gfshare_test(struct supernet_info *myinfo,int32_t M,int32_t N,int32_t da return ok!=1; } +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); +} + void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]) { uint32_t i,x = 1; diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index e3094974e..4a00dfe4a 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -637,6 +637,8 @@ void gfshare_ctx_decextract(uint8_t *logs,uint8_t *exps,gfshare_ctx * /* ctx */, void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]); int32_t init_sharenrs(uint8_t sharenrs[255],uint8_t *orig,int32_t m,int32_t n); void iguana_schnorr(struct supernet_info *myinfo); +void iguana_fixsecp(struct supernet_info *myinfo); + #include "../includes/iguana_api.h"