int32_t smartaddress_add(struct supernet_info *myinfo,bits256 privkey,char *BTCaddr,char *KMDaddr) { struct smartaddress *ap; int32_t i; if ( myinfo->numsmartaddrs < sizeof(myinfo->smartaddrs)/sizeof(*myinfo->smartaddrs) ) { for (i=0; i<myinfo->numsmartaddrs; i++) if ( bits256_cmp(myinfo->smartaddrs[i].privkey,privkey) == 0 ) return(-1); ap = &myinfo->smartaddrs[myinfo->numsmartaddrs++]; ap->privkey = privkey; bitcoin_pubkey33(myinfo->ctx,ap->pubkey33,privkey); calc_rmd160_sha256(ap->rmd160,ap->pubkey33,33); ap->pubkey = curve25519(privkey,curve25519_basepoint9()); char coinaddr[64]; uint8_t addrtype,rmd160[20]; bitcoin_address(coinaddr,0,ap->pubkey33,33); for (i=0; i<20; i++) printf("%02x",ap->rmd160[i]); bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr); printf(", "); for (i=0; i<20; i++) printf("%02x",rmd160[i]); printf (" <- rmd160 for %d %s vs %s\n",myinfo->numsmartaddrs,coinaddr,BTCaddr); return(myinfo->numsmartaddrs); } printf("too many smartaddresses %d vs %d\n",myinfo->numsmartaddrs,(int32_t)(sizeof(myinfo->smartaddrs)/sizeof(*myinfo->smartaddrs))); return(-1); }
bits256 SuperNET_wallet2shared(bits256 wallethash,bits256 wallet2priv) { bits256 wallet2shared,seed,wallet2pub; wallet2pub = curve25519(wallet2priv,curve25519_basepoint9()); seed = curve25519_shared(wallethash,wallet2pub); vcalc_sha256(0,wallet2shared.bytes,seed.bytes,sizeof(bits256)); return(wallet2shared); }
bits256 cards777_cardpriv(bits256 playerpriv,bits256 *cardpubs,int32_t numcards,bits256 cipher) { bits256 cardpriv,checkpub; int32_t i; for (i=0; i<numcards; i++) { cardpriv = cards777_initcrypt(cipher,playerpriv,cardpubs[i],1); //printf("(%llx %llx) ",(long long)cardpriv.txid,(long long)curve25519_shared(playerpriv,cardpubs[i]).txid); checkpub = curve25519(cardpriv,curve25519_basepoint9()); if ( memcmp(checkpub.bytes,cardpubs[i].bytes,sizeof(bits256)) == 0 ) { //printf("%d ",cardpriv.bytes[1]); //printf("decrypted card.%d %llx\n",cardpriv.bytes[1],(long long)cardpriv.txid); return(cardpriv); } } //printf("\nplayerpriv %llx cipher.%llx\n",(long long)playerpriv.txid,(long long)cipher.txid); memset(cardpriv.bytes,0,sizeof(cardpriv)); return(cardpriv); }