diff --git a/src/komodo_curve25519.h b/src/komodo_curve25519.h index 1bcb67382..541e4447c 100644 --- a/src/komodo_curve25519.h +++ b/src/komodo_curve25519.h @@ -945,18 +945,19 @@ uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_ uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase) { - bits256 privkey; - conv_NXTpassword(privkey.bytes,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); - return(uint256); + uint256 privkey; + conv_NXTpassword((uint8_t *)&privkey,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); + 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); otherpub = curve25519(hash,curve25519_basepoint9()); - sig = curve25519_shared(privkey,otherpub); - return(sig); + sig = curve25519_shared(*(bits256 *)&privkey,otherpub); + memcpy(&usig,&sig,sizeof(usig)); + return(usig); } int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,bits256 pubkey,bits256 sig) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 274d723e1..38ea99bc1 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -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) { 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[3],sizeof(valuesize),&valuesize); 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 ) { 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(&sig,0,sizeof(sig)); - if ( (haspubkey= (opretlen >= coresize+sizeof(bits256))) != 0 ) + if ( (haspubkey= (opretlen >= coresize+sizeof(uint256))) != 0 ) { for (i=0; i<32; 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++) - ((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 ) {