Browse Source

Remove test_schnorr_threshold

etomic
jl777 8 years ago
parent
commit
1144093e81
  1. 2
      .gitignore
  2. 10
      basilisk/basilisk.c
  3. 126
      basilisk/jumblr.c
  4. 89
      iguana/iguana_secp.c
  5. 15
      iguana/main.c
  6. 2
      iguana/tests/dexlistunspent
  7. 4
      includes/iguana_funcs.h
  8. 11
      includes/iguana_structs.h

2
.gitignore

@ -216,3 +216,5 @@ iguana/autoAPI.md
iguana/confs/5228bcea7ae2515a29c3844673de6ee2acba53bf45724744a00ff4306f192912 iguana/confs/5228bcea7ae2515a29c3844673de6ee2acba53bf45724744a00ff4306f192912
iguana/confs/630929d976025fafde221c7358eb5805f4359bad3c6b8bd50ad3f6e0a9b5ce78 iguana/confs/630929d976025fafde221c7358eb5805f4359bad3c6b8bd50ad3f6e0a9b5ce78
iguana/confs/5f3283a017c31e52443d61cb43944e2157f7c03eb12d701ebf4a35a695688e1f

10
basilisk/basilisk.c

@ -1301,7 +1301,7 @@ STRING_ARG(jumblr,setpassphrase,passphrase)
safecopy(myinfo->jumblr_passphrase,passphrase,sizeof(myinfo->jumblr_passphrase)); safecopy(myinfo->jumblr_passphrase,passphrase,sizeof(myinfo->jumblr_passphrase));
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); privkey = jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,JUMBLR_DEPOSITPREFIX);
smartaddress_add(myinfo,privkey,BTCaddr,KMDaddr); smartaddress_add(myinfo,privkey,BTCaddr,KMDaddr);
myinfo->jumblr_depositkey = curve25519(privkey,curve25519_basepoint9()); myinfo->jumblr_depositkey = curve25519(privkey,curve25519_basepoint9());
bitcoin_priv2wif(wifstr,privkey,coin->chain->wiftype); bitcoin_priv2wif(wifstr,privkey,coin->chain->wiftype);
@ -1316,7 +1316,7 @@ STRING_ARG(jumblr,setpassphrase,passphrase)
jumblr_importprivkey(myinfo,coinbtc,wifstr); jumblr_importprivkey(myinfo,coinbtc,wifstr);
jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr))); jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr)));
} }
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); privkey = jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,"");
smartaddress_add(myinfo,privkey,BTCaddr,KMDaddr); smartaddress_add(myinfo,privkey,BTCaddr,KMDaddr);
myinfo->jumblr_pubkey = curve25519(privkey,curve25519_basepoint9()); myinfo->jumblr_pubkey = curve25519(privkey,curve25519_basepoint9());
jaddstr(retjson,"KMDjumblr",KMDaddr); jaddstr(retjson,"KMDjumblr",KMDaddr);
@ -1335,14 +1335,14 @@ ZERO_ARGS(jumblr,status)
jumblr_opidsupdate(myinfo,coin); jumblr_opidsupdate(myinfo,coin);
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
step_t2z = step_z2z = step_z2t = deposited = finished = pending = 0; step_t2z = step_z2z = step_z2t = deposited = finished = pending = 0;
jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,JUMBLR_DEPOSITPREFIX);
jaddstr(retjson,"KMDdeposit",KMDaddr); jaddstr(retjson,"KMDdeposit",KMDaddr);
jaddstr(retjson,"BTCdeposit",BTCaddr); jaddstr(retjson,"BTCdeposit",BTCaddr);
if ( (coinbtc= iguana_coinfind("BTC")) != 0 ) if ( (coinbtc= iguana_coinfind("BTC")) != 0 )
jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr))); jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr)));
received = jumblr_receivedby(myinfo,coin,KMDaddr); received = jumblr_receivedby(myinfo,coin,KMDaddr);
deposited = jumblr_balance(myinfo,coin,KMDaddr); deposited = jumblr_balance(myinfo,coin,KMDaddr);
jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,"");
jaddstr(retjson,"KMDjumblr",KMDaddr); jaddstr(retjson,"KMDjumblr",KMDaddr);
jaddstr(retjson,"BTCjumblr",BTCaddr); jaddstr(retjson,"BTCjumblr",BTCaddr);
if ( coinbtc != 0 ) if ( coinbtc != 0 )
@ -1706,7 +1706,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
jadd64bits(vals,"destsatoshis",jdouble(vals,"destamount") * SATOSHIDEN); jadd64bits(vals,"destsatoshis",jdouble(vals,"destamount") * SATOSHIDEN);
jaddnum(vals,"timestamp",time(NULL)); jaddnum(vals,"timestamp",time(NULL));
if ( (jumblr= jint(vals,"usejumblr")) != 0 ) if ( (jumblr= jint(vals,"usejumblr")) != 0 )
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,jumblr == 1 ? JUMBLR_DEPOSITPREFIX : ""); privkey = jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,jumblr == 1 ? JUMBLR_DEPOSITPREFIX : "");
else privkey = myinfo->persistent_priv; else privkey = myinfo->persistent_priv;
hash = curve25519(privkey,curve25519_basepoint9()); hash = curve25519(privkey,curve25519_basepoint9());
if ( jobj(vals,"srchash") == 0 ) if ( jobj(vals,"srchash") == 0 )

126
basilisk/jumblr.c

@ -289,8 +289,8 @@ void jumblr_opidupdate(struct supernet_info *myinfo,struct iguana_info *coin,str
if ( strcmp(status,"success") == 0 ) if ( strcmp(status,"success") == 0 )
{ {
ptr->status = jumblr_itemset(ptr,item,status); ptr->status = jumblr_itemset(ptr,item,status);
jumblr_privkey(myinfo,BTCaddr,KMDdeposit,JUMBLR_DEPOSITPREFIX); jumblr_privkey(myinfo,BTCaddr,0,KMDdeposit,JUMBLR_DEPOSITPREFIX);
jumblr_privkey(myinfo,BTCaddr,KMDjumblr,""); jumblr_privkey(myinfo,BTCaddr,0,KMDjumblr,"");
if ( (jumblr_addresstype(myinfo,coin,ptr->src) == 't' && jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && strcmp(ptr->src,KMDdeposit) != 0) || (jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && jumblr_addresstype(myinfo,coin,ptr->src) == 't' && strcmp(ptr->dest,KMDjumblr) != 0) ) if ( (jumblr_addresstype(myinfo,coin,ptr->src) == 't' && jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && strcmp(ptr->src,KMDdeposit) != 0) || (jumblr_addresstype(myinfo,coin,ptr->src) == 'z' && jumblr_addresstype(myinfo,coin,ptr->src) == 't' && strcmp(ptr->dest,KMDjumblr) != 0) )
{ {
printf("a non-jumblr t->z pruned\n"); printf("a non-jumblr t->z pruned\n");
@ -364,37 +364,125 @@ void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin)
} }
} }
bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,char *KMDaddr,char *prefix) bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,uint8_t pubtype,char *KMDaddr,char *prefix)
{ {
bits256 privkey,pubkey; uint8_t pubkey33[33]; char passphrase[sizeof(myinfo->jumblr_passphrase) + 64]; bits256 privkey,pubkey; uint8_t pubkey33[33]; char passphrase[sizeof(myinfo->jumblr_passphrase) + 64];
sprintf(passphrase,"%s%s",prefix,myinfo->jumblr_passphrase); sprintf(passphrase,"%s%s",prefix,myinfo->jumblr_passphrase);
conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
bitcoin_pubkey33(myinfo->ctx,pubkey33,privkey); bitcoin_pubkey33(myinfo->ctx,pubkey33,privkey);
bitcoin_address(BTCaddr,0,pubkey33,33); bitcoin_address(BTCaddr,pubtype,pubkey33,33);
bitcoin_address(KMDaddr,60,pubkey33,33); bitcoin_address(KMDaddr,60,pubkey33,33);
return(privkey); return(privkey);
} }
void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coinkmd,char *BTCaddr,char *KMDaddr,bits256 privkey) /*struct DEXcoin_info
{
bits256 deposit_privkey,jumblr_privkey;
struct iguana_info *coin;
cJSON *utxos,*spentutxos,*bigutxos,*normalutxos,*smallutxos,*feeutxos,*otherutxos;
double btcprice,USD_average,DEXpending,maxbid,minask,avail,KMDavail;
uint32_t lasttime;
char CMCname[32],symbol[16],depositaddr[64],KMDdepositaddr[64],KMDjumblraddr[64],jumblraddr[64];
};*/
int32_t jumblr_DEXsplit(struct supernet_info *myinfo,bits256 *splittxidp,bits256 txid,int32_t vout,uint64_t value,double bigprice,double middleprice,double smallprice,double feeprice)
{ {
static double kmdprice,pending; static uint32_t lasttime;
double btcavail=0,minbtc,avebid,aveask,highbid,lowask,CMC_average,USD_average,changes[3]; struct iguana_info *coinbtc; cJSON *vals; bits256 hash; char *retstr; }
coinbtc = iguana_coinfind("BTC");
if ( kmdprice == 0. || time(NULL) > lasttime+60 ) int32_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,bits256 *splittxidp,bits256 txid,int32_t vout,uint64_t value,int32_t isbob)
{ {
kmdprice = get_theoretical(&avebid,&aveask,&highbid,&lowask,&CMC_average,changes,"komodo","KMD","BTC",&USD_average); double targetpriceB,targetpriceM,targetpriceS,fee,depositfactor,dexfeeratio,margin = 1.1;
lasttime = (uint32_t)time(NULL); depositfactor = (isbob == 0) ? 1. : 1.2;
printf("KMD %.8f\n",kmdprice); dexfeeratio = 500.;
memset(splittxidp,0,sizeof(*splittxidp));
fee = JUMBLR_INCR * JUMBLR_FEE;
targetpriceB = depositfactor * ((JUMBLR_INCR + 3*fee)*100 + 3*JUMBLR_TXFEE);
targetpriceM = depositfactor * ((JUMBLR_INCR + 3*fee)*10 + 3*JUMBLR_TXFEE);
targetpriceS = depositfactor * ((JUMBLR_INCR + 3*fee) + 3*JUMBLR_TXFEE);
if ( value >= targetpriceB )
{
if ( value > margin * (targetpriceB + targetpriceS) )
jumblr_DEXsplit(myinfo,splittxidp,txid,vout,value,margin * targetpriceB,margin * targetpriceM,margin * targetpriceS,margin * targetpriceB/dexfeeratio);
return(0);
} }
if ( kmdprice > SMALLVAL ) else
{ {
minbtc = (kmdprice * 1.1) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE)); if ( value >= targetpriceM )
if ( coinbtc != 0 && (btcavail= dstr(jumblr_balance(myinfo,coinbtc,BTCaddr))) > minbtc+pending ) {
if ( value > margin * (targetpriceM + targetpriceS) )
return(jumblr_DEXsplit(myinfo,splittxidp,txid,vout,value,0.,margin * targetpriceM,margin * targetpriceS,margin * targetpriceM/dexfeeratio));
else return(0);
}
else
{
if ( value >= targetpriceS )
{
if ( value > margin * targetpriceS )
return(jumblr_DEXsplit(myinfo,splittxidp,txid,vout,value,0.,0.,margin * targetpriceS,margin * targetpriceS/dexfeeratio));
else return(0);
}
else if ( value > targetpriceS/dexfeeratio )
return(jumblr_DEXsplit(myinfo,splittxidp,txid,vout,value,0.,0.,0.,margin * targetpriceS/dexfeeratio));
else return(0);
}
}
}
void jumblr_DEXupdate(struct supernet_info *myinfo,struct DEXcoin_info *ptr,char *symbol,char *CMCname,double BTC2KMD,double KMDavail)
{
double avebid,aveask,highbid,lowask,CMC_average,changes[3]; struct iguana_info *kmdcoin = iguana_coinfind("KMD");
if ( kmdcoin != 0 && time(NULL) > ptr->lasttime+60 )
{
if ( strcmp(symbol,ptr->symbol) != 0 || ptr->coin == 0 )
{
safecopy(ptr->symbol,symbol,sizeof(ptr->symbol));
safecopy(ptr->CMCname,CMCname,sizeof(ptr->CMCname));
if ( ptr->coin == 0 )
ptr->coin = iguana_coinfind(symbol);
}
if ( ptr->coin != 0 )
{
if ( ptr->depositaddr[0] == 0 )
ptr->deposit_privkey = jumblr_privkey(myinfo,ptr->depositaddr,ptr->coin->chain->pubtype,ptr->KMDdepositaddr,JUMBLR_DEPOSITPREFIX);
if ( ptr->jumblraddr[0] == 0 )
ptr->jumblr_privkey = jumblr_privkey(myinfo,ptr->jumblraddr,ptr->coin->chain->pubtype,ptr->KMDjumblraddr,"");
ptr->avail = dstr(jumblr_balance(myinfo,ptr->coin,ptr->depositaddr));
}
ptr->btcprice = get_theoretical(&avebid,&aveask,&highbid,&lowask,&CMC_average,changes,CMCname,symbol,"BTC",&ptr->USD_average);
if ( strcmp("KMD",symbol) == 0 )
{
ptr->BTC2KMD = ptr->btcprice;
ptr->kmdprice = 1.;
ptr->KMDavail = ptr->avail;
}
else if ( (ptr->BTC2KMD= BTC2KMD) > SMALLVAL )
{
ptr->kmdprice = ptr->btcprice / BTC2KMD;
ptr->KMDavail = KMDavail;
}
ptr->lasttime = (uint32_t)time(NULL);
}
}
void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin)
{
struct iguana_info *kmdcoin;
if ( (kmdcoin= iguana_coinfind("KMD")) == 0 )
return;
jumblr_DEXupdate(myinfo,&kmdcoin->DEXinfo,"KMD","komodo",0.,0.);
if ( strcmp(coin->symbol,"KMD") != 0 && kmdcoin->DEXinfo.btcprice > 0. )
jumblr_DEXupdate(myinfo,&coin->DEXinfo,"KMD","komodo",kmdcoin->DEXinfo.btcprice,kmdcoin->DEXinfo.avail);
/*if ( kmdprice > SMALLVAL )
{
minbtc = (kmdprice * 1.2) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE));
btcavail = dstr(jumblr_balance(myinfo,coinbtc,BTCaddr));
if ( coinbtc != 0 && btcavail > minbtc+pending )
{ {
printf("BTC deposits %.8f, min %.8f\n",btcavail,minbtc); printf("BTC deposits %.8f, min %.8f\n",btcavail,minbtc);
vals = cJSON_CreateObject(); vals = cJSON_CreateObject();
jaddstr(vals,"source","BTC"); jaddstr(vals,"source","BTC");
//hash = curve25519(privkey,curve25519_basepoint9());
jaddstr(vals,"dest","KMD"); jaddstr(vals,"dest","KMD");
jaddnum(vals,"amount",btcavail*.3); jaddnum(vals,"amount",btcavail*.3);
jaddnum(vals,"minprice",kmdprice*.95); jaddnum(vals,"minprice",kmdprice*.95);
@ -408,7 +496,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coinkmd,ch
} }
// curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"KMD\",\"amount\":20,\"dest\":\"USD\",\"minprice\":0.08}}" // curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"KMD\",\"amount\":20,\"dest\":\"USD\",\"minprice\":0.08}}"
} //else printf("btcavail %.8f pending %.8f\n",btcavail,pending); } //else printf("btcavail %.8f pending %.8f\n",btcavail,pending);
} else printf("null kmdprice %.8f\n",kmdprice); } else printf("null kmdprice %.8f\n",kmdprice);*/
} }
void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval) void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval)
@ -424,7 +512,7 @@ void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int3
switch ( selector ) switch ( selector )
{ {
case 0: // public -> z, need to importprivkey case 0: // public -> z, need to importprivkey
jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,JUMBLR_DEPOSITPREFIX);
if ( (total= jumblr_balance(myinfo,coin,KMDaddr)) >= (JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))*SATOSHIDEN ) if ( (total= jumblr_balance(myinfo,coin,KMDaddr)) >= (JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))*SATOSHIDEN )
{ {
if ( (r & 1) == 0 ) if ( (r & 1) == 0 )
@ -477,7 +565,7 @@ void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int3
{ {
if ( (r & 1) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) if ( (r & 1) == 0 && ptr->spent == 0 && (total= jumblr_balance(myinfo,coin,ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN )
{ {
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); privkey = jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,"");
if ( (retstr= jumblr_sendz_to_t(myinfo,coin,ptr->dest,KMDaddr,dstr(total))) != 0 ) if ( (retstr= jumblr_sendz_to_t(myinfo,coin,ptr->dest,KMDaddr,dstr(total))) != 0 )
{ {
printf("sendz_to_t.(%s)\n",retstr); printf("sendz_to_t.(%s)\n",retstr);

89
iguana/iguana_secp.c

@ -451,95 +451,6 @@ int32_t bitcoin_rangeproof(void *ctx,uint8_t *proof,uint8_t *commit,bits256 blin
return(retval); return(retval);
} }
/*
* The intended procedure for creating a multiparty signature is:
* - Each signer S[i] with private key x[i] and public key Q[i] runs
* secp256k1_schnorr_generate_nonce_pair to produce a pair (k[i],R[i]) of private/public nonces.
* - All signers communicate their public nonces to each other (revealing your
* private nonce can lead to discovery of your private key, so it should be considered secret).
* - All signers combine all the public nonces they received (excluding their
* own) using secp256k1_ec_pubkey_combine to obtain an Rall[i] = sum(R[0..i-1,i+1..n]).
* - All signers produce a partial signature using
* secp256k1_schnorr_partial_sign, passing in their own private key x[i],
* their own private nonce k[i], and the sum of the others' public nonces Rall[i].
* - All signers communicate their partial signatures to each other.
* - Someone combines all partial signatures using secp256k1_schnorr_partial_combine, to obtain a full signature.
* - The resulting signature is validatable using secp256k1_schnorr_verify, with
* public key equal to the result of secp256k1_ec_pubkey_combine of the signers' public keys (sum(Q[0..n])).
*
* Note that secp256k1_schnorr_partial_combine and secp256k1_ec_pubkey_combine
* function take their arguments in any order, and it is possible to
* pre-combine several inputs already with one call, and add more inputs later
* by calling the function again (they are commutative and associative).
*/
#ifdef test_schnorr
#include "secp256k1/src/util.h"
#include "secp256k1/src/hash_impl.h"
#include "secp256k1/src/testrand_impl.h"
void test_schnorr_threshold(void *ctx) {
unsigned char msg[32];
unsigned char sec[5][32];
secp256k1_pubkey pub[5];
unsigned char nonce[5][32];
secp256k1_pubkey pubnonce[5];
unsigned char sig[5][64];
const unsigned char* sigs[5];
unsigned char allsig[64];
const secp256k1_pubkey* pubs[5];
secp256k1_pubkey allpub;
int n, i;
int damage;
int ret = 0;
damage = secp256k1_rand_bits(1) ? (1 + secp256k1_rand_int(4)) : 0;
secp256k1_rand256_test(msg);
n = 2 + secp256k1_rand_int(4);
for (i = 0; i < n; i++) {
do {
secp256k1_rand256_test(sec[i]);
} while (!secp256k1_ec_seckey_verify(ctx, sec[i]));
CHECK(secp256k1_ec_pubkey_create(ctx, &pub[i], sec[i]));
CHECK(secp256k1_schnorr_generate_nonce_pair(ctx, &pubnonce[i], nonce[i], msg, sec[i], NULL, NULL));
pubs[i] = &pub[i];
}
if (damage == 1) {
nonce[secp256k1_rand_int(n)][secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255);
} else if (damage == 2) {
sec[secp256k1_rand_int(n)][secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255);
}
for (i = 0; i < n; i++) {
secp256k1_pubkey allpubnonce;
const secp256k1_pubkey *pubnonces[4];
int j;
for (j = 0; j < i; j++) {
pubnonces[j] = &pubnonce[j];
}
for (j = i + 1; j < n; j++) {
pubnonces[j - 1] = &pubnonce[j];
}
CHECK(secp256k1_ec_pubkey_combine(ctx, &allpubnonce, pubnonces, n - 1));
ret |= (secp256k1_schnorr_partial_sign(ctx, sig[i], msg, sec[i], &allpubnonce, nonce[i]) != 1) * 1;
sigs[i] = sig[i];
}
if (damage == 3) {
sig[secp256k1_rand_int(n)][secp256k1_rand_bits(6)] ^= 1 + secp256k1_rand_int(255);
}
ret |= (secp256k1_ec_pubkey_combine(ctx, &allpub, pubs, n) != 1) * 2;
if ((ret & 1) == 0) {
ret |= (secp256k1_schnorr_partial_combine(ctx, allsig, sigs, n) != 1) * 4;
}
if (damage == 4) {
allsig[secp256k1_rand_int(32)] ^= 1 + secp256k1_rand_int(255);
}
if ((ret & 7) == 0) {
ret |= (secp256k1_schnorr_verify(ctx, allsig, msg, &allpub) != 1) * 8;
}
CHECK((ret == 0) == (damage == 0));
}
#endif
int32_t iguana_pederson_test(void *ctx) int32_t iguana_pederson_test(void *ctx)
{ {
uint8_t commits[100][33],*commitptrs[100],proofs[100][5138]; uint16_t vouts[100]; int64_t min_value,values[100],totalpos,totalneg; bits256 txids[100],nonces[100],blinds[100],*blindptrs[100],blindsum; int32_t prooflens[100],i,r,pos,neg,numpos,exponent,min_bits,n,N = 100; uint8_t commits[100][33],*commitptrs[100],proofs[100][5138]; uint16_t vouts[100]; int64_t min_value,values[100],totalpos,totalneg; bits256 txids[100],nonces[100],blinds[100],*blindptrs[100],blindsum; int32_t prooflens[100],i,r,pos,neg,numpos,exponent,min_bits,n,N = 100;

15
iguana/main.c

@ -749,19 +749,18 @@ void iguana_urlinit(struct supernet_info *myinfo,int32_t ismainnet,int32_t usess
void jumblr_loop(void *ptr) void jumblr_loop(void *ptr)
{ {
struct iguana_info *coin; char BTCaddr[64],KMDaddr[64]; bits256 privkey; uint32_t t; struct supernet_info *myinfo = ptr; int32_t mult = 10; struct iguana_info *coin; uint32_t t; struct supernet_info *myinfo = ptr; int32_t mult = 10;
printf("JUMBLR loop\n"); printf("JUMBLR loop\n");
while ( 1 ) while ( 1 )
{ {
if ( (coin= iguana_coinfind("KMD")) != 0 && coin->FULLNODE < 0 ) if ( myinfo->jumblr_passphrase[0] != 0 && (coin= iguana_coinfind("KMD")) != 0 && coin->FULLNODE < 0 )
{ {
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX);
// if BTC has arrived in deposit address, invoke DEX -> KMD
// if BTC has arrived in destination address, invoke DEX -> BTC // if BTC has arrived in destination address, invoke DEX -> BTC
jumblr_DEXcheck(myinfo,coin,BTCaddr,KMDaddr,privkey); jumblr_DEXcheck(myinfo,coin);
t = (uint32_t)time(NULL); t = (uint32_t)time(NULL);
if ( myinfo->jumblr_passphrase[0] != 0 && (t % (120 * mult)) < 60 ) if ( (t % (120 * mult)) < 60 )
{ {
// if BTC has arrived in deposit address, invoke DEX -> KMD
jumblr_iteration(myinfo,coin,(t % (360 * mult)) / (120 * mult),t % (120 * mult)); jumblr_iteration(myinfo,coin,(t % (360 * mult)) / (120 * mult),t % (120 * mult));
} }
//printf("t.%u %p.%d %s\n",t,coin,coin!=0?coin->FULLNODE:0,myinfo->jumblr_passphrase); //printf("t.%u %p.%d %s\n",t,coin,coin!=0?coin->FULLNODE:0,myinfo->jumblr_passphrase);
@ -1909,10 +1908,10 @@ ZERO_ARGS(SuperNET,activehandle)
} else jaddstr(retjson,"status","locked"); } else jaddstr(retjson,"status","locked");
if ( myinfo->jumblr_passphrase[0] != 0 ) if ( myinfo->jumblr_passphrase[0] != 0 )
{ {
jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,JUMBLR_DEPOSITPREFIX);
jaddstr(retjson,"BTCdeposit","notyet"); jaddstr(retjson,"BTCdeposit","notyet");
jaddstr(retjson,"KMDdeposit",KMDaddr); jaddstr(retjson,"KMDdeposit",KMDaddr);
jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); jumblr_privkey(myinfo,BTCaddr,0,KMDaddr,"");
jaddstr(retjson,"BTCjumblr","notyet"); jaddstr(retjson,"BTCjumblr","notyet");
jaddstr(retjson,"KMDjumblr",KMDaddr); jaddstr(retjson,"KMDjumblr",KMDaddr);
} }

2
iguana/tests/dexlistunspent

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"\",\"symbol\":\"BTC\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"REMYL4s4zSiKeLEit5FawHFuGKZ4apm297\",\"symbol\":\"KMD\"}"

4
includes/iguana_funcs.h

@ -629,8 +629,8 @@ int32_t iguana_staker_sort(struct iguana_info *coin,bits256 *hash2p,uint8_t *ref
bits256 mpz_div64(bits256 hash,uint64_t divval); bits256 mpz_div64(bits256 hash,uint64_t divval);
void iguana_walletinitcheck(struct supernet_info *myinfo,struct iguana_info *coin); void iguana_walletinitcheck(struct supernet_info *myinfo,struct iguana_info *coin);
void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval); void jumblr_iteration(struct supernet_info *myinfo,struct iguana_info *coin,int32_t selector,int32_t modval);
void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coinkmd,char *BTCaddr,char *KMDaddr,bits256 privkey); void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin);
bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,char *KMDaddr,char *prefix); bits256 jumblr_privkey(struct supernet_info *myinfo,char *BTCaddr,uint8_t pubtype,char *KMDaddr,char *prefix);
char *jumblr_importprivkey(struct supernet_info *myinfo,struct iguana_info *coin,char *wifstr); char *jumblr_importprivkey(struct supernet_info *myinfo,struct iguana_info *coin,char *wifstr);
int64_t iguana_esttxfee(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,char *signedtx,int32_t numvins); int64_t iguana_esttxfee(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,char *signedtx,int32_t numvins);

11
includes/iguana_structs.h

@ -466,6 +466,16 @@ struct iguana_RTtxid
struct hashstr_item { UT_hash_handle hh; char address[40]; }; struct hashstr_item { UT_hash_handle hh; char address[40]; };
struct DEXcoin_info
{
bits256 deposit_privkey,jumblr_privkey;
struct iguana_info *coin;
cJSON *utxos,*spentutxos,*bigutxos,*normalutxos,*smallutxos,*feeutxos,*otherutxos;
double btcprice,BTC2KMD,kmdprice,USD_average,DEXpending,maxbid,minask,avail,KMDavail;
uint32_t lasttime;
char CMCname[32],symbol[16],depositaddr[64],KMDdepositaddr[64],KMDjumblraddr[64],jumblraddr[64];
};
struct iguana_info struct iguana_info
{ {
UT_hash_handle hh; UT_hash_handle hh;
@ -534,6 +544,7 @@ struct iguana_info
uint64_t estimatedfee; uint64_t estimatedfee;
char seedipaddr[64]; char seedipaddr[64];
uint32_t lastbesthashtime; bits256 lastbesthash; int32_t lastbestheight; uint32_t lastbesthashtime; bits256 lastbesthash; int32_t lastbestheight;
struct DEXcoin_info DEXinfo;
struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536]; struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536];
struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs; struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs;
struct hashstr_item *alladdresses; struct hashstr_item *alladdresses;

Loading…
Cancel
Save