From d5f1c653841a8ab2b75fa9ff85545a8cee5d8bec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 Jan 2017 19:47:33 +0200 Subject: [PATCH] test --- src/komodo_curve25519.h | 15 +++++++++------ src/wallet/rpcwallet.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/komodo_curve25519.h b/src/komodo_curve25519.h index 7271e3741..8bca4e7fb 100644 --- a/src/komodo_curve25519.h +++ b/src/komodo_curve25519.h @@ -962,12 +962,15 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey) int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 pubkey,uint256 sig) { - bits256 hash,checksig; - vcalc_sha256(0,hash.bytes,buf,len); - checksig = curve25519_shared(hash,*(bits256 *)&pubkey); - if ( memcmp(&checksig,&sig,sizeof(sig)) != 0 ) - return(-1); - else return(0); + bits256 hash,checksig; static uint256 zeroes; + if ( memcmp(&pubkey,&zeroes,sizeof(pubkey)) != 0 ) + { + vcalc_sha256(0,hash.bytes,buf,len); + checksig = curve25519_shared(hash,*(bits256 *)&pubkey); + if ( memcmp(&checksig,&sig,sizeof(sig)) != 0 ) + return(-1); + } + return(0); } #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4acdacea4..838c8a963 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -506,6 +506,7 @@ Value kvupdate(const Array& params, bool fHelp) haveprivkey = 0; memset(&sig,0,sizeof(sig)); memset(&privkey,0,sizeof(privkey)); + memset(&refprivkey,0,sizeof(refpubkey)); memset(&pubkey,0,sizeof(pubkey)); if ( (n= (int32_t)params.size()) >= 3 ) { @@ -544,13 +545,12 @@ Value kvupdate(const Array& params, bool fHelp) ret.push_back(Pair("error",(char *)"cant modify write once key without passphrase")); return ret; } - sig = komodo_kvsig(keyvalue,keylen+refvaluesize,privkey); - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&sig)[i]); - printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize); } + sig = komodo_kvsig(keyvalue,keylen+refvaluesize,privkey); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&sig)[i]); + printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize); } - printf("refvaluesize.%d tmpflags.%d\n",refvaluesize,tmpflags); ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL))); height = chainActive.Tip()->nHeight; if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )