|
@ -909,19 +909,23 @@ void basilisk_swap01(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
{ |
|
|
{ |
|
|
int32_t datalen; |
|
|
int32_t datalen; |
|
|
datalen = basilisk_swapdata_deck(myinfo,swap,data,maxlen); |
|
|
datalen = basilisk_swapdata_deck(myinfo,swap,data,maxlen); |
|
|
|
|
|
printf("send deck.%d\n",datalen); |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x02,data,datalen,0x01); |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x02,data,datalen,0x01); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if ( (rand() % 100) == 0 ) |
|
|
basilisk_swap01(myinfo,swap,data,maxlen); |
|
|
basilisk_swap01(myinfo,swap,data,maxlen); |
|
|
|
|
|
printf("check for other deck\n"); |
|
|
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 ) |
|
|
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 ) |
|
|
swap->statebits |= 0x02; |
|
|
swap->statebits |= 0x02; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
{ |
|
|
{ |
|
|
int32_t i,datalen; |
|
|
int32_t i,datalen; char str[65]; |
|
|
|
|
|
if ( (rand() % 10) == 0 ) |
|
|
basilisk_swap02(myinfo,swap,data,maxlen); |
|
|
basilisk_swap02(myinfo,swap,data,maxlen); |
|
|
datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei); |
|
|
datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei); |
|
|
if ( swap->iambob != 0 ) |
|
|
if ( swap->iambob != 0 ) |
|
@ -930,6 +934,7 @@ void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
data[datalen++] = swap->pubB0.bytes[i]; |
|
|
data[datalen++] = swap->pubB0.bytes[i]; |
|
|
for (i=0; i<32; i++) |
|
|
for (i=0; i<32; i++) |
|
|
data[datalen++] = swap->pubB1.bytes[i]; |
|
|
data[datalen++] = swap->pubB1.bytes[i]; |
|
|
|
|
|
printf("SEND pubB0/1 %s\n",bits256_str(str,swap->pubB0)); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -937,19 +942,22 @@ void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
data[datalen++] = swap->pubA0.bytes[i]; |
|
|
data[datalen++] = swap->pubA0.bytes[i]; |
|
|
for (i=0; i<32; i++) |
|
|
for (i=0; i<32; i++) |
|
|
data[datalen++] = swap->pubA1.bytes[i]; |
|
|
data[datalen++] = swap->pubA1.bytes[i]; |
|
|
char str[65]; printf("SEND pubA0/1 %s\n",bits256_str(str,swap->pubA0)); |
|
|
printf("SEND pubA0/1 %s\n",bits256_str(str,swap->pubA0)); |
|
|
} |
|
|
} |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x08,data,datalen,0x04); |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x08,data,datalen,0x04); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
{ |
|
|
{ |
|
|
uint8_t pubkey33[33]; |
|
|
uint8_t pubkey33[33]; char str[65]; |
|
|
|
|
|
if ( (rand() % 10) == 0 ) |
|
|
basilisk_swap04(myinfo,swap,data,maxlen); |
|
|
basilisk_swap04(myinfo,swap,data,maxlen); |
|
|
|
|
|
printf("check otherchoosei\n"); |
|
|
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) |
|
|
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) |
|
|
{ |
|
|
{ |
|
|
char str[65]; |
|
|
|
|
|
if ( swap->iambob != 0 ) |
|
|
if ( swap->iambob != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( bits256_nonz(swap->privBn) == 0 ) |
|
|
{ |
|
|
{ |
|
|
swap->privBn = swap->privkeys[swap->otherchoosei]; |
|
|
swap->privBn = swap->privkeys[swap->otherchoosei]; |
|
|
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); |
|
|
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); |
|
@ -957,7 +965,10 @@ void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privBn); |
|
|
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privBn); |
|
|
printf("set privBn.%s\n",bits256_str(str,swap->privBn)); |
|
|
printf("set privBn.%s\n",bits256_str(str,swap->privBn)); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
else |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if ( bits256_nonz(swap->privAm) == 0 ) |
|
|
{ |
|
|
{ |
|
|
swap->privAm = swap->privkeys[swap->otherchoosei]; |
|
|
swap->privAm = swap->privkeys[swap->otherchoosei]; |
|
|
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); |
|
|
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); |
|
@ -965,6 +976,7 @@ void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privAm); |
|
|
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privAm); |
|
|
printf("set privAm.%s\n",bits256_str(str,swap->privAm)); |
|
|
printf("set privAm.%s\n",bits256_str(str,swap->privAm)); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
swap->statebits |= 0x08; |
|
|
swap->statebits |= 0x08; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -972,6 +984,7 @@ void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
{ |
|
|
{ |
|
|
int32_t i,j,datalen; |
|
|
int32_t i,j,datalen; |
|
|
|
|
|
if ( (rand() % 10) == 0 ) |
|
|
basilisk_swap08(myinfo,swap,data,maxlen); |
|
|
basilisk_swap08(myinfo,swap,data,maxlen); |
|
|
datalen = 0; |
|
|
datalen = 0; |
|
|
for (i=0; i<sizeof(swap->privkeys)/sizeof(*swap->privkeys); i++) |
|
|
for (i=0; i<sizeof(swap->privkeys)/sizeof(*swap->privkeys); i++) |
|
@ -993,6 +1006,7 @@ void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uin |
|
|
for (i=0; i<20; i++) |
|
|
for (i=0; i<20; i++) |
|
|
data[datalen++] = swap->secretAm[i]; |
|
|
data[datalen++] = swap->secretAm[i]; |
|
|
} |
|
|
} |
|
|
|
|
|
printf("send privkeys.%d\n",datalen); |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x20,data,datalen,0x10); |
|
|
swap->statebits |= basilisk_swapsend(myinfo,swap,0x20,data,datalen,0x10); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|