diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 1679fdf51..721f9dda6 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -81,7 +81,8 @@ char *basilisk_bitcoinblockhashstr(char *coinstr,char *serverport,char *userpass { char numstr[128],*blockhashstr=0; bits256 hash2; struct iguana_info *coin; sprintf(numstr,"%d",height); - blockhashstr = bitcoind_passthru(coinstr,serverport,userpass,"getblockhash",numstr); + if ( (blockhashstr= bitcoind_passthru(coinstr,serverport,userpass,"getblockhash",numstr)) == 0 ) + return(0); hash2 = bits256_conv(blockhashstr); if ( blockhashstr == 0 || blockhashstr[0] == 0 || bits256_nonz(hash2) == 0 ) { diff --git a/crypto777/scrypt.c b/crypto777/scrypt.c index c8fdebd07..99ce4a04a 100755 --- a/crypto777/scrypt.c +++ b/crypto777/scrypt.c @@ -1,5 +1,6 @@ -/*- - * Copyright 2009 Colin Percival, 2011 ArtForz, 2011 pooler, 2013 Balthazar + +/* + * Copyright 2009 Colin Percival, 2011 ArtForz, 2011-2014 pooler * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,251 +28,341 @@ * online backup system. */ -#include "../includes/curve25519.h" -#define SCRYPT_BUFFER_SIZE (131072 + 63) +#include +#include +#include -/* -static inline uint32_t be32dec(const void *pp) -{ - const uint8_t *p = (uint8_t const *)pp; - return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) + ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24)); -} +static const uint32_t keypad[12] = { + 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000280 +}; +static const uint32_t innerpad[11] = { + 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x000004a0 +}; +static const uint32_t outerpad[8] = { + 0x80000000, 0, 0, 0, 0, 0, 0, 0x00000300 +}; +static const uint32_t finalblk[16] = { + 0x00000001, 0x80000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000620 +}; -static inline void be32enc(void *pp,uint32_t x) -{ - uint8_t *p = (uint8_t *)pp; - p[3] = x & 0xff; - p[2] = (x >> 8) & 0xff; - p[1] = (x >> 16) & 0xff; - p[0] = (x >> 24) & 0xff; -} +static const uint32_t sha256_h[8] = { + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 +}; -void HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx,const void * _K,size_t Klen) -{ - size_t i; uint8_t pad[64],khash[32]; const uint8_t * K = (const uint8_t *)_K; - // If Klen > 64, the key is really SHA256(K). - if ( Klen > 64 ) - { - SHA256_Init(&ctx->ictx); - SHA256_Update(&ctx->ictx, K, Klen); - SHA256_Final(khash, &ctx->ictx); - K = khash; - Klen = 32; - } - // Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). - SHA256_Init(&ctx->ictx); - memset(pad, 0x36, 64); - for (i = 0; i < Klen; i++) - pad[i] ^= K[i]; - SHA256_Update(&ctx->ictx, pad, 64); - // Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). - SHA256_Init(&ctx->octx); - memset(pad, 0x5c, 64); - for (i = 0; i < Klen; i++) - pad[i] ^= K[i]; - SHA256_Update(&ctx->octx, pad, 64); - // Clean the stack. - memset(khash,0,32); -} +static const uint32_t sha256_k[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; -// Add bytes to the HMAC-SHA256 operation. -void HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx,const void *in,size_t len) +static inline void sha256_init(uint32_t *state) { - SHA256_Update(&ctx->ictx,in,len); + memcpy(state, sha256_h, 32); } -// Finish an HMAC-SHA256 operation. -void HMAC_SHA256_Final(uint8_t digest[32],HMAC_SHA256_CTX *ctx) -{ - uint8_t ihash[32]; - SHA256_Final(ihash,&ctx->ictx); - SHA256_Update(&ctx->octx,ihash,32); - SHA256_Final(digest,&ctx->octx); - memset(ihash,0,32); -} - -// PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and write the output to buf. The value dkLen must be at most 32 * (2^32 - 1) -void PBKDF2_SHA256(const uint8_t *passwd,size_t passwdlen,const uint8_t *salt,size_t saltlen,uint64_t c,uint8_t *buf,size_t dkLen) -{ - HMAC_SHA256_CTX PShctx, hctx; - size_t i,clen; uint8_t ivec[4],U[32],T[32]; uint64_t j; int32_t k; - // Compute HMAC state after processing P and S. - HMAC_SHA256_Init(&PShctx, passwd, passwdlen); - HMAC_SHA256_Update(&PShctx, salt, saltlen); - // Iterate through the blocks. - for (i=0; i*32 32) - clen = 32; - memcpy(&buf[i * 32],T,clen); - } -}*/ +/* Elementary functions used by SHA256 */ +#define Ch(x, y, z) ((x & (y ^ z)) ^ z) +#define Maj(x, y, z) ((x & (y | z)) | (y & z)) +#define ROTR(x, n) ((x >> n) | (x << (32 - n))) +#define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) +#define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) +#define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ (x >> 3)) +#define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ (x >> 10)) -// Generic scrypt_core implementation - -static inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16]) -{ - int32_t i; uint32_t x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15; - x00 = (B[0] ^= Bx[0]); - x01 = (B[1] ^= Bx[1]); - x02 = (B[2] ^= Bx[2]); - x03 = (B[3] ^= Bx[3]); - x04 = (B[4] ^= Bx[4]); - x05 = (B[5] ^= Bx[5]); - x06 = (B[6] ^= Bx[6]); - x07 = (B[7] ^= Bx[7]); - x08 = (B[8] ^= Bx[8]); - x09 = (B[9] ^= Bx[9]); - x10 = (B[10] ^= Bx[10]); - x11 = (B[11] ^= Bx[11]); - x12 = (B[12] ^= Bx[12]); - x13 = (B[13] ^= Bx[13]); - x14 = (B[14] ^= Bx[14]); - x15 = (B[15] ^= Bx[15]); - for (i = 0; i < 8; i += 2) { -#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) - /* Operate on columns. */ - x04 ^= R(x00+x12, 7); x09 ^= R(x05+x01, 7); - x14 ^= R(x10+x06, 7); x03 ^= R(x15+x11, 7); +/* SHA256 round function */ +#define RND(a, b, c, d, e, f, g, h, k) \ +do { \ +t0 = h + S1(e) + Ch(e, f, g) + k; \ +t1 = S0(a) + Maj(a, b, c); \ +d += t0; \ +h = t0 + t1; \ +} while (0) - x08 ^= R(x04+x00, 9); x13 ^= R(x09+x05, 9); - x02 ^= R(x14+x10, 9); x07 ^= R(x03+x15, 9); +/* Adjusted round function for rotating state */ +#define RNDr(S, W, i) \ +RND(S[(64 - i) % 8], S[(65 - i) % 8], \ +S[(66 - i) % 8], S[(67 - i) % 8], \ +S[(68 - i) % 8], S[(69 - i) % 8], \ +S[(70 - i) % 8], S[(71 - i) % 8], \ +W[i] + sha256_k[i]) - x12 ^= R(x08+x04,13); x01 ^= R(x13+x09,13); - x06 ^= R(x02+x14,13); x11 ^= R(x07+x03,13); +#define swab32(x) ((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | (((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) - x00 ^= R(x12+x08,18); x05 ^= R(x01+x13,18); - x10 ^= R(x06+x02,18); x15 ^= R(x11+x07,18); - - /* Operate on rows. */ - x01 ^= R(x00+x03, 7); x06 ^= R(x05+x04, 7); - x11 ^= R(x10+x09, 7); x12 ^= R(x15+x14, 7); - - x02 ^= R(x01+x00, 9); x07 ^= R(x06+x05, 9); - x08 ^= R(x11+x10, 9); x13 ^= R(x12+x15, 9); - - x03 ^= R(x02+x01,13); x04 ^= R(x07+x06,13); - x09 ^= R(x08+x11,13); x14 ^= R(x13+x12,13); - - x00 ^= R(x03+x02,18); x05 ^= R(x04+x07,18); - x10 ^= R(x09+x08,18); x15 ^= R(x14+x13,18); -#undef R - } - B[0] += x00; - B[1] += x01; - B[2] += x02; - B[3] += x03; - B[4] += x04; - B[5] += x05; - B[6] += x06; - B[7] += x07; - B[8] += x08; - B[9] += x09; - B[10] += x10; - B[11] += x11; - B[12] += x12; - B[13] += x13; - B[14] += x14; - B[15] += x15; -} - -static inline void scrypt_core(uint32_t *X,uint32_t *V) +static inline void sha256_transform(uint32_t *state, const uint32_t *block, int swap) { - uint32_t i,j,k; - for (i=0; i<1024; i++) - { - memcpy(&V[i * 32],X,128); - xor_salsa8(&X[0],&X[16]); - xor_salsa8(&X[16],&X[0]); - } - for (i=0; i<1024; i++) - { - j = 32 * (X[16] & 1023); - for (k = 0; k < 32; k++) - X[k] ^= V[j + k]; - xor_salsa8(&X[0],&X[16]); - xor_salsa8(&X[16],&X[0]); - } + uint32_t W[64]; + uint32_t S[8]; + uint32_t t0, t1; + int i; + + /* 1. Prepare message schedule W. */ + if (swap) { + for (i = 0; i < 16; i++) + W[i] = swab32(block[i]); + } else + memcpy(W, block, 64); + for (i = 16; i < 64; i += 2) { + W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16]; + W[i+1] = s1(W[i - 1]) + W[i - 6] + s0(W[i - 14]) + W[i - 15]; + } + + /* 2. Initialize working variables. */ + memcpy(S, state, 32); + + /* 3. Mix. */ + RNDr(S, W, 0); + RNDr(S, W, 1); + RNDr(S, W, 2); + RNDr(S, W, 3); + RNDr(S, W, 4); + RNDr(S, W, 5); + RNDr(S, W, 6); + RNDr(S, W, 7); + RNDr(S, W, 8); + RNDr(S, W, 9); + RNDr(S, W, 10); + RNDr(S, W, 11); + RNDr(S, W, 12); + RNDr(S, W, 13); + RNDr(S, W, 14); + RNDr(S, W, 15); + RNDr(S, W, 16); + RNDr(S, W, 17); + RNDr(S, W, 18); + RNDr(S, W, 19); + RNDr(S, W, 20); + RNDr(S, W, 21); + RNDr(S, W, 22); + RNDr(S, W, 23); + RNDr(S, W, 24); + RNDr(S, W, 25); + RNDr(S, W, 26); + RNDr(S, W, 27); + RNDr(S, W, 28); + RNDr(S, W, 29); + RNDr(S, W, 30); + RNDr(S, W, 31); + RNDr(S, W, 32); + RNDr(S, W, 33); + RNDr(S, W, 34); + RNDr(S, W, 35); + RNDr(S, W, 36); + RNDr(S, W, 37); + RNDr(S, W, 38); + RNDr(S, W, 39); + RNDr(S, W, 40); + RNDr(S, W, 41); + RNDr(S, W, 42); + RNDr(S, W, 43); + RNDr(S, W, 44); + RNDr(S, W, 45); + RNDr(S, W, 46); + RNDr(S, W, 47); + RNDr(S, W, 48); + RNDr(S, W, 49); + RNDr(S, W, 50); + RNDr(S, W, 51); + RNDr(S, W, 52); + RNDr(S, W, 53); + RNDr(S, W, 54); + RNDr(S, W, 55); + RNDr(S, W, 56); + RNDr(S, W, 57); + RNDr(S, W, 58); + RNDr(S, W, 59); + RNDr(S, W, 60); + RNDr(S, W, 61); + RNDr(S, W, 62); + RNDr(S, W, 63); + + /* 4. Mix local working variables into global state */ + for (i = 0; i < 8; i++) + state[i] += S[i]; } -/* cpu and memory intensive function to transform a 80 byte buffer into a 32 byte output - scratchpad size needs to be at least 63 + (128 * r * p) + (256 * r + 64) + (128 * r * N) bytes - r = 1, p = 1, N = 1024 - */ - -bits256 scrypt_nosalt(const void *input,size_t inputlen,void *scratchpad) +static inline void HMAC_SHA256_80_init(const uint32_t *key,uint32_t *tstate, uint32_t *ostate) { - uint32_t *V; uint32_t X[32]; bits256 result; - memset(result.bytes,0,sizeof(result)); - V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63)); - calc_hmac_sha256((void *)X,128,(void *)input,(int32_t)inputlen,(void *)input,(int32_t)inputlen); - //PBKDF2_SHA256((const uint8_t *)input,inputlen,(const uint8_t *)input,inputlen,1,(uint8_t *)X,128); - scrypt_core(X,V); - calc_hmac_sha256((void *)result.bytes,sizeof(result),(void *)input,(int32_t)inputlen,(void *)X,128); - //PBKDF2_SHA256((const uint8_t *)input,inputlen,(uint8_t *)X,128,1,(uint8_t*)&result,32); - return result; + uint32_t ihash[8]; + uint32_t pad[16]; + int i; + + /* tstate is assumed to contain the midstate of key */ + memcpy(pad, key + 16, 16); + memcpy(pad + 4, keypad, 48); + sha256_transform(tstate, pad, 0); + memcpy(ihash, tstate, 32); + + sha256_init(ostate); + for (i = 0; i < 8; i++) + pad[i] = ihash[i] ^ 0x5c5c5c5c; + for (; i < 16; i++) + pad[i] = 0x5c5c5c5c; + sha256_transform(ostate, pad, 0); + + sha256_init(tstate); + for (i = 0; i < 8; i++) + pad[i] = ihash[i] ^ 0x36363636; + for (; i < 16; i++) + pad[i] = 0x36363636; + sha256_transform(tstate, pad, 0); } -bits256 scrypt(const void *data,size_t datalen,const void *salt,size_t saltlen,void *scratchpad) +static inline void PBKDF2_SHA256_80_128(const uint32_t *tstate,const uint32_t *ostate, const uint32_t *salt, uint32_t *output) { - uint32_t *V; uint32_t X[32]; bits256 result; - memset(result.bytes,0,sizeof(result)); - V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63)); - calc_hmac_sha256((void *)X,128,(void *)data,(int32_t)datalen,(void *)salt,(int32_t)saltlen); - //PBKDF2_SHA256((const uint8_t *)data,datalen,(const uint8_t *)salt,saltlen,1,(uint8_t *)X,128); - scrypt_core(X,V); - calc_hmac_sha256((void *)result.bytes,sizeof(result),(void *)data,(int32_t)datalen,(void *)X,128); - //PBKDF2_SHA256((const uint8_t *)data,datalen,(uint8_t *)X,128,1,(uint8_t *)&result,32); - return result; + uint32_t istate[8], ostate2[8],ibuf[16], obuf[16]; int i, j; + memcpy(istate, tstate, 32); + sha256_transform(istate, salt, 0); + memcpy(ibuf, salt + 16, 16); + memcpy(ibuf + 5, innerpad, 44); + memcpy(obuf + 8, outerpad, 32); + for (i = 0; i < 4; i++) + { + memcpy(obuf, istate, 32); + ibuf[4] = i + 1; + sha256_transform(obuf, ibuf, 0); + memcpy(ostate2, ostate, 32); + sha256_transform(ostate2, obuf, 0); + for (j = 0; j < 8; j++) + output[8 * i + j] = swab32(ostate2[j]); + } } -bits256 scrypt_hash(const void *input,size_t inputlen) +static inline void PBKDF2_SHA256_128_32(uint32_t *tstate, uint32_t *ostate,const uint32_t *salt, uint32_t *output) { - uint8_t scratchpad[SCRYPT_BUFFER_SIZE]; - return scrypt_nosalt(input,inputlen,scratchpad); + uint32_t buf[16]; int i; + sha256_transform(tstate, salt, 1); + sha256_transform(tstate, salt + 16, 1); + sha256_transform(tstate, finalblk, 0); + memcpy(buf, tstate, 32); + memcpy(buf + 8, outerpad, 32); + sha256_transform(ostate, buf, 0); + for (i = 0; i < 8; i++) + output[i] = swab32(ostate[i]); } -bits256 scrypt_salted_hash(const void *input,size_t inputlen,const void *salt,size_t saltlen) +static inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16]) { - uint8_t scratchpad[SCRYPT_BUFFER_SIZE]; - return scrypt(input,inputlen,salt,saltlen,scratchpad); + uint32_t x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15; + int i; + + x00 = (B[ 0] ^= Bx[ 0]); + x01 = (B[ 1] ^= Bx[ 1]); + x02 = (B[ 2] ^= Bx[ 2]); + x03 = (B[ 3] ^= Bx[ 3]); + x04 = (B[ 4] ^= Bx[ 4]); + x05 = (B[ 5] ^= Bx[ 5]); + x06 = (B[ 6] ^= Bx[ 6]); + x07 = (B[ 7] ^= Bx[ 7]); + x08 = (B[ 8] ^= Bx[ 8]); + x09 = (B[ 9] ^= Bx[ 9]); + x10 = (B[10] ^= Bx[10]); + x11 = (B[11] ^= Bx[11]); + x12 = (B[12] ^= Bx[12]); + x13 = (B[13] ^= Bx[13]); + x14 = (B[14] ^= Bx[14]); + x15 = (B[15] ^= Bx[15]); + for (i = 0; i < 8; i += 2) { +#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) + /* Operate on columns. */ + x04 ^= R(x00+x12, 7); x09 ^= R(x05+x01, 7); + x14 ^= R(x10+x06, 7); x03 ^= R(x15+x11, 7); + + x08 ^= R(x04+x00, 9); x13 ^= R(x09+x05, 9); + x02 ^= R(x14+x10, 9); x07 ^= R(x03+x15, 9); + + x12 ^= R(x08+x04,13); x01 ^= R(x13+x09,13); + x06 ^= R(x02+x14,13); x11 ^= R(x07+x03,13); + + x00 ^= R(x12+x08,18); x05 ^= R(x01+x13,18); + x10 ^= R(x06+x02,18); x15 ^= R(x11+x07,18); + + /* Operate on rows. */ + x01 ^= R(x00+x03, 7); x06 ^= R(x05+x04, 7); + x11 ^= R(x10+x09, 7); x12 ^= R(x15+x14, 7); + + x02 ^= R(x01+x00, 9); x07 ^= R(x06+x05, 9); + x08 ^= R(x11+x10, 9); x13 ^= R(x12+x15, 9); + + x03 ^= R(x02+x01,13); x04 ^= R(x07+x06,13); + x09 ^= R(x08+x11,13); x14 ^= R(x13+x12,13); + + x00 ^= R(x03+x02,18); x05 ^= R(x04+x07,18); + x10 ^= R(x09+x08,18); x15 ^= R(x14+x13,18); +#undef R + } + B[ 0] += x00; + B[ 1] += x01; + B[ 2] += x02; + B[ 3] += x03; + B[ 4] += x04; + B[ 5] += x05; + B[ 6] += x06; + B[ 7] += x07; + B[ 8] += x08; + B[ 9] += x09; + B[10] += x10; + B[11] += x11; + B[12] += x12; + B[13] += x13; + B[14] += x14; + B[15] += x15; } -bits256 scrypt_salted_multiround_hash(const void *input,size_t inputlen,const void *salt,size_t saltlen,const uint32_t nRounds) +static inline void scrypt_core(uint32_t *X, uint32_t *V, int N) { - uint32_t i; bits256 resultHash = scrypt_salted_hash(input,inputlen,salt,saltlen); - bits256 transitionalHash = resultHash; - for(i=1; ichain,&hash2,serialized,block); - if ( coin->MAXPEERS == 1 ) - hash2 = block->RO.hash2; *validp = (memcmp(hash2.bytes,block->RO.hash2.bytes,sizeof(hash2)) == 0); block->valid = *validp; char str[65]; char str2[65]; diff --git a/iguana/iguana_chains.c b/iguana/iguana_chains.c index 4e7c575dd..d96ff030f 100755 --- a/iguana/iguana_chains.c +++ b/iguana/iguana_chains.c @@ -106,11 +106,13 @@ int32_t blockhash_sha256(uint8_t *blockhashp,uint8_t *serialized,int32_t len) int32_t blockhash_scrypt(uint8_t *blockhashp,uint8_t *serialized,int32_t len) { if ( len == 80 ) - *(bits256 *)blockhashp = scrypt_blockhash(serialized); - else memset(blockhashp,0,sizeof(*blockhashp)); - //int32_t i; for (i=0; i<32; i++) - // printf("%02x",blockhashp[i]); - //printf(" scrypt\n"); + { + calc_scrypthash((uint32_t *)blockhashp,serialized); + //*(bits256 *)blockhashp = scrypt_blockhash(serialized); + //int32_t i; for (i=0; i<32; i++) + // printf("%02x",blockhashp[i]); + //printf(" scrypt\n"); + } else memset(blockhashp,0,sizeof(*blockhashp)); return(sizeof(bits256)); } @@ -135,7 +137,7 @@ bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhash for (i=0; i<32; i++) hash2.bytes[i] = tmp.bytes[31 - i]; } else return(tmp); - if ( hashalgo == blockhash_scrypt ) + /*if ( hashalgo == blockhash_scrypt ) { char str[65]; bits256 checkhash2; struct iguana_msgblock msg; struct iguana_block *block; struct iguana_info *coin; if ( (coin= iguana_coinfind(symbol)) != 0 ) @@ -147,7 +149,7 @@ bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhash printf("sethash2.(%s)\n",bits256_str(str,hash2)); } } - } + }*/ return(hash2); } @@ -313,6 +315,8 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson) else strcpy(chain->userhome,Userhome); if ( (port= extract_userpass(chain->serverport,chain->userpass,chain->symbol,chain->userhome,path,conf)) != 0 ) chain->rpcport = port; + if ( chain->serverport[0] == 0 ) + sprintf(chain->serverport,"127.0.0.1:%u",chain->rpcport); printf("COIN.%s serverport.(%s) userpass.(%s) port.%u\n",chain->symbol,chain->serverport,chain->userpass,chain->rpcport); if ( (hexstr= jstr(argjson,"pubval")) != 0 && strlen(hexstr) == 2 ) decode_hex((uint8_t *)&chain->pubtype,1,hexstr); diff --git a/iguana/main.c b/iguana/main.c index 033c3eaba..ac8ddad1d 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1151,23 +1151,22 @@ void iguana_appletests(struct supernet_info *myinfo) if ( 0 ) { char genesisblock[1024]; - iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN + //iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN iguana_chaingenesis("LTC",0,bits256_conv("12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"),genesisblock,"scrypt",1,1317972665,0x1e0ffff0,2084524493,bits256_conv("97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); // LTC + char *Str = "01000000f615f7ce3b4fc6b8f61e8f89aedb1d0852507650533a9e3b10b9bbcc30639f279fcaa86746e1ef52d3edb3c4ad8259920d509bd073605c9bf1d59983752a6b06b817bb4ea78e011d012d59d4"; + uint8_t buf[1000]; bits256 shash; char str[65]; + decode_hex(buf,(int32_t)strlen(Str)>>1,Str); + calc_scrypthash(shash.uints,buf); + printf("shash -> %s\n",bits256_str(str,shash)); getchar(); } if ( 1 ) { - //void ztest(); ztest(); - //int proofmain(void); - //proofmain(); getchar(); - //int32_t iguana_schnorr_test(void *ctx); - //iguana_schnorr_test(myinfo->ctx); getchar(); - - if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":128,\"maxpeers\":1,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":128,\"maxpeers\":128,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); - if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 )