This commit is contained in:
jl777
2017-01-22 14:07:09 +02:00
parent a8fadb1882
commit a9aca4da0e
2 changed files with 13 additions and 12 deletions

View File

@@ -945,18 +945,19 @@ uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_
uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase) uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase)
{ {
bits256 privkey; uint256 privkey;
conv_NXTpassword(privkey.bytes,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); conv_NXTpassword((uint8_t *)&privkey,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
return(uint256); return(privkey);
} }
bits256 komodo_kvsig(uint8_t *buf,int32_t len,bits256 privkey) uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey)
{ {
bits256 sig,hash,otherpub; bits256 sig,hash,otherpub; uint256 usig;
vcalc_sha256(0,hash.bytes,buf,len); vcalc_sha256(0,hash.bytes,buf,len);
otherpub = curve25519(hash,curve25519_basepoint9()); otherpub = curve25519(hash,curve25519_basepoint9());
sig = curve25519_shared(privkey,otherpub); sig = curve25519_shared(*(bits256 *)&privkey,otherpub);
return(sig); memcpy(&usig,&sig,sizeof(usig));
return(usig);
} }
int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,bits256 pubkey,bits256 sig) int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,bits256 pubkey,bits256 sig)

View File

@@ -86,7 +86,7 @@ uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
{ {
static uint256 zeroes; static uint256 zeroes;
uint32_t flags; bits256 pubkey,refpubkey,sig; int32_t i,transferflag,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,valuebuf[IGUANA_MAXSCRIPTSIZE]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,transferflag,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,valuebuf[IGUANA_MAXSCRIPTSIZE]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
iguana_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize); iguana_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize);
iguana_rwnum(0,&opretbuf[5],sizeof(height),&height); iguana_rwnum(0,&opretbuf[5],sizeof(height),&height);
@@ -98,19 +98,19 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
if ( value >= fee ) if ( value >= fee )
{ {
coresize = (int32_t)(sizeof(flags)+sizeof(height)+sizeof(keylen)+sizeof(valuesize)+keylen+valuesize+1); coresize = (int32_t)(sizeof(flags)+sizeof(height)+sizeof(keylen)+sizeof(valuesize)+keylen+valuesize+1);
if ( opretlen == coresize || opretlen == coresize+sizeof(bits256) || opretlen == coresize+2*sizeof(bits256) ) if ( opretlen == coresize || opretlen == coresize+sizeof(uint256) || opretlen == coresize+2*sizeof(uint256) )
{ {
memset(&pubkey,0,sizeof(pubkey)); memset(&pubkey,0,sizeof(pubkey));
memset(&sig,0,sizeof(sig)); memset(&sig,0,sizeof(sig));
if ( (haspubkey= (opretlen >= coresize+sizeof(bits256))) != 0 ) if ( (haspubkey= (opretlen >= coresize+sizeof(uint256))) != 0 )
{ {
for (i=0; i<32; i++) for (i=0; i<32; i++)
((uint8_t *)&pubkey)[i] = opretbuf[coresize+i]; ((uint8_t *)&pubkey)[i] = opretbuf[coresize+i];
} }
if ( (hassig= (opretlen == coresize+sizeof(bits256)*2)) != 0 ) if ( (hassig= (opretlen == coresize+sizeof(uint256)*2)) != 0 )
{ {
for (i=0; i<32; i++) for (i=0; i<32; i++)
((uint8_t *)&sig)[i] = opretbuf[coresize+sizeof(bits256)+i]; ((uint8_t *)&sig)[i] = opretbuf[coresize+sizeof(uint256)+i];
} }
if ( komodo_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,valuebuf,key,keylen) >= 0 ) if ( komodo_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,valuebuf,key,keylen) >= 0 )
{ {