From 4e5684fc037c6d9f816d76d5ce2841c8867b481d Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 06:44:56 +0530 Subject: [PATCH 01/94] test --- privatebet/bet.c | 105 ++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 47 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index a622248c4c92..42db36c547d4 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -440,60 +440,70 @@ int main(int argc,const char *argv[]) printf("%s:%d, range:%d, numplayers:%d\n",__FUNCTION__,__LINE__,range,numplayers); // for dcv - BET_dcv=calloc(1,sizeof(struct privatebet_info)); - BET_dcv->pubsock = BET_nanosock(1,bindaddr,NN_PUB); - BET_dcv->pullsock = BET_nanosock(1,bindaddr1,NN_PULL); - BET_dcv->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; - BET_dcv->maxchips = CARDS777_MAXCHIPS; - BET_dcv->chipsize = CARDS777_CHIPSIZE; - BET_dcv->numplayers=numplayers; - BET_betinfo_set(BET_dcv,"demo",range,0,Maxplayers); - if ( OS_thread_create(&dcv_t,NULL,(void *)BET_hostdcv,(void *)BET_dcv) != 0 ) - { - printf("error launching BET_hostloop for pub.%d pull.%d\n",BET_dcv->pubsock,BET_dcv->pullsock); - exit(-1); - } - - // for bvv - BET_bvv=calloc(1,sizeof(struct privatebet_info)); - BET_bvv->subsock = BET_nanosock(0,bindaddr,NN_SUB); - BET_bvv->pushsock = BET_nanosock(0,bindaddr1,NN_PUSH); - BET_bvv->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; - BET_bvv->maxchips = CARDS777_MAXCHIPS; - BET_bvv->chipsize = CARDS777_CHIPSIZE; - BET_bvv->numplayers=numplayers; - BET_bvv->myplayerid=0; - BET_betinfo_set(BET_bvv,"demo",range,0,Maxplayers); - if ( OS_thread_create(&bvv_t,NULL,(void *)BET_clientbvv,(void *)BET_bvv) != 0 ) - { - printf("error launching BET_clientloop for sub.%d push.%d\n",BET_bvv->subsock,BET_bvv->pushsock); - exit(-1); - } - - // for players - BET_players=calloc(numplayers,sizeof(struct privatebet_info*)); - for(int i=0;ipubsock = BET_nanosock(1,bindaddr,NN_PUB); + BET_dcv->pullsock = BET_nanosock(1,bindaddr1,NN_PULL); + BET_dcv->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; + BET_dcv->maxchips = CARDS777_MAXCHIPS; + BET_dcv->chipsize = CARDS777_CHIPSIZE; + BET_dcv->numplayers=numplayers; + BET_betinfo_set(BET_dcv,"demo",range,0,Maxplayers); + if ( OS_thread_create(&dcv_t,NULL,(void *)BET_hostdcv,(void *)BET_dcv) != 0 ) + { + printf("error launching BET_hostloop for pub.%d pull.%d\n",BET_dcv->pubsock,BET_dcv->pullsock); + exit(-1); + } } - - for(int i=0;isubsock = BET_nanosock(0,bindaddr,NN_SUB); - BET_players[i]->pushsock = BET_nanosock(0,bindaddr1,NN_PUSH); - BET_players[i]->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; - BET_players[i]->maxchips = CARDS777_MAXCHIPS; - BET_players[i]->chipsize = CARDS777_CHIPSIZE; - BET_players[i]->numplayers=numplayers; - BET_players[i]->myplayerid=i; - BET_betinfo_set(BET_players[i],"demo",range,0,Maxplayers); - if (OS_thread_create(&players_t[i],NULL,(void *)BET_clientplayer,(void *)BET_players[i]) != 0 ) + BET_bvv=calloc(1,sizeof(struct privatebet_info)); + BET_bvv->subsock = BET_nanosock(0,bindaddr,NN_SUB); + BET_bvv->pushsock = BET_nanosock(0,bindaddr1,NN_PUSH); + BET_bvv->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; + BET_bvv->maxchips = CARDS777_MAXCHIPS; + BET_bvv->chipsize = CARDS777_CHIPSIZE; + BET_bvv->numplayers=numplayers; + BET_bvv->myplayerid=0; + BET_betinfo_set(BET_bvv,"demo",range,0,Maxplayers); + if ( OS_thread_create(&bvv_t,NULL,(void *)BET_clientbvv,(void *)BET_bvv) != 0 ) { - printf("error launching BET_clientloop for sub.%d push.%d\n",BET_players[i]->subsock,BET_players[i]->pushsock); + printf("error launching BET_clientloop for sub.%d push.%d\n",BET_bvv->subsock,BET_bvv->pushsock); exit(-1); - } + } } + // for players + if(strcmp(argv[1],"player")==0) + { + numplayers=1; + BET_players=calloc(numplayers,sizeof(struct privatebet_info*)); + for(int i=0;isubsock = BET_nanosock(0,bindaddr,NN_SUB); + BET_players[i]->pushsock = BET_nanosock(0,bindaddr1,NN_PUSH); + BET_players[i]->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; + BET_players[i]->maxchips = CARDS777_MAXCHIPS; + BET_players[i]->chipsize = CARDS777_CHIPSIZE; + BET_players[i]->numplayers=numplayers; + BET_players[i]->myplayerid=i; + BET_betinfo_set(BET_players[i],"demo",range,0,Maxplayers); + if (OS_thread_create(&players_t[i],NULL,(void *)BET_clientplayer,(void *)BET_players[i]) != 0 ) + { + printf("error launching BET_clientloop for sub.%d push.%d\n",BET_players[i]->subsock,BET_players[i]->pushsock); + exit(-1); + } + } + } + #if 0 if(pthread_join(dcv_t,NULL)) { printf("\nError in joining the main thread for dcv"); @@ -511,6 +521,7 @@ int main(int argc,const char *argv[]) printf("\nError in joining the main thread for player %d",i); } } + #endif return 0; } From b18449f056dfb471c1eb1137427cdc33899932fc Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 06:56:44 +0530 Subject: [PATCH 02/94] test --- privatebet/bet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 42db36c547d4..7d6ff8d9f680 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -455,6 +455,10 @@ int main(int argc,const char *argv[]) printf("error launching BET_hostloop for pub.%d pull.%d\n",BET_dcv->pubsock,BET_dcv->pullsock); exit(-1); } + if(pthread_join(dcv_t,NULL)) + { + printf("\nError in joining the main thread for dcv"); + } } // for bvv @@ -474,6 +478,10 @@ int main(int argc,const char *argv[]) printf("error launching BET_clientloop for sub.%d push.%d\n",BET_bvv->subsock,BET_bvv->pushsock); exit(-1); } + if(pthread_join(bvv_t,NULL)) + { + printf("\nError in joining the main thread for bvvv"); + } } // for players @@ -502,6 +510,13 @@ int main(int argc,const char *argv[]) exit(-1); } } + for(int i=0;i Date: Tue, 2 Jan 2018 07:00:08 +0530 Subject: [PATCH 03/94] test --- privatebet/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/client.c b/privatebet/client.c index 8ca2be5a453d..23a50beaf67d 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -526,6 +526,7 @@ void* BET_clientplayer(void * _ptr) char *rendered=cJSON_Print(playerInfo); int bytes=nn_send(bet->pushsock,rendered,strlen(rendered),0); + printf("\n%s:%d:bytes:%d,buf:%s",__FUNCTION__,__LINE__,bytes,rendered); while (1) { char *buf = NULL; From 446f5ca314e19c397813cd7f09f1b92a1a90cc77 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 07:03:52 +0530 Subject: [PATCH 04/94] test --- privatebet/bet.c | 2 ++ privatebet/host.c | 1 + 2 files changed, 3 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 7d6ff8d9f680..7db7c0ce2e4f 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -437,6 +437,8 @@ int main(int argc,const char *argv[]) range = (range % 52) + 1; numplayers = (numplayers % (CARDS777_MAXPLAYERS-1)) + 2; + range=2; + numplayers=2; printf("%s:%d, range:%d, numplayers:%d\n",__FUNCTION__,__LINE__,range,numplayers); // for dcv diff --git a/privatebet/host.c b/privatebet/host.c index f90a720e4057..27331c2da440 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -363,6 +363,7 @@ void* BET_hostdcv(void * _ptr) { char *buf=NULL; int bytes=nn_recv(bet->pullsock,&buf,NN_MSG,0); + printf("\n%s:%d, buf:%s",__FUNCTION__,__LINE__,buf); if(bytes>0) { gameInfo=cJSON_Parse(buf); From 86b5c37d62393caf38ef6c1f497d621f53539366 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:25:16 +0530 Subject: [PATCH 05/94] test --- privatebet/bet.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 7db7c0ce2e4f..ee7bd6420e69 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -442,7 +442,7 @@ int main(int argc,const char *argv[]) printf("%s:%d, range:%d, numplayers:%d\n",__FUNCTION__,__LINE__,range,numplayers); // for dcv - if(strcmp(argv[1],"dcv")==0) + if((argc==2)&&(strcmp(argv[1],"dcv")==0)) { BET_dcv=calloc(1,sizeof(struct privatebet_info)); BET_dcv->pubsock = BET_nanosock(1,bindaddr,NN_PUB); @@ -464,7 +464,7 @@ int main(int argc,const char *argv[]) } // for bvv - if(strcmp(argv[1],"bvv")==0) + else if((argc==2)&&(strcmp(argv[1],"bvv")==0)) { BET_bvv=calloc(1,sizeof(struct privatebet_info)); BET_bvv->subsock = BET_nanosock(0,bindaddr,NN_SUB); @@ -487,38 +487,44 @@ int main(int argc,const char *argv[]) } // for players - if(strcmp(argv[1],"player")==0) + else if((argc==3)&&(strcmp(argv[1],"player")==0)) { - numplayers=1; + char *ptr; BET_players=calloc(numplayers,sizeof(struct privatebet_info*)); - for(int i=0;isubsock = BET_nanosock(0,bindaddr,NN_SUB); BET_players[i]->pushsock = BET_nanosock(0,bindaddr1,NN_PUSH); BET_players[i]->maxplayers = (Maxplayers < CARDS777_MAXPLAYERS) ? Maxplayers : CARDS777_MAXPLAYERS; BET_players[i]->maxchips = CARDS777_MAXCHIPS; BET_players[i]->chipsize = CARDS777_CHIPSIZE; BET_players[i]->numplayers=numplayers; - BET_players[i]->myplayerid=i; + BET_players[i]->myplayerid=strtoul(argv[2],&ptr,10);; BET_betinfo_set(BET_players[i],"demo",range,0,Maxplayers); if (OS_thread_create(&players_t[i],NULL,(void *)BET_clientplayer,(void *)BET_players[i]) != 0 ) { printf("error launching BET_clientloop for sub.%d push.%d\n",BET_players[i]->subsock,BET_players[i]->pushsock); exit(-1); } - } - for(int i=0;i Date: Tue, 2 Jan 2018 09:26:37 +0530 Subject: [PATCH 06/94] test --- privatebet/bet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index ee7bd6420e69..cfd0e35e8075 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -522,9 +522,9 @@ int main(int argc,const char *argv[]) else { printf("\nInvalid Usage"); - printf("\nFor DCV: .\bet dcv"); - printf("\nFor BVV: .\bet bvv"); - printf("\nFor Player: .\bet player player_id"); + printf("\nFor DCV: .\\bet dcv"); + printf("\nFor BVV: .\\bet bvv"); + printf("\nFor Player: .\\bet player player_id"); } #if 0 if(pthread_join(dcv_t,NULL)) From dc0f322788aae511b151ee55b71d576fe21aeb9e Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:28:14 +0530 Subject: [PATCH 07/94] test --- privatebet/bet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index cfd0e35e8075..930f13cc1d52 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -522,9 +522,9 @@ int main(int argc,const char *argv[]) else { printf("\nInvalid Usage"); - printf("\nFor DCV: .\\bet dcv"); - printf("\nFor BVV: .\\bet bvv"); - printf("\nFor Player: .\\bet player player_id"); + printf("\nFor DCV: ./bet dcv"); + printf("\nFor BVV: ./bet bvv"); + printf("\nFor Player: ./bet player player_id"); } #if 0 if(pthread_join(dcv_t,NULL)) From 8d3b684680839caa616352bb0a2beb2f395fe1ca Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:37:19 +0530 Subject: [PATCH 08/94] test --- privatebet/bet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 930f13cc1d52..392522c9d8e0 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -490,6 +490,7 @@ int main(int argc,const char *argv[]) else if((argc==3)&&(strcmp(argv[1],"player")==0)) { char *ptr; + i=0; BET_players=calloc(numplayers,sizeof(struct privatebet_info*)); //for(int i=0;imaxchips = CARDS777_MAXCHIPS; BET_players[i]->chipsize = CARDS777_CHIPSIZE; BET_players[i]->numplayers=numplayers; - BET_players[i]->myplayerid=strtoul(argv[2],&ptr,10);; + BET_players[i]->myplayerid=atoi(argv[2]); BET_betinfo_set(BET_players[i],"demo",range,0,Maxplayers); if (OS_thread_create(&players_t[i],NULL,(void *)BET_clientplayer,(void *)BET_players[i]) != 0 ) { From ea7bdda655a3e73d8485f420295a4adc94d3130e Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:38:31 +0530 Subject: [PATCH 09/94] test --- privatebet/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/host.c b/privatebet/host.c index 27331c2da440..e75d90088688 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -363,9 +363,9 @@ void* BET_hostdcv(void * _ptr) { char *buf=NULL; int bytes=nn_recv(bet->pullsock,&buf,NN_MSG,0); - printf("\n%s:%d, buf:%s",__FUNCTION__,__LINE__,buf); if(bytes>0) { + printf("\n%s:%d, buf:%s",__FUNCTION__,__LINE__,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init")) { From 63625d832ba4daa58ed29e50c9aa41a19558984f Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:41:51 +0530 Subject: [PATCH 10/94] test --- privatebet/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/host.c b/privatebet/host.c index e75d90088688..294b2c82f0fc 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -365,7 +365,7 @@ void* BET_hostdcv(void * _ptr) int bytes=nn_recv(bet->pullsock,&buf,NN_MSG,0); if(bytes>0) { - printf("\n%s:%d, buf:%s",__FUNCTION__,__LINE__,buf); + printf("\n%s:%d, players initialized:%d, max players:%d,buf:%s",__FUNCTION__,__LINE__,numplayers,bet->numplayers,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init")) { From b5c9c8bd1a85a3f7f76d67e8d45b16d5e0104284 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 09:45:04 +0530 Subject: [PATCH 11/94] test --- privatebet/host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/host.c b/privatebet/host.c index 294b2c82f0fc..df6ab14e5b43 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -365,11 +365,12 @@ void* BET_hostdcv(void * _ptr) int bytes=nn_recv(bet->pullsock,&buf,NN_MSG,0); if(bytes>0) { - printf("\n%s:%d, players initialized:%d, max players:%d,buf:%s",__FUNCTION__,__LINE__,numplayers,bet->numplayers,buf); + printf("\n%s:%d,buf:%s",__FUNCTION__,__LINE__,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init")) { numplayers++; + printf("\n%d:%d",numplayers,bet->numplayers); playerID=jint(gameInfo,"playerid"); range=jint(gameInfo,"range"); playerInfo=cJSON_GetObjectItem(gameInfo,"playercards"); From 40b5f46797d4ed6d911998ab5549dfebb218232d Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 10:36:38 +0530 Subject: [PATCH 12/94] test --- privatebet/client.c | 1 + privatebet/host.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 23a50beaf67d..8782195fe333 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -652,6 +652,7 @@ void* BET_clientbvv(void * _ptr) } } } + printf("\n%s:%d",__FUNCTION__,__LINE__); while (flag) { char *buf = NULL; diff --git a/privatebet/host.c b/privatebet/host.c index df6ab14e5b43..cc290b3520f8 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -370,7 +370,6 @@ void* BET_hostdcv(void * _ptr) if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init")) { numplayers++; - printf("\n%d:%d",numplayers,bet->numplayers); playerID=jint(gameInfo,"playerid"); range=jint(gameInfo,"range"); playerInfo=cJSON_GetObjectItem(gameInfo,"playercards"); From 1d0107521ce30ad493c42cc852e8bc6f7f79f10e Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 10:41:22 +0530 Subject: [PATCH 13/94] test --- privatebet/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/privatebet/client.c b/privatebet/client.c index 8782195fe333..d70229702dab 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -533,6 +533,7 @@ void* BET_clientplayer(void * _ptr) int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"decode")) { @@ -659,6 +660,7 @@ void* BET_clientbvv(void * _ptr) int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init_d")) { From 6e53330a25b2075049ab947354959abca295c30d Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 10:45:19 +0530 Subject: [PATCH 14/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index d70229702dab..43f5992c53c9 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -703,7 +703,7 @@ void* BET_clientbvv(void * _ptr) } } char *rendered=cJSON_Print(gameInfo); - nn_send(bet->pubsock,rendered,strlen(rendered),0); + nn_send(bet->pushsock,rendered,strlen(rendered),0); flag=0; } } From 6fa11c1531b0fa031c6ee684b5f8d583b841aeaf Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 10:57:33 +0530 Subject: [PATCH 15/94] test --- privatebet/bet.c | 8 ++++++++ privatebet/client.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 392522c9d8e0..e2581075e55f 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -834,6 +834,11 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } memcpy(cardshares[i].bytes,tmp.bytes,sizeof(bits256)); } + printf("\nThe shares are:\n"); + for(i=0;imyplayerid==0));i++) + for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); if ( bits256_nonz(decoded256) == 0 ) From 6c2d21fcbc05dc6f0a9e1a0defbfb2ca65daead7 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 11:30:28 +0530 Subject: [PATCH 16/94] test --- privatebet/bet.c | 31 +++++++++++++++++++++++++++++++ privatebet/client.c | 17 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index e2581075e55f..11d39beb4302 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -812,6 +812,37 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num uint8_t **shares,flag=0; uint32_t playerid; char share_str[177]; + pthread_t t_req,t_rcv,t_res; + + if ( OS_thread_create(&t_req,NULL,(void *)BET_request(),NULL) != 0 ) + { + printf("error launching BET_request thread"); + exit(-1); + } + if ( OS_thread_create(&t_res,NULL,(void *)BET_response(),NULL) != 0 ) + { + printf("error launching BET_response thread"); + exit(-1); + } + if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive(),NULL) != 0 ) + { + printf("error launching BET_receive thread"); + exit(-1); + } + + if(pthread_join(t_req,NULL)) + { + printf("\nError in joining the main thread for t_req"); + } + if(pthread_join(t_res,NULL)) + { + printf("\nError in joining the main thread for t_res"); + } + if(pthread_join(t_rcv,NULL)) + { + printf("\nError in joining the main thread for t_rcv"); + } + shares=calloc(numplayers,sizeof(uint8_t*)); for(i=0;i Date: Tue, 2 Jan 2018 11:36:17 +0530 Subject: [PATCH 17/94] test --- privatebet/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 07cca35e6dcf..eebe20e2ee62 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -396,17 +396,17 @@ char *enc_share_str(char hexstr[177],struct enc_share x) return(hexstr); } -bits256 BET_request() +void* BET_request(void* _ptr) { printf("\n%s:%d",__FUNCTION__,__LINE__); } -bits256 BET_response() +void* BET_response(void* _ptr) { printf("\n%s:%d",__FUNCTION__,__LINE__); } -bits256 BET_receive() +void* BET_receive(void* _ptr) { printf("\n%s:%d",__FUNCTION__,__LINE__); From 6a3f7724ebfc2640cdbc2cd939846d4425ee67b9 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 11:42:51 +0530 Subject: [PATCH 18/94] test --- privatebet/bet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 11d39beb4302..2790732d2bc8 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -814,17 +814,17 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num char share_str[177]; pthread_t t_req,t_rcv,t_res; - if ( OS_thread_create(&t_req,NULL,(void *)BET_request(),NULL) != 0 ) + if ( OS_thread_create(&t_req,NULL,(void *)BET_request,NULL) != 0 ) { printf("error launching BET_request thread"); exit(-1); } - if ( OS_thread_create(&t_res,NULL,(void *)BET_response(),NULL) != 0 ) + if ( OS_thread_create(&t_res,NULL,(void *)BET_response,NULL) != 0 ) { printf("error launching BET_response thread"); exit(-1); } - if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive(),NULL) != 0 ) + if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive,NULL) != 0 ) { printf("error launching BET_receive thread"); exit(-1); From 96bb5ad929aca91cbac476979f70ee75d92f2ecd Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 15:17:57 +0530 Subject: [PATCH 19/94] test --- privatebet/bet.c | 6 +++--- privatebet/client.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 2790732d2bc8..02837ec71164 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -814,17 +814,17 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num char share_str[177]; pthread_t t_req,t_rcv,t_res; - if ( OS_thread_create(&t_req,NULL,(void *)BET_request,NULL) != 0 ) + if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) { printf("error launching BET_request thread"); exit(-1); } - if ( OS_thread_create(&t_res,NULL,(void *)BET_response,NULL) != 0 ) + if ( OS_thread_create(&t_res,NULL,(void *)BET_response,bet) != 0 ) { printf("error launching BET_response thread"); exit(-1); } - if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive,NULL) != 0 ) + if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive,bet) != 0 ) { printf("error launching BET_receive thread"); exit(-1); diff --git a/privatebet/client.c b/privatebet/client.c index eebe20e2ee62..e10ecbd34af1 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -398,7 +398,8 @@ char *enc_share_str(char hexstr[177],struct enc_share x) void* BET_request(void* _ptr) { - printf("\n%s:%d",__FUNCTION__,__LINE__); + struct privatebet_info *bet = _ptr; + printf("\n%s:%d:player_id:%d",__FUNCTION__,__LINE__,bet->myplayerid); } void* BET_response(void* _ptr) From 6bc5ef365e6eda416a79a6b9c5226386a588bfb8 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 16:12:17 +0530 Subject: [PATCH 20/94] test --- privatebet/bet.c | 1 - privatebet/bet.h | 1 - privatebet/client.c | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 02837ec71164..bd527e47da3c 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -53,7 +53,6 @@ uint8_t sharenrs[256]; struct rpcrequest_info *LP_garbage_collector; struct enc_share { uint8_t bytes[sizeof(bits256)+crypto_box_NONCEBYTES+crypto_box_ZEROBYTES]; }; struct enc_share *g_shares=NULL; -//struct enc_share g_shares[CARDS777_MAXPLAYERS*CARDS777_MAXPLAYERS*CARDS777_MAXCARDS]; bits256 v_hash[CARDS777_MAXCARDS][CARDS777_MAXCARDS]; bits256 g_hash[CARDS777_MAXPLAYERS][CARDS777_MAXCARDS]; diff --git a/privatebet/bet.h b/privatebet/bet.h index c7bbf19da179..563c20dbb0a6 100644 --- a/privatebet/bet.h +++ b/privatebet/bet.h @@ -276,7 +276,6 @@ struct privatebet_info uint32_t timestamp; char peerids[CARDS777_MAXPLAYERS+1][67]; }; - struct privatebet_rawpeerln { uint64_t msatoshi_to_us,msatoshi_total; diff --git a/privatebet/client.c b/privatebet/client.c index e10ecbd34af1..aa95335bd2d5 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -398,18 +398,46 @@ char *enc_share_str(char hexstr[177],struct enc_share x) void* BET_request(void* _ptr) { + char bindaddr[128]="ipc:///tmp/bet.ipc"; struct privatebet_info *bet = _ptr; - printf("\n%s:%d:player_id:%d",__FUNCTION__,__LINE__,bet->myplayerid); + + cJSON *shareInfo=NULL; + char *buf=NULL,str[65]; + int bytes; + + for(int i=0;irange;i++) + { + for(int j=0;jnumplayers;j++) + { + if(j!=bet->myplayerid) + { + shareInfo=cJSON_CreateObject(); + cJSON_AddStringToObject(shareInfo,"messageid","request_share"); + cJSON_AddNumberToObject(shareInfo,"ofCardID",i); + cJSON_AddNumberToObject(shareInfo,"ofPlayerID",j); + cJSON_AddNumberToObject(shareInfo,"forPlayerID",bet->myplayerid); + buf=cJSON_Print(shareInfo); + bytes=nn_send(bet->pushsock,buf,strlen(buf),0); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + cJSON_Delete(shareInfo); + } + } + } } void* BET_response(void* _ptr) { + char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; printf("\n%s:%d",__FUNCTION__,__LINE__); } void* BET_receive(void* _ptr) { - printf("\n%s:%d",__FUNCTION__,__LINE__); + char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; + char *buf = NULL; + struct privatebet_info *bet = _ptr; + int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } From 85b5e0e5cf78f7e88add95807daf18b0091c177e Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 16:20:01 +0530 Subject: [PATCH 21/94] test --- privatebet/bet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index bd527e47da3c..2aa5199f3b4d 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -841,7 +841,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nError in joining the main thread for t_rcv"); } - + #if 0 shares=calloc(numplayers,sizeof(uint8_t*)); for(i=0;i Date: Tue, 2 Jan 2018 16:23:03 +0530 Subject: [PATCH 22/94] test --- privatebet/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/client.c b/privatebet/client.c index aa95335bd2d5..1d2049960b33 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -418,6 +418,7 @@ void* BET_request(void* _ptr) cJSON_AddNumberToObject(shareInfo,"forPlayerID",bet->myplayerid); buf=cJSON_Print(shareInfo); bytes=nn_send(bet->pushsock,buf,strlen(buf),0); + printf("\nMyplayerid:%d",bet->myplayerid); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareInfo); } From 77b07bb62e25977393109ef81e92bee425833a8b Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 16:26:23 +0530 Subject: [PATCH 23/94] test --- privatebet/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 1d2049960b33..8631f5651e30 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -437,8 +437,12 @@ void* BET_receive(void* _ptr) char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; char *buf = NULL; struct privatebet_info *bet = _ptr; - int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + //int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); + //printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + while(1) + { + sleep(5); + } } From 9bd684a8e054b57bec100f970c74b987e6228256 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 16:33:50 +0530 Subject: [PATCH 24/94] test --- privatebet/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 8631f5651e30..55385bfb27d0 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -437,11 +437,13 @@ void* BET_receive(void* _ptr) char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; char *buf = NULL; struct privatebet_info *bet = _ptr; - //int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); - //printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); while(1) { - sleep(5); + int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); + if(bytes>0) + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + sleep(1); + } } From 9c6eca56be606ac5ce50f230804a9f00f302e5ac Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:12:24 +0530 Subject: [PATCH 25/94] test --- privatebet/bet.c | 11 ++++++++- privatebet/bet.h | 8 +++++++ privatebet/client.c | 54 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 2aa5199f3b4d..f847098d20e3 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -812,13 +812,22 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num uint32_t playerid; char share_str[177]; pthread_t t_req,t_rcv,t_res; + struct privatebet_share *share_info=NULL; + + share_info=calloc(1,sizeof(struct privatebet_share)); + share_info->bvv_public_key=public_key_b; + share_info->player_key=key; + share_info->subsock=bet->subsock; + share_info->myplayerid=bet->myplayerid; + share_info->range=bet->range; + share_info->numplayers=bet->numplayers; if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) { printf("error launching BET_request thread"); exit(-1); } - if ( OS_thread_create(&t_res,NULL,(void *)BET_response,bet) != 0 ) + if ( OS_thread_create(&t_res,NULL,(void *)BET_response,share_info) != 0 ) { printf("error launching BET_response thread"); exit(-1); diff --git a/privatebet/bet.h b/privatebet/bet.h index 563c20dbb0a6..fba9c56dc75a 100644 --- a/privatebet/bet.h +++ b/privatebet/bet.h @@ -276,6 +276,14 @@ struct privatebet_info uint32_t timestamp; char peerids[CARDS777_MAXPLAYERS+1][67]; }; + +struct privatebet_share +{ + int32_t numplayers,range,myplayerid; + int32_t pullsock,pubsock,subsock,pushsock; + bits256 bvv_public_key; + struct pair256 player_key; +}; struct privatebet_rawpeerln { uint64_t msatoshi_to_us,msatoshi_total; diff --git a/privatebet/client.c b/privatebet/client.c index 55385bfb27d0..b4fe53e890c9 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -428,8 +428,58 @@ void* BET_request(void* _ptr) void* BET_response(void* _ptr) { - char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; - printf("\n%s:%d",__FUNCTION__,__LINE__); + + int32_t ofCardID,ofPlayerID,forPlayerID; + struct enc_share temp; + char str[65],enc_str[177],*buf; + bits256 share; + uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; + struct privatebet_share *share_info=_ptr; + cJSON *temp; + while(1) + { + int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); + if(bytes>0) + { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + temp=cJSON_Parse(buf); + if(0==strcmp(cJSON_str(cJSON_GetObjectItem(temp,"messageid")),"request_share")) + { + ofCardID=jint(temp,"ofCardID"); + ofPlayerID=jint(temp,"ofPlayerID"); + forPlayerID=jint(temp,"forPlayerID"); + + if((ofPlayerID==share_info->myplayerid)&&(forPlayerID!=share_info->myplayerid)) + { + temp=g_shares[ofPlayerID*share_info->numplayers*share_info->range + (ofCardID*share_info->numplayers + forPlayerID)]; + recvlen = sizeof(temp); + if ( (ptr= BET_decrypt(decipher,sizeof(decipher),share_info->bvv_public_key,share_info->player_key.priv,temp.bytes,&recvlen)) == 0 ) + printf("decrypt error "); + else + { + memcpy(share.bytes,ptr,recvlen); + cJSON_Delete(temp); + temp=cJSON_CreateObject(); + cJSON_AddStringToObject(temp,"messageid","response_share"); + cJSON_AddNumberToObject(temp,"ofCardID",ofCardID); + cJSON_AddNumberToObject(temp,"ofPlayerID",ofPlayerID); + cJSON_AddNumberToObject(temp,"forPlayerID",forPlayerID); + jaddbits256(temp,"share",share); + } + if(share_info->pushsock>=0){ + char *buf=NULL; + buf=cJSON_Print(temp); + int bytes=nn_send(share_info->pushsock,buf,strlen(buf),0); + } + } + + } + + } + + sleep(1); + + } } void* BET_receive(void* _ptr) From 382f6ca9d8c11867c60bc01fb449982c32380bf9 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:16:32 +0530 Subject: [PATCH 26/94] test --- privatebet/bet.h | 16 +++++++++------- privatebet/client.c | 28 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/privatebet/bet.h b/privatebet/bet.h index fba9c56dc75a..c781b19ad173 100644 --- a/privatebet/bet.h +++ b/privatebet/bet.h @@ -277,13 +277,6 @@ struct privatebet_info char peerids[CARDS777_MAXPLAYERS+1][67]; }; -struct privatebet_share -{ - int32_t numplayers,range,myplayerid; - int32_t pullsock,pubsock,subsock,pushsock; - bits256 bvv_public_key; - struct pair256 player_key; -}; struct privatebet_rawpeerln { uint64_t msatoshi_to_us,msatoshi_total; @@ -309,6 +302,15 @@ struct privatebet_vars struct pair256 { bits256 priv,prod; }; +struct privatebet_share +{ + int32_t numplayers,range,myplayerid; + int32_t pullsock,pubsock,subsock,pushsock; + bits256 bvv_public_key; + struct pair256 player_key; +}; + + bits256 *BET_process_packet(bits256 *cardpubs,bits256 *deckidp,bits256 senderpub,bits256 mypriv,uint8_t *decoded,int32_t maxsize,bits256 mypub,uint8_t *sendbuf,int32_t size,int32_t checkplayers,int32_t range); cJSON *BET_hostrhashes(struct privatebet_info *bet); bits256 BET_clientrhash(); diff --git a/privatebet/client.c b/privatebet/client.c index b4fe53e890c9..d46eb4584210 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -435,19 +435,19 @@ void* BET_response(void* _ptr) bits256 share; uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; struct privatebet_share *share_info=_ptr; - cJSON *temp; + cJSON *share_res; while(1) { int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); if(bytes>0) { printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); - temp=cJSON_Parse(buf); - if(0==strcmp(cJSON_str(cJSON_GetObjectItem(temp,"messageid")),"request_share")) + share_res=cJSON_Parse(buf); + if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { - ofCardID=jint(temp,"ofCardID"); - ofPlayerID=jint(temp,"ofPlayerID"); - forPlayerID=jint(temp,"forPlayerID"); + ofCardID=jint(share_res,"ofCardID"); + ofPlayerID=jint(share_res,"ofPlayerID"); + forPlayerID=jint(share_res,"forPlayerID"); if((ofPlayerID==share_info->myplayerid)&&(forPlayerID!=share_info->myplayerid)) { @@ -458,17 +458,17 @@ void* BET_response(void* _ptr) else { memcpy(share.bytes,ptr,recvlen); - cJSON_Delete(temp); - temp=cJSON_CreateObject(); - cJSON_AddStringToObject(temp,"messageid","response_share"); - cJSON_AddNumberToObject(temp,"ofCardID",ofCardID); - cJSON_AddNumberToObject(temp,"ofPlayerID",ofPlayerID); - cJSON_AddNumberToObject(temp,"forPlayerID",forPlayerID); - jaddbits256(temp,"share",share); + cJSON_Delete(share_res); + share_res=cJSON_CreateObject(); + cJSON_AddStringToObject(share_res,"messageid","response_share"); + cJSON_AddNumberToObject(share_res,"ofCardID",ofCardID); + cJSON_AddNumberToObject(share_res,"ofPlayerID",ofPlayerID); + cJSON_AddNumberToObject(share_res,"forPlayerID",forPlayerID); + jaddbits256(share_res,"share",share); } if(share_info->pushsock>=0){ char *buf=NULL; - buf=cJSON_Print(temp); + buf=cJSON_Print(share_res); int bytes=nn_send(share_info->pushsock,buf,strlen(buf),0); } } From 9052ecbadb7a14e0c8a442b2e4a126c9b7bc41f4 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:18:48 +0530 Subject: [PATCH 27/94] test --- privatebet/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/client.c b/privatebet/client.c index d46eb4584210..c214033c0da2 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -470,6 +470,7 @@ void* BET_response(void* _ptr) char *buf=NULL; buf=cJSON_Print(share_res); int bytes=nn_send(share_info->pushsock,buf,strlen(buf),0); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } From 3cd24a8d3543ba471b8b7f74f21c89e6aeb0f3b3 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:28:14 +0530 Subject: [PATCH 28/94] test --- privatebet/client.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index c214033c0da2..726a0a7b1dd0 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -418,7 +418,6 @@ void* BET_request(void* _ptr) cJSON_AddNumberToObject(shareInfo,"forPlayerID",bet->myplayerid); buf=cJSON_Print(shareInfo); bytes=nn_send(bet->pushsock,buf,strlen(buf),0); - printf("\nMyplayerid:%d",bet->myplayerid); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareInfo); } @@ -441,7 +440,7 @@ void* BET_response(void* _ptr) int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); if(bytes>0) { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + share_res=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { @@ -460,7 +459,7 @@ void* BET_response(void* _ptr) memcpy(share.bytes,ptr,recvlen); cJSON_Delete(share_res); share_res=cJSON_CreateObject(); - cJSON_AddStringToObject(share_res,"messageid","response_share"); + cJSON_AddStringToObject(share_res,"messageid","receive_share"); cJSON_AddNumberToObject(share_res,"ofCardID",ofCardID); cJSON_AddNumberToObject(share_res,"ofPlayerID",ofPlayerID); cJSON_AddNumberToObject(share_res,"forPlayerID",forPlayerID); @@ -470,7 +469,6 @@ void* BET_response(void* _ptr) char *buf=NULL; buf=cJSON_Print(share_res); int bytes=nn_send(share_info->pushsock,buf,strlen(buf),0); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } @@ -488,15 +486,20 @@ void* BET_receive(void* _ptr) char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; char *buf = NULL; struct privatebet_info *bet = _ptr; + cJSON *share_rcv; while(1) { int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + { + share_rcv=cJSON_Parse(buf); + if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_rcv,"messageid")),"receive_share")) + { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + } + } sleep(1); - } - } From 6e1cb4968f6155dec8445daf605d1abdf3758bc8 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:33:29 +0530 Subject: [PATCH 29/94] test --- privatebet/client.c | 1 + privatebet/host.c | 1 + 2 files changed, 2 insertions(+) diff --git a/privatebet/client.c b/privatebet/client.c index 726a0a7b1dd0..5a0c29869982 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -492,6 +492,7 @@ void* BET_receive(void* _ptr) int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); share_rcv=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_rcv,"messageid")),"receive_share")) { diff --git a/privatebet/host.c b/privatebet/host.c index cc290b3520f8..f41fd9f9821b 100644 --- a/privatebet/host.c +++ b/privatebet/host.c @@ -415,6 +415,7 @@ void* BET_hostdcv(void * _ptr) if(bytes>0) { bytes=nn_send(bet->pubsock,buf,strlen(buf),0); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } nn_shutdown(bet->pullsock,0); From 8959ba342b6ed09e2a091315f7afeaecea290e83 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:35:47 +0530 Subject: [PATCH 30/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 5a0c29869982..8cdb21de40d1 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -487,7 +487,7 @@ void* BET_receive(void* _ptr) char *buf = NULL; struct privatebet_info *bet = _ptr; cJSON *share_rcv; - while(1) + while(0) { int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) From f9ae524c3e5fd3644218e0d275afa0d42c368158 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:38:12 +0530 Subject: [PATCH 31/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 8cdb21de40d1..1da86db36f05 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -440,7 +440,7 @@ void* BET_response(void* _ptr) int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); if(bytes>0) { - + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); share_res=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { From a0f05745df817c045dbdf97d2ec4ff41ab0e9c7f Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:40:46 +0530 Subject: [PATCH 32/94] test --- privatebet/bet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index f847098d20e3..b7a8e106660d 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -821,6 +821,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num share_info->myplayerid=bet->myplayerid; share_info->range=bet->range; share_info->numplayers=bet->numplayers; + share_info->pushsock=bet->pushsock; if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) { From 6744e6e4014eb136c6b724271de42feeff4efa44 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 17:45:43 +0530 Subject: [PATCH 33/94] test --- privatebet/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 1da86db36f05..aa8cccd9d579 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -440,7 +440,7 @@ void* BET_response(void* _ptr) int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); if(bytes>0) { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + share_res=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { @@ -473,6 +473,10 @@ void* BET_response(void* _ptr) } } + else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"receive_share")) + { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + } } From 1c1635c91a936b65a01e2aa108a7cdc3e173962b Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 18:44:42 +0530 Subject: [PATCH 34/94] test --- privatebet/client.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index aa8cccd9d579..6b01a221dd20 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -428,16 +428,22 @@ void* BET_request(void* _ptr) void* BET_response(void* _ptr) { - int32_t ofCardID,ofPlayerID,forPlayerID; + int32_t ofCardID,ofPlayerID,forPlayerID,subsock,pushsock; struct enc_share temp; char str[65],enc_str[177],*buf; bits256 share; uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; struct privatebet_share *share_info=_ptr; cJSON *share_res; + char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet.ipc"; + subsock=BET_nanosock(0,bindaddr,NN_SUB); + pushsock=BET_nanosock(0,bindaddr1,NN_PUSH); + if((subsock>=0)&&(pushsock>=0)){ + printf("\n%s:%d:socket creation is done",__FUNCTION__,__LINE__); + } while(1) { - int bytes = nn_recv (share_info->subsock, &buf, NN_MSG, 0); + int bytes = nn_recv (subsock, &buf, NN_MSG, 0); if(bytes>0) { @@ -465,10 +471,10 @@ void* BET_response(void* _ptr) cJSON_AddNumberToObject(share_res,"forPlayerID",forPlayerID); jaddbits256(share_res,"share",share); } - if(share_info->pushsock>=0){ + if(pushsock>=0){ char *buf=NULL; buf=cJSON_Print(share_res); - int bytes=nn_send(share_info->pushsock,buf,strlen(buf),0); + int bytes=nn_send(pushsock,buf,strlen(buf),0); } } @@ -483,6 +489,8 @@ void* BET_response(void* _ptr) sleep(1); } + nn_shutdown(pushsock,0); + nn_shutdown(subsock,0); } void* BET_receive(void* _ptr) From db270d921ea82f0c632812ff67c8ab72efa88a2c Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 18:46:37 +0530 Subject: [PATCH 35/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 6b01a221dd20..dc48bffb1661 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -446,7 +446,7 @@ void* BET_response(void* _ptr) int bytes = nn_recv (subsock, &buf, NN_MSG, 0); if(bytes>0) { - + printf("\n%s:%d,%s",__FUNCTION__,__LINE__,buf); share_res=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { From d5a266447e560407f3d73cfe7e66c475dc1eb100 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 18:51:55 +0530 Subject: [PATCH 36/94] test --- privatebet/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/client.c b/privatebet/client.c index dc48bffb1661..8f39d8b3696d 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -475,6 +475,7 @@ void* BET_response(void* _ptr) char *buf=NULL; buf=cJSON_Print(share_res); int bytes=nn_send(pushsock,buf,strlen(buf),0); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } From 65534f7db0b81ad5dadb29022e2020428963f231 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:09:09 +0530 Subject: [PATCH 37/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 8f39d8b3696d..d3c8e4e9b979 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -435,7 +435,7 @@ void* BET_response(void* _ptr) uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; struct privatebet_share *share_info=_ptr; cJSON *share_res; - char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet.ipc"; + char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; subsock=BET_nanosock(0,bindaddr,NN_SUB); pushsock=BET_nanosock(0,bindaddr1,NN_PUSH); if((subsock>=0)&&(pushsock>=0)){ From f3181afc2c259f354aa0315917fb38761e8549ea Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:12:26 +0530 Subject: [PATCH 38/94] test --- privatebet/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index d3c8e4e9b979..b6d7fd75fa88 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -446,7 +446,7 @@ void* BET_response(void* _ptr) int bytes = nn_recv (subsock, &buf, NN_MSG, 0); if(bytes>0) { - printf("\n%s:%d,%s",__FUNCTION__,__LINE__,buf); + share_res=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"request_share")) { @@ -475,7 +475,7 @@ void* BET_response(void* _ptr) char *buf=NULL; buf=cJSON_Print(share_res); int bytes=nn_send(pushsock,buf,strlen(buf),0); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + } } From 6f813627d736d8a4866aa70f08c22cb2f9d2c8c5 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:22:06 +0530 Subject: [PATCH 39/94] test --- privatebet/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index b6d7fd75fa88..ff43977c405f 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -453,9 +453,10 @@ void* BET_response(void* _ptr) ofCardID=jint(share_res,"ofCardID"); ofPlayerID=jint(share_res,"ofPlayerID"); forPlayerID=jint(share_res,"forPlayerID"); - + printf("\n%s:%d:player id:%d",__FUNCTION__,__LINE__,share_info->myplayerid); if((ofPlayerID==share_info->myplayerid)&&(forPlayerID!=share_info->myplayerid)) { + printf("\n%s:%d:player id:%d",__FUNCTION__,__LINE__,share_info->myplayerid); temp=g_shares[ofPlayerID*share_info->numplayers*share_info->range + (ofCardID*share_info->numplayers + forPlayerID)]; recvlen = sizeof(temp); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),share_info->bvv_public_key,share_info->player_key.priv,temp.bytes,&recvlen)) == 0 ) From 92134f89c7c920a889ca91957bde308347d35a12 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:26:47 +0530 Subject: [PATCH 40/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index ff43977c405f..462fdbdf19e0 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -453,7 +453,7 @@ void* BET_response(void* _ptr) ofCardID=jint(share_res,"ofCardID"); ofPlayerID=jint(share_res,"ofPlayerID"); forPlayerID=jint(share_res,"forPlayerID"); - printf("\n%s:%d:player id:%d",__FUNCTION__,__LINE__,share_info->myplayerid); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); if((ofPlayerID==share_info->myplayerid)&&(forPlayerID!=share_info->myplayerid)) { printf("\n%s:%d:player id:%d",__FUNCTION__,__LINE__,share_info->myplayerid); From 97bb19a7d9d9be51c5b2375438cf2dad74174012 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:33:01 +0530 Subject: [PATCH 41/94] test --- privatebet/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 462fdbdf19e0..fcfebb144d83 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -695,6 +695,10 @@ void* BET_clientplayer(void * _ptr) for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); + while(1) + { + sleep(5); + } if ( bits256_nonz(decoded256) == 0 ) errs++; else @@ -726,10 +730,10 @@ void* BET_clientplayer(void * _ptr) } } } - else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) + /*else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) { BET_give_share(gameInfo,bet,public_key_b,key); - } + }*/ } } nn_shutdown(bet->pushsock,0); From 5ce0873e4212ba048c6c7966c652e77218cbf488 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:35:40 +0530 Subject: [PATCH 42/94] test --- privatebet/client.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index fcfebb144d83..6b3536f1b8aa 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -695,10 +695,6 @@ void* BET_clientplayer(void * _ptr) for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); - while(1) - { - sleep(5); - } if ( bits256_nonz(decoded256) == 0 ) errs++; else @@ -730,10 +726,11 @@ void* BET_clientplayer(void * _ptr) } } } - /*else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) + else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); BET_give_share(gameInfo,bet,public_key_b,key); - }*/ + } } } nn_shutdown(bet->pushsock,0); From f4be68fe8a96c86da1f44b10307fe6e7d27b0473 Mon Sep 17 00:00:00 2001 From: sg777 Date: Tue, 2 Jan 2018 19:38:35 +0530 Subject: [PATCH 43/94] test --- privatebet/bet.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index b7a8e106660d..2f7b383db003 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -823,22 +823,23 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num share_info->numplayers=bet->numplayers; share_info->pushsock=bet->pushsock; - if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) - { - printf("error launching BET_request thread"); - exit(-1); - } + if ( OS_thread_create(&t_res,NULL,(void *)BET_response,share_info) != 0 ) { printf("error launching BET_response thread"); exit(-1); } + sleep(5); if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive,bet) != 0 ) { printf("error launching BET_receive thread"); exit(-1); } - + if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) + { + printf("error launching BET_request thread"); + exit(-1); + } if(pthread_join(t_req,NULL)) { printf("\nError in joining the main thread for t_req"); From 15205976a782130ad7888654ef3b5c86803d0c9b Mon Sep 17 00:00:00 2001 From: sg777 Date: Wed, 3 Jan 2018 10:24:31 +0530 Subject: [PATCH 44/94] test --- privatebet/bet.c | 6 ++++++ privatebet/client.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 2f7b383db003..92d4fdca8784 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -56,6 +56,10 @@ struct enc_share *g_shares=NULL; bits256 v_hash[CARDS777_MAXCARDS][CARDS777_MAXCARDS]; bits256 g_hash[CARDS777_MAXPLAYERS][CARDS777_MAXCARDS]; + +int32_t sharesflag[CARDS777_MAXCARDS][CARDS777_MAXPLAYERS]; +bits256 playershares[CARDS777_MAXCARDS][CARDS777_MAXPLAYERS]; + uint32_t LP_rand() { uint32_t retval; @@ -852,6 +856,8 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nError in joining the main thread for t_rcv"); } + printf("\n%s:%d",__FUNCTION__,__LINE__); + #if 0 shares=calloc(numplayers,sizeof(uint8_t*)); for(i=0;inumplayers;j++) { - if(j!=bet->myplayerid) - { + sharesflag[i][j]=0; + } + } + + for(int i=0;irange;i++) + { + for(int j=0;jnumplayers;j++) + { + if((j!=bet->myplayerid) && (sharesflag[i][j]==0)) + { shareInfo=cJSON_CreateObject(); cJSON_AddStringToObject(shareInfo,"messageid","request_share"); cJSON_AddNumberToObject(shareInfo,"ofCardID",i); @@ -421,6 +429,8 @@ void* BET_request(void* _ptr) printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareInfo); } + else if((j==bet->myplayerid) && (sharesflag[i][j]==0)) + sharesflag[i][j]==1; } } } @@ -441,8 +451,10 @@ void* BET_response(void* _ptr) if((subsock>=0)&&(pushsock>=0)){ printf("\n%s:%d:socket creation is done",__FUNCTION__,__LINE__); } - while(1) + int flag=1; + while(flag) { + flag=0; int bytes = nn_recv (subsock, &buf, NN_MSG, 0); if(bytes>0) { @@ -483,11 +495,28 @@ void* BET_response(void* _ptr) } else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"receive_share")) { + ofCardID=jint(share_res,"ofCardID"); + ofPlayerID=jint(share_res,"ofPlayerID"); + sharesflag[ofCardID][ofPlayerID]=1; + playershares=jbits256(share_res,"share"); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } - + for(int i=0;irange;i++) + { + for(int j=0;jnumplayers;j++) + { + if(sharesflag[i][j]==0) + { + flag=1; + break; + } + + } + if(flag) + break; + } sleep(1); } From 210bd479b8a9a064d20c288f7b63784ac4ba8119 Mon Sep 17 00:00:00 2001 From: sg777 Date: Wed, 3 Jan 2018 10:25:52 +0530 Subject: [PATCH 45/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 5ee6bfb6f3b1..1580e9b2b1b0 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -498,7 +498,7 @@ void* BET_response(void* _ptr) ofCardID=jint(share_res,"ofCardID"); ofPlayerID=jint(share_res,"ofPlayerID"); sharesflag[ofCardID][ofPlayerID]=1; - playershares=jbits256(share_res,"share"); + playershares[ofCardID][ofPlayerID]=jbits256(share_res,"share"); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } From d72139ef064c245dad3cf0ad3c22dd39fc4dd7d1 Mon Sep 17 00:00:00 2001 From: sg777 Date: Wed, 3 Jan 2018 11:06:48 +0530 Subject: [PATCH 46/94] test --- privatebet/bet.c | 12 ++++++++++++ privatebet/client.c | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 92d4fdca8784..e610859a442c 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -848,14 +848,26 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nError in joining the main thread for t_req"); } + else + { + printf("\nRequest thread is finished"); + } if(pthread_join(t_res,NULL)) { printf("\nError in joining the main thread for t_res"); } + else + { + printf("\nResponse thread is finished"); + } if(pthread_join(t_rcv,NULL)) { printf("\nError in joining the main thread for t_rcv"); } + else + { + printf("\nResponse thread is finished"); + } printf("\n%s:%d",__FUNCTION__,__LINE__); #if 0 diff --git a/privatebet/client.c b/privatebet/client.c index 1580e9b2b1b0..411f19f3b5d0 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -433,6 +433,7 @@ void* BET_request(void* _ptr) sharesflag[i][j]==1; } } + } void* BET_response(void* _ptr) @@ -503,7 +504,7 @@ void* BET_response(void* _ptr) } } - for(int i=0;irange;i++) + /*for(int i=0;irange;i++) { for(int j=0;jnumplayers;j++) { @@ -516,7 +517,7 @@ void* BET_response(void* _ptr) } if(flag) break; - } + }*/ sleep(1); } From cd0571ad11f743d091e908b9a2a55ddc1041ff21 Mon Sep 17 00:00:00 2001 From: sg777 Date: Wed, 3 Jan 2018 11:29:54 +0530 Subject: [PATCH 47/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 411f19f3b5d0..9d41013536fd 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -453,7 +453,7 @@ void* BET_response(void* _ptr) printf("\n%s:%d:socket creation is done",__FUNCTION__,__LINE__); } int flag=1; - while(flag) + while(1) { flag=0; int bytes = nn_recv (subsock, &buf, NN_MSG, 0); From 6ad0d2865d1c5c6e8af546578bec9930ec72af14 Mon Sep 17 00:00:00 2001 From: sg777 Date: Wed, 3 Jan 2018 11:44:15 +0530 Subject: [PATCH 48/94] test --- privatebet/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 9d41013536fd..8d9ebdd35d11 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -504,7 +504,7 @@ void* BET_response(void* _ptr) } } - /*for(int i=0;irange;i++) + for(int i=0;irange;i++) { for(int j=0;jnumplayers;j++) { @@ -517,7 +517,7 @@ void* BET_response(void* _ptr) } if(flag) break; - }*/ + } sleep(1); } From 04399deb2476e14c94a64d8766c6d4121f05f1ab Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 06:06:54 +0530 Subject: [PATCH 49/94] test --- privatebet/bet.c | 11 ++++++----- privatebet/client.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index e610859a442c..3a50d0108eeb 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -852,22 +852,23 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nRequest thread is finished"); } - if(pthread_join(t_res,NULL)) + if(pthread_join(t_rcv,NULL)) { - printf("\nError in joining the main thread for t_res"); + printf("\nError in joining the main thread for t_rcv"); } else { - printf("\nResponse thread is finished"); + printf("\nReceive thread is finished"); } - if(pthread_join(t_rcv,NULL)) + if(pthread_join(t_res,NULL)) { - printf("\nError in joining the main thread for t_rcv"); + printf("\nError in joining the main thread for t_res"); } else { printf("\nResponse thread is finished"); } + printf("\n%s:%d",__FUNCTION__,__LINE__); #if 0 diff --git a/privatebet/client.c b/privatebet/client.c index 8d9ebdd35d11..7c526766128f 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -453,7 +453,7 @@ void* BET_response(void* _ptr) printf("\n%s:%d:socket creation is done",__FUNCTION__,__LINE__); } int flag=1; - while(1) + while(flag) { flag=0; int bytes = nn_recv (subsock, &buf, NN_MSG, 0); From ce0d1b36e082ddc4160453101ea8a1094e0f0d9b Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 06:10:27 +0530 Subject: [PATCH 50/94] test --- privatebet/bet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 3a50d0108eeb..9ad273f8e3d9 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -937,7 +937,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } } } - #endif + end: for(i=0;i Date: Thu, 4 Jan 2018 06:15:42 +0530 Subject: [PATCH 51/94] test --- privatebet/bet.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 9ad273f8e3d9..de3918aac491 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -870,6 +870,16 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } printf("\n%s:%d",__FUNCTION__,__LINE__); + + for(int i=0;irange;i++) + { + printf("\ncard:%d",i); + for(int j=0;jnumplayers;j++) + { + printf("\nshare:%s",bits256_str(str,playershares[i][j])); + } + } + #if 0 shares=calloc(numplayers,sizeof(uint8_t*)); From cabc7ece2041d5dd640a36b5255896caae5f76d5 Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 06:23:03 +0530 Subject: [PATCH 52/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 7c526766128f..484e3e5b139e 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -722,7 +722,7 @@ void* BET_clientplayer(void * _ptr) vcalc_sha256(0,v_hash[i][j].bytes,temp.bytes,sizeof(temp)); } } - for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); if ( bits256_nonz(decoded256) == 0 ) From da60b7939bfa40d213ad33fb2908fa3dc8759c7b Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 06:33:04 +0530 Subject: [PATCH 53/94] test --- privatebet/bet.c | 2 +- privatebet/client.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index de3918aac491..1d8c37b68dc9 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -880,7 +880,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } } - + #if 0 shares=calloc(numplayers,sizeof(uint8_t*)); for(i=0;imyplayerid==forPlayerID) + { + sharesflag[ofCardID][ofPlayerID]=1; + playershares[ofCardID][ofPlayerID]=jbits256(share_res,"share"); + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + } } } From 7bc3dbaced0200a73a3976c01536e21ab9ea9d7c Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 06:36:43 +0530 Subject: [PATCH 54/94] test --- privatebet/bet.c | 2 +- privatebet/client.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 1d8c37b68dc9..e49215adc99e 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -880,7 +880,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } } - + printf("\nDone"); #if 0 shares=calloc(numplayers,sizeof(uint8_t*)); for(i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); - if ( bits256_nonz(decoded256) == 0 ) + while(1){sleep(5)}; + if ( bits256_nonz(decoded256) == 0 ) errs++; else { From 91b13105fda090c185875a9bc8f9af409397645d Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 16:37:41 +0530 Subject: [PATCH 55/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 8e6d2401f1b3..079b17713197 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -729,7 +729,7 @@ void* BET_clientplayer(void * _ptr) for(int i=0;i<1/*numcards*/;i++) { decoded256 = t_sg777_player_decode(bet,i,numplayers,key,public_key_b,blindedcards[bet->myplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); - while(1){sleep(5)}; + while(1){sleep(5);}; if ( bits256_nonz(decoded256) == 0 ) errs++; else From 099ee9d558884f33f5109a53db3f5e0b0e0891a5 Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 4 Jan 2018 16:39:16 +0530 Subject: [PATCH 56/94] test --- privatebet/client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 079b17713197..4566b5d38cd4 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -729,7 +729,9 @@ void* BET_clientplayer(void * _ptr) for(int i=0;i<1/*numcards*/;i++) { decoded256 = t_sg777_player_decode(bet,i,numplayers,key,public_key_b,blindedcards[bet->myplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); - while(1){sleep(5);}; + while(1){ + sleep(5); + } if ( bits256_nonz(decoded256) == 0 ) errs++; else From 4e5f7b1d2c510bf68ab4c37fdd63ef5d33302778 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 07:58:04 +0530 Subject: [PATCH 57/94] test --- privatebet/client.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 4566b5d38cd4..fc57c5a3f049 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -522,7 +522,16 @@ void* BET_response(void* _ptr) if(flag) break; } - sleep(1); + for(int i=0;irange;i++) + { + printf("\n"); + for(int j=0;jnumplayers;j++) + { + printf("%d ",sharesflag[i][j]); + } + + } + sleep(5); } nn_shutdown(pushsock,0); From 1221ada32801bbd4e84af87d4abab3ce6792624a Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 08:14:36 +0530 Subject: [PATCH 58/94] test --- privatebet/client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index fc57c5a3f049..e8b3d60097f9 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -429,8 +429,10 @@ void* BET_request(void* _ptr) printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareInfo); } - else if((j==bet->myplayerid) && (sharesflag[i][j]==0)) + else if((j==bet->myplayerid) && (sharesflag[i][j]==0)) { sharesflag[i][j]==1; + printf("\n%d %d ::%d",i,j,sharesflag[i][j]); + } } } From 1f0556785ef1e58793249ee759f480ca6273d99f Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 08:20:34 +0530 Subject: [PATCH 59/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index e8b3d60097f9..f17e0fab6729 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -430,7 +430,7 @@ void* BET_request(void* _ptr) cJSON_Delete(shareInfo); } else if((j==bet->myplayerid) && (sharesflag[i][j]==0)) { - sharesflag[i][j]==1; + sharesflag[i][j]=1; printf("\n%d %d ::%d",i,j,sharesflag[i][j]); } } From 1dc605cf289301d0c0512035bf3c968213c28558 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 08:38:45 +0530 Subject: [PATCH 60/94] test --- privatebet/bet.c | 2 +- privatebet/client.c | 59 +++++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index e49215adc99e..bc69a0532e3e 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -839,7 +839,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num printf("error launching BET_receive thread"); exit(-1); } - if ( OS_thread_create(&t_req,NULL,(void *)BET_request,bet) != 0 ) + if ( OS_thread_create(&t_req,NULL,(void *)BET_request,share_info) != 0 ) { printf("error launching BET_request thread"); exit(-1); diff --git a/privatebet/client.c b/privatebet/client.c index f17e0fab6729..ceff1e7dd7a4 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -398,40 +398,56 @@ char *enc_share_str(char hexstr[177],struct enc_share x) void* BET_request(void* _ptr) { - char bindaddr[128]="ipc:///tmp/bet.ipc"; - struct privatebet_info *bet = _ptr; - - cJSON *shareInfo=NULL; + struct enc_share temp; + bits256 share; + uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; + struct privatebet_share *shareInfo=_ptr; + int32_t ofCardID,ofPlayerID,forPlayerID; + cJSON *shareReq=NULL; char *buf=NULL,str[65]; int bytes; - for(int i=0;irange;i++) + for(int i=0;irange;i++) { - for(int j=0;jnumplayers;j++) + for(int j=0;jnumplayers;j++) { sharesflag[i][j]=0; } } - for(int i=0;irange;i++) + for(int i=0;irange;i++) { - for(int j=0;jnumplayers;j++) + for(int j=0;jnumplayers;j++) { - if((j!=bet->myplayerid) && (sharesflag[i][j]==0)) + if((j!=shareInfo->myplayerid) && (sharesflag[i][j]==0)) { shareInfo=cJSON_CreateObject(); - cJSON_AddStringToObject(shareInfo,"messageid","request_share"); - cJSON_AddNumberToObject(shareInfo,"ofCardID",i); - cJSON_AddNumberToObject(shareInfo,"ofPlayerID",j); - cJSON_AddNumberToObject(shareInfo,"forPlayerID",bet->myplayerid); - buf=cJSON_Print(shareInfo); + cJSON_AddStringToObject(shareReq,"messageid","request_share"); + cJSON_AddNumberToObject(shareReq,"ofCardID",i); + cJSON_AddNumberToObject(shareReq,"ofPlayerID",j); + cJSON_AddNumberToObject(shareReq,"forPlayerID",shareInfo->myplayerid); + buf=cJSON_Print(shareReq); bytes=nn_send(bet->pushsock,buf,strlen(buf),0); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); - cJSON_Delete(shareInfo); + cJSON_Delete(shareReq); } - else if((j==bet->myplayerid) && (sharesflag[i][j]==0)) { + else if((j==shareInfo->myplayerid) && (sharesflag[i][j]==0)) { sharesflag[i][j]=1; - printf("\n%d %d ::%d",i,j,sharesflag[i][j]); + ofCardID=jint(shareInfo,"ofCardID"); + ofPlayerID=jint(shareInfo,"ofPlayerID"); + forPlayerID=jint(shareInfo,"forPlayerID"); + temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; + recvlen = sizeof(temp); + + if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) + printf("decrypt error "); + else + { + memcpy(share.bytes,ptr,recvlen); + playershares[i][j]=share; + } + + } } } @@ -524,15 +540,6 @@ void* BET_response(void* _ptr) if(flag) break; } - for(int i=0;irange;i++) - { - printf("\n"); - for(int j=0;jnumplayers;j++) - { - printf("%d ",sharesflag[i][j]); - } - - } sleep(5); } From b49750402084f45d647e1872c7719b10ad8244f8 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 08:41:27 +0530 Subject: [PATCH 61/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index ceff1e7dd7a4..2c48c1fe1e60 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -427,7 +427,7 @@ void* BET_request(void* _ptr) cJSON_AddNumberToObject(shareReq,"ofPlayerID",j); cJSON_AddNumberToObject(shareReq,"forPlayerID",shareInfo->myplayerid); buf=cJSON_Print(shareReq); - bytes=nn_send(bet->pushsock,buf,strlen(buf),0); + bytes=nn_send(shareInfo->pushsock,buf,strlen(buf),0); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareReq); } From 9ca497522c8fa66ae5abe2872d2503c4eadbd223 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 08:46:40 +0530 Subject: [PATCH 62/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 2c48c1fe1e60..cffa4fe00045 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -421,7 +421,7 @@ void* BET_request(void* _ptr) { if((j!=shareInfo->myplayerid) && (sharesflag[i][j]==0)) { - shareInfo=cJSON_CreateObject(); + shareReq=cJSON_CreateObject(); cJSON_AddStringToObject(shareReq,"messageid","request_share"); cJSON_AddNumberToObject(shareReq,"ofCardID",i); cJSON_AddNumberToObject(shareReq,"ofPlayerID",j); From 980031045ccf8fe1132f3f8c6f23b33cbd269c45 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 09:32:17 +0530 Subject: [PATCH 63/94] test --- privatebet/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index cffa4fe00045..7515825680dd 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -436,7 +436,8 @@ void* BET_request(void* _ptr) ofCardID=jint(shareInfo,"ofCardID"); ofPlayerID=jint(shareInfo,"ofPlayerID"); forPlayerID=jint(shareInfo,"forPlayerID"); - temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; + //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; + temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID)]; recvlen = sizeof(temp); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) From 56d32ae28205dbb876bfe40d3fd39e588cb029b5 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 09:39:26 +0530 Subject: [PATCH 64/94] test --- privatebet/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 7515825680dd..999874d6c98f 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -432,7 +432,6 @@ void* BET_request(void* _ptr) cJSON_Delete(shareReq); } else if((j==shareInfo->myplayerid) && (sharesflag[i][j]==0)) { - sharesflag[i][j]=1; ofCardID=jint(shareInfo,"ofCardID"); ofPlayerID=jint(shareInfo,"ofPlayerID"); forPlayerID=jint(shareInfo,"forPlayerID"); @@ -444,8 +443,10 @@ void* BET_request(void* _ptr) printf("decrypt error "); else { + printf("\n%s:%d",__FUNCTION__,__LINE__); memcpy(share.bytes,ptr,recvlen); playershares[i][j]=share; + sharesflag[i][j]=1; } From 0368aa54cda58045c4172605642ff702e1227ee8 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 09:49:38 +0530 Subject: [PATCH 65/94] test --- privatebet/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 999874d6c98f..b45af21fa61e 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -404,7 +404,7 @@ void* BET_request(void* _ptr) struct privatebet_share *shareInfo=_ptr; int32_t ofCardID,ofPlayerID,forPlayerID; cJSON *shareReq=NULL; - char *buf=NULL,str[65]; + char *buf=NULL,str[65],enc_str[177]; int bytes; for(int i=0;irange;i++) @@ -438,7 +438,7 @@ void* BET_request(void* _ptr) //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID)]; recvlen = sizeof(temp); - + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,enc_share_str(enc_str,temp)); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) printf("decrypt error "); else From 2be9e402b1cf9d952e726a4a7cc1b2314d58b12e Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 09:55:24 +0530 Subject: [PATCH 66/94] test --- privatebet/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/privatebet/client.c b/privatebet/client.c index b45af21fa61e..e4b200c71a8b 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -438,6 +438,7 @@ void* BET_request(void* _ptr) //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID)]; recvlen = sizeof(temp); + printf("\n%d",(ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID))); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,enc_share_str(enc_str,temp)); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) printf("decrypt error "); From c665fefa891d3176a7b46900dedcdbce60f3fc77 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 10:05:46 +0530 Subject: [PATCH 67/94] test --- privatebet/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index e4b200c71a8b..926b536e125d 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -436,9 +436,9 @@ void* BET_request(void* _ptr) ofPlayerID=jint(shareInfo,"ofPlayerID"); forPlayerID=jint(shareInfo,"forPlayerID"); //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; - temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID)]; + temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + j)]; recvlen = sizeof(temp); - printf("\n%d",(ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + forPlayerID))); + printf("\n%d ",(ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + j))); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,enc_share_str(enc_str,temp)); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) printf("decrypt error "); From 1e5e335f82efab99094568f1b1a506d1a80dc77d Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 11:14:16 +0530 Subject: [PATCH 68/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 926b536e125d..9a63e9275a55 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -436,7 +436,7 @@ void* BET_request(void* _ptr) ofPlayerID=jint(shareInfo,"ofPlayerID"); forPlayerID=jint(shareInfo,"forPlayerID"); //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; - temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + j)]; + temp=g_shares[shareInfo->myplayerid*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + shareInfo->myplayerid)]; recvlen = sizeof(temp); printf("\n%d ",(ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + j))); printf("\n%s:%d:%s",__FUNCTION__,__LINE__,enc_share_str(enc_str,temp)); From 328620b1b281bb0c3386529cbf318661c2edff21 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 11:30:59 +0530 Subject: [PATCH 69/94] test --- privatebet/bet.c | 98 ++++++++++++++++++++++++++++++++++++++------- privatebet/client.c | 27 ------------- 2 files changed, 84 insertions(+), 41 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index bc69a0532e3e..0c4bc3bd1683 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -834,11 +834,6 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num exit(-1); } sleep(5); - if ( OS_thread_create(&t_rcv,NULL,(void *)BET_receive,bet) != 0 ) - { - printf("error launching BET_receive thread"); - exit(-1); - } if ( OS_thread_create(&t_req,NULL,(void *)BET_request,share_info) != 0 ) { printf("error launching BET_request thread"); @@ -852,14 +847,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nRequest thread is finished"); } - if(pthread_join(t_rcv,NULL)) - { - printf("\nError in joining the main thread for t_rcv"); - } - else - { - printf("\nReceive thread is finished"); - } + if(pthread_join(t_res,NULL)) { printf("\nError in joining the main thread for t_res"); @@ -880,7 +868,89 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } } - printf("\nDone"); + + #if 1 + shares=calloc(numplayers,sizeof(uint8_t*)); + for(i=0;irange;k++) + { + for(i=0;imyplayerid; + + for (i=0; imyplayerid); buf=cJSON_Print(shareReq); bytes=nn_send(shareInfo->pushsock,buf,strlen(buf),0); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); cJSON_Delete(shareReq); } else if((j==shareInfo->myplayerid) && (sharesflag[i][j]==0)) { @@ -438,13 +437,10 @@ void* BET_request(void* _ptr) //temp=g_shares[ofPlayerID*shareInfo->numplayers*shareInfo->range + (ofCardID*shareInfo->numplayers + forPlayerID)]; temp=g_shares[shareInfo->myplayerid*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + shareInfo->myplayerid)]; recvlen = sizeof(temp); - printf("\n%d ",(ofPlayerID*shareInfo->numplayers*shareInfo->range + (i*shareInfo->numplayers + j))); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,enc_share_str(enc_str,temp)); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),shareInfo->bvv_public_key,shareInfo->player_key.priv,temp.bytes,&recvlen)) == 0 ) printf("decrypt error "); else { - printf("\n%s:%d",__FUNCTION__,__LINE__); memcpy(share.bytes,ptr,recvlen); playershares[i][j]=share; sharesflag[i][j]=1; @@ -524,7 +520,6 @@ void* BET_response(void* _ptr) { sharesflag[ofCardID][ofPlayerID]=1; playershares[ofCardID][ofPlayerID]=jbits256(share_res,"share"); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); } } @@ -550,28 +545,6 @@ void* BET_response(void* _ptr) nn_shutdown(subsock,0); } -void* BET_receive(void* _ptr) -{ - char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; - char *buf = NULL; - struct privatebet_info *bet = _ptr; - cJSON *share_rcv; - while(0) - { - int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); - if(bytes>0) - { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); - share_rcv=cJSON_Parse(buf); - if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_rcv,"messageid")),"receive_share")) - { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); - } - } - sleep(1); - } -} - bits256 BET_request_share(int32_t ofCardID,int32_t ofPlayerID,struct privatebet_info *bet,bits256 bvv_public_key,struct pair256 player_key) { From c0f7d9ca43dc1f21fd7da4db34edd14f7becd72f Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 11:39:01 +0530 Subject: [PATCH 70/94] test --- privatebet/bet.c | 91 +++--------------------------------------------- 1 file changed, 5 insertions(+), 86 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 0c4bc3bd1683..73374c4a6ebf 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -869,96 +869,15 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } - #if 1 - shares=calloc(numplayers,sizeof(uint8_t*)); - for(i=0;irange;k++) - { - for(i=0;imyplayerid; - - for (i=0; imyplayerid){ tmp=BET_request_share(cardID,i,bet,public_key_b,key); } @@ -978,11 +897,11 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num for(i=0;i Date: Fri, 5 Jan 2018 11:44:30 +0530 Subject: [PATCH 71/94] test --- privatebet/bet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 73374c4a6ebf..19daf9b13d5f 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -902,6 +902,11 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num for(i=0;i Date: Fri, 5 Jan 2018 11:47:00 +0530 Subject: [PATCH 72/94] test --- privatebet/bet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 19daf9b13d5f..dcde420d3a58 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -902,7 +902,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num for(i=0;i Date: Fri, 5 Jan 2018 11:58:32 +0530 Subject: [PATCH 73/94] test --- privatebet/bet.c | 10 ++++++++-- privatebet/client.c | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index dcde420d3a58..3638cf38f5b0 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -59,7 +59,7 @@ bits256 g_hash[CARDS777_MAXPLAYERS][CARDS777_MAXCARDS]; int32_t sharesflag[CARDS777_MAXCARDS][CARDS777_MAXPLAYERS]; bits256 playershares[CARDS777_MAXCARDS][CARDS777_MAXPLAYERS]; - +bits256 deckid; uint32_t LP_rand() { uint32_t retval; @@ -904,10 +904,13 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num memcpy(shares[i],playershares[cardID][i].bytes,sizeof(bits256)); printf("\n%s",bits256_str(str,playershares[cardID][i])); } + gfshare_calc_sharenrs(sharenrs,numplayers,deckid.bytes,sizeof(deckid)); // same for all players for this round + printf("\nsharenrs values are:\n"); for(i=0;i Date: Fri, 5 Jan 2018 12:07:24 +0530 Subject: [PATCH 74/94] test --- privatebet/bet.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 3638cf38f5b0..141ef8e4a8be 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -876,40 +876,13 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num basepoint = curve25519_basepoint9(); uint8_t decipher[sizeof(bits256) + 1024],*ptr; int32_t recvlen; - - /*for(i=0;imyplayerid){ - tmp=BET_request_share(cardID,i,bet,public_key_b,key); - } - else{ - temp=g_shares[bet->myplayerid*bet->numplayers*bet->range + (cardID*bet->numplayers + bet->myplayerid)]; - recvlen = sizeof(temp); - if ( (ptr= BET_decrypt(decipher,sizeof(decipher),public_key_b,key.priv,temp.bytes,&recvlen)) == 0 ) - printf("decrypt error "); - else - { - memcpy(tmp.bytes,ptr,recvlen); - } - } - memcpy(cardshares[i].bytes,tmp.bytes,sizeof(bits256)); - } - printf("\nThe shares are:\n"); - for(i=0;i Date: Fri, 5 Jan 2018 15:05:23 +0530 Subject: [PATCH 75/94] test --- privatebet/bet.c | 1 + privatebet/client.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 141ef8e4a8be..1a0628565034 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -887,6 +887,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num gfshare_recoverdata(shares,sharenrs, M,recover.bytes,sizeof(bits256),M); refval = fmul_donna(blindedcard,crecip_donna(recover)); printf("\n%s:%d:cardID:%d, Blinding Value:%s", __FUNCTION__,__LINE__,cardID,bits256_str(str,recover)); + printf("\nFinal card:%s",bits256_str(str,refval)); for(i=0;i Date: Fri, 5 Jan 2018 15:08:03 +0530 Subject: [PATCH 76/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index cf8332819565..a30fac23ca27 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -827,8 +827,8 @@ void* BET_clientbvv(void * _ptr) printf("\nplayerID: %d",playerID); for(int i=0;i Date: Fri, 5 Jan 2018 15:08:44 +0530 Subject: [PATCH 77/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index a30fac23ca27..4be3f4ab3a4e 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -828,7 +828,7 @@ void* BET_clientbvv(void * _ptr) for(int i=0;i Date: Fri, 5 Jan 2018 15:18:53 +0530 Subject: [PATCH 78/94] test --- privatebet/bet.c | 15 +++++++++++++++ privatebet/client.c | 1 + 2 files changed, 16 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 1a0628565034..29560d307fc1 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -896,6 +896,21 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num vcalc_sha256(0,v_hash[i][j].bytes,temp.bytes,sizeof(temp)); } } + printf("\nv_hash is:\n"); + for(int i=0;imyplayerid; for (i=0; imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); From 4af028d28490fb1e4710abfbe23e075274dcf15e Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 20:25:11 +0530 Subject: [PATCH 79/94] test --- privatebet/bet.c | 1 + privatebet/client.c | 1 + 2 files changed, 2 insertions(+) diff --git a/privatebet/bet.c b/privatebet/bet.c index 29560d307fc1..1ba5d8fbdac5 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -918,6 +918,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { if ( bits256_cmp(v_hash[i][j],g_hash[playerid][cardID]) == 0 ) { + printf("\n%s:%d",__FUNCTION__,__LINE__); tmp = curve25519(key.priv,curve25519(playerprivs[i],cardprods[j])); xoverz = xoverz_donna(tmp); vcalc_sha256(0,hash.bytes,xoverz.bytes,sizeof(xoverz)); diff --git a/privatebet/client.c b/privatebet/client.c index ac08edc82ad2..1254a7e7f38f 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -751,6 +751,7 @@ void* BET_clientplayer(void * _ptr) { deckid=jbits256(gameInfo,"deckid"); cjsoncardprods=cJSON_GetObjectItem(gameInfo,"cardprods"); + for(int i=0;i Date: Fri, 5 Jan 2018 21:10:28 +0530 Subject: [PATCH 80/94] test --- privatebet/bet.c | 4 ++-- privatebet/client.c | 14 +++++++++++++- privatebet/host.c | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 1ba5d8fbdac5..b92baef441c9 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -899,14 +899,14 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num printf("\nv_hash is:\n"); for(int i=0;inumplayers; numcards=bet->range; @@ -759,6 +759,18 @@ void* BET_clientplayer(void * _ptr) cardprods[i][j]=jbits256i(cjsoncardprods,i*numcards+j); } } + + + cjsong_hash=cJSON_GetObjectItem(gameInfo,"g_hash"); + + for(int i=0;irange; @@ -405,7 +405,17 @@ void* BET_hostdcv(void * _ptr) { cJSON_AddItemToArray(cjsonfinalcards,cJSON_CreateString(bits256_str(str,finalcards[i][j]))); } - } + } + + cJSON_AddItemToObject(gameInfo,"g_hash",cjsong_hash=cJSON_CreateArray()); + for(int i=0;ipubsock,rendered,strlen(rendered),0); while(1) From 367ddec6a095a0cab48e3dc99c8231640cd5b5d1 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 21:13:20 +0530 Subject: [PATCH 81/94] test --- privatebet/bet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index b92baef441c9..a45b065c28b0 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -906,7 +906,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num printf("\ng_hash is:\n"); for(int i=0;i Date: Fri, 5 Jan 2018 21:15:27 +0530 Subject: [PATCH 82/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index 7a188576f88a..732c2c37d137 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -721,7 +721,7 @@ void* BET_clientplayer(void * _ptr) } } - for(int i=0;i<1/*numcards*/;i++) + for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); while(1){ From 7017661007766abbc08762dbf57bda4c02986f98 Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 21:23:02 +0530 Subject: [PATCH 83/94] test --- privatebet/client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 732c2c37d137..f8c5ac996623 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -724,9 +724,7 @@ void* BET_clientplayer(void * _ptr) for(int i=0;imyplayerid][i],cardprods[bet->myplayerid],playerprivs,numcards); - while(1){ - sleep(5); - } + if ( bits256_nonz(decoded256) == 0 ) errs++; else From 9484e83eef0c532f3513098fad21345060a9d8fe Mon Sep 17 00:00:00 2001 From: sg777 Date: Fri, 5 Jan 2018 21:28:26 +0530 Subject: [PATCH 84/94] test --- privatebet/client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/privatebet/client.c b/privatebet/client.c index f8c5ac996623..6fd0aae4087c 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -742,6 +742,10 @@ void* BET_clientplayer(void * _ptr) decoded[i] = k; } } + while(1) + { + sleep(5); + } decodebad += errs; decodegood+= (numcards - errs); } From b3b3c37056cee679c53b50f7211f809e0b07db98 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 05:12:54 +0530 Subject: [PATCH 85/94] test --- sh.exe.stackdump | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 sh.exe.stackdump diff --git a/sh.exe.stackdump b/sh.exe.stackdump new file mode 100644 index 000000000000..5bcd3c242cb1 --- /dev/null +++ b/sh.exe.stackdump @@ -0,0 +1,11 @@ +Stack trace: +Frame Function Args +00180309488 0018005CCCE (0018022C830, 0018021EC39, 00180309488, 000FFFFBA00) +00180309488 00180046419 (00000000002, 00000000003, 00000000002, 000C0000000) +00180309488 00180046452 (00000000002, 00180309798, 00180309488, 00000000008) +00180309488 00180057285 (00000000000, 000FFFFCC18, 000FFFFCC63, 0060003ACC8) +000FFFFCCC0 00180057330 (645C655C725C635C, 695C745C6E5C655C, 6D5C2D5C6C5C615C, 675C615C6E5C615C) +000FFFFCCC0 00180046BD7 (00000000000, 00000000000, 00000000000, 00000000000) +00000000000 001800456B3 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180045764 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace From 02caabcbae7ca63082982c743508241d1ec4cf77 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 07:42:33 +0530 Subject: [PATCH 86/94] test --- privatebet/bet.c | 3 ++- privatebet/client.c | 15 ++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index a45b065c28b0..049893a3b1d7 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -910,8 +910,9 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num } } - playerid=bet->myplayerid; + printf("\n%s:%d:playerid:%d,cardid:%d",__FUNCTION__,__LINE__,playerid,cardID); + for (i=0; imyplayerid)&&(forPlayerID!=share_info->myplayerid)) { - printf("\n%s:%d:player id:%d",__FUNCTION__,__LINE__,share_info->myplayerid); temp=g_shares[ofPlayerID*share_info->numplayers*share_info->range + (ofCardID*share_info->numplayers + forPlayerID)]; recvlen = sizeof(temp); if ( (ptr= BET_decrypt(decipher,sizeof(decipher),share_info->bvv_public_key,share_info->player_key.priv,temp.bytes,&recvlen)) == 0 ) @@ -506,11 +504,9 @@ void* BET_response(void* _ptr) char *buf=NULL; buf=cJSON_Print(share_res); int bytes=nn_send(pushsock,buf,strlen(buf),0); - } } - - } + } else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(share_res,"messageid")),"receive_share")) { ofCardID=jint(share_res,"ofCardID"); @@ -522,7 +518,6 @@ void* BET_response(void* _ptr) playershares[ofCardID][ofPlayerID]=jbits256(share_res,"share"); } } - } for(int i=0;irange;i++) { @@ -533,13 +528,11 @@ void* BET_response(void* _ptr) flag=1; break; } - } if(flag) break; } sleep(5); - } nn_shutdown(pushsock,0); nn_shutdown(subsock,0); @@ -742,11 +735,7 @@ void* BET_clientplayer(void * _ptr) decoded[i] = k; } } - while(1) - { - sleep(5); - } - decodebad += errs; + decodebad += errs; decodegood+= (numcards - errs); } else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init_d")) From 81bc843885abd7246b32be684eb51e48a8b49ce9 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 07:47:52 +0530 Subject: [PATCH 87/94] test --- privatebet/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 8aa1ce02d589..a7127fd1237c 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -763,11 +763,12 @@ void* BET_clientplayer(void * _ptr) } } + /* else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + BET_give_share(gameInfo,bet,public_key_b,key); - } + }*/ } } nn_shutdown(bet->pushsock,0); From 97196eb1fbb7dae583b9b90411382dff2e4ef203 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 07:56:25 +0530 Subject: [PATCH 88/94] test --- privatebet/client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index a7127fd1237c..e9c039ea3a18 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -676,10 +676,11 @@ void* BET_clientplayer(void * _ptr) int bytes = nn_recv (bet->subsock, &buf, NN_MSG, 0); if(bytes>0) { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"decode")) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); public_key_b=jbits256(gameInfo,"public_key_b"); g_shares=(struct enc_share*)malloc(CARDS777_MAXPLAYERS*CARDS777_MAXPLAYERS*CARDS777_MAXCARDS*sizeof(struct enc_share)); cjsonblindedcards=cJSON_GetObjectItem(gameInfo,"blindedcards"); @@ -740,6 +741,7 @@ void* BET_clientplayer(void * _ptr) } else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init_d")) { + printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); deckid=jbits256(gameInfo,"deckid"); cjsoncardprods=cJSON_GetObjectItem(gameInfo,"cardprods"); From b15f6869733fa4d0d07936bd6a74b332f184d795 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:07:15 +0530 Subject: [PATCH 89/94] test --- privatebet/bet.c | 22 ++-------------------- privatebet/client.c | 5 ----- privatebet/host.c | 2 +- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index 049893a3b1d7..c4d2dfc123a0 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -886,8 +886,7 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num gfshare_recoverdata(shares,sharenrs, M,recover.bytes,sizeof(bits256),M); refval = fmul_donna(blindedcard,crecip_donna(recover)); - printf("\n%s:%d:cardID:%d, Blinding Value:%s", __FUNCTION__,__LINE__,cardID,bits256_str(str,recover)); - printf("\nFinal card:%s",bits256_str(str,refval)); + for(i=0;imyplayerid; - printf("\n%s:%d:playerid:%d,cardid:%d",__FUNCTION__,__LINE__,playerid,cardID); - + for (i=0; isubsock, &buf, NN_MSG, 0); if(bytes>0) { - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); gameInfo=cJSON_Parse(buf); if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init_d")) { deckid=jbits256(gameInfo,"deckid"); cjsonfinalcards=cJSON_GetObjectItem(gameInfo,"finalcards"); - printf("\ncards received to bvv from dcv"); for(int playerID=0;playerID0) { bytes=nn_send(bet->pubsock,buf,strlen(buf),0); - printf("\n%s:%d:%s",__FUNCTION__,__LINE__,buf); + } } nn_shutdown(bet->pullsock,0); From b3d9fa6faf576d818f61d417e1ccc7dbacb808b2 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:11:39 +0530 Subject: [PATCH 90/94] test --- privatebet/client.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 537860b228fd..6e750d31d43c 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -466,9 +466,7 @@ void* BET_response(void* _ptr) char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; subsock=BET_nanosock(0,bindaddr,NN_SUB); pushsock=BET_nanosock(0,bindaddr1,NN_PUSH); - if((subsock>=0)&&(pushsock>=0)){ - printf("\n%s:%d:socket creation is done",__FUNCTION__,__LINE__); - } + int flag=1; while(flag) { @@ -736,6 +734,7 @@ void* BET_clientplayer(void * _ptr) decoded[i] = k; } } + printf("\nCards Decoded:%d, errored:%d",decoded,errs); decodebad += errs; decodegood+= (numcards - errs); } From 5d4bc84febae2016c6c04615f63f716e0b4c1214 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:12:57 +0530 Subject: [PATCH 91/94] test --- privatebet/bet.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/privatebet/bet.c b/privatebet/bet.c index c4d2dfc123a0..96becc20ad47 100644 --- a/privatebet/bet.c +++ b/privatebet/bet.c @@ -843,21 +843,10 @@ bits256 t_sg777_player_decode(struct privatebet_info *bet,int32_t cardID,int num { printf("\nError in joining the main thread for t_req"); } - else - { - printf("\nRequest thread is finished"); - } - if(pthread_join(t_res,NULL)) { printf("\nError in joining the main thread for t_res"); } - else - { - printf("\nResponse thread is finished"); - } - - printf("\n%s:%d",__FUNCTION__,__LINE__); for(int i=0;irange;i++) { From 8f97fabc25a8acf2a241375e22f5156f7034f6b0 Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:24:28 +0530 Subject: [PATCH 92/94] test --- privatebet/client.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 6e750d31d43c..f65ac69d4c52 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -764,11 +764,21 @@ void* BET_clientplayer(void * _ptr) } } - /* else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"request_share")) { + struct privatebet_share *share_info=NULL; - BET_give_share(gameInfo,bet,public_key_b,key); + share_info=calloc(1,sizeof(struct privatebet_share)); + share_info->bvv_public_key=public_key_b; + share_info->player_key=key; + share_info->subsock=bet->subsock; + share_info->myplayerid=bet->myplayerid; + share_info->range=bet->range; + share_info->numplayers=bet->numplayers; + share_info->pushsock=bet->pushsock; + BET_response(share_info); + free(share_info); + //BET_give_share(gameInfo,bet,public_key_b,key); }*/ } } From d11919237a8d4562c1a7124c8f2f4b8ab0987cff Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:25:19 +0530 Subject: [PATCH 93/94] test --- privatebet/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/privatebet/client.c b/privatebet/client.c index f65ac69d4c52..4ed879d9d31f 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -779,7 +779,7 @@ void* BET_clientplayer(void * _ptr) BET_response(share_info); free(share_info); //BET_give_share(gameInfo,bet,public_key_b,key); - }*/ + } } } nn_shutdown(bet->pushsock,0); From 2650b8418e8d39ed435e0b26561b5751d73c908d Mon Sep 17 00:00:00 2001 From: sg777 Date: Sat, 6 Jan 2018 09:30:47 +0530 Subject: [PATCH 94/94] test --- privatebet/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/privatebet/client.c b/privatebet/client.c index 4ed879d9d31f..665337d1bf9d 100644 --- a/privatebet/client.c +++ b/privatebet/client.c @@ -464,8 +464,10 @@ void* BET_response(void* _ptr) struct privatebet_share *share_info=_ptr; cJSON *share_res; char bindaddr[128]="ipc:///tmp/bet.ipc",bindaddr1[128]="ipc:///tmp/bet1.ipc"; - subsock=BET_nanosock(0,bindaddr,NN_SUB); - pushsock=BET_nanosock(0,bindaddr1,NN_PUSH); + //subsock=BET_nanosock(0,bindaddr,NN_SUB); + //pushsock=BET_nanosock(0,bindaddr1,NN_PUSH); + subsock=share_info->subsock; + pushsock=share_info->pushsock; int flag=1; while(flag) @@ -734,9 +736,9 @@ void* BET_clientplayer(void * _ptr) decoded[i] = k; } } - printf("\nCards Decoded:%d, errored:%d",decoded,errs); decodebad += errs; decodegood+= (numcards - errs); + printf("\nCards Decoded:%d, errored:%d",decodegood,decodebad); } else if(0==strcmp(cJSON_str(cJSON_GetObjectItem(gameInfo,"messageid")),"init_d")) {