This commit is contained in:
jl777
2017-01-22 19:47:33 +02:00
parent a9d3adf5a4
commit d5f1c65384
2 changed files with 14 additions and 11 deletions

View File

@@ -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) int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 pubkey,uint256 sig)
{ {
bits256 hash,checksig; bits256 hash,checksig; static uint256 zeroes;
vcalc_sha256(0,hash.bytes,buf,len); if ( memcmp(&pubkey,&zeroes,sizeof(pubkey)) != 0 )
checksig = curve25519_shared(hash,*(bits256 *)&pubkey); {
if ( memcmp(&checksig,&sig,sizeof(sig)) != 0 ) vcalc_sha256(0,hash.bytes,buf,len);
return(-1); checksig = curve25519_shared(hash,*(bits256 *)&pubkey);
else return(0); if ( memcmp(&checksig,&sig,sizeof(sig)) != 0 )
return(-1);
}
return(0);
} }
#endif #endif

View File

@@ -506,6 +506,7 @@ Value kvupdate(const Array& params, bool fHelp)
haveprivkey = 0; haveprivkey = 0;
memset(&sig,0,sizeof(sig)); memset(&sig,0,sizeof(sig));
memset(&privkey,0,sizeof(privkey)); memset(&privkey,0,sizeof(privkey));
memset(&refprivkey,0,sizeof(refpubkey));
memset(&pubkey,0,sizeof(pubkey)); memset(&pubkey,0,sizeof(pubkey));
if ( (n= (int32_t)params.size()) >= 3 ) 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")); ret.push_back(Pair("error",(char *)"cant modify write once key without passphrase"));
return ret; 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))); ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
height = chainActive.Tip()->nHeight; height = chainActive.Tip()->nHeight;
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )