@@ -2929,26 +2929,28 @@ int32_t main(void)
|
|||||||
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
||||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||||
|
|
||||||
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector<uint256> voutpubtxids)
|
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector<uint256> voutpubtxids)
|
||||||
{
|
{
|
||||||
CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
numvouts = tx.vout.size();
|
for (i=0; i<numvins; i++)
|
||||||
if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a )
|
|
||||||
{
|
{
|
||||||
for (i=0; i<numvins; i++)
|
vintxids.push_back(tx.vin[i].prevout.hash);
|
||||||
{
|
vinprevns.push_back(tx.vin[i].prevout.n);
|
||||||
vintxids.push_back(tx.vin[i].prevout.hash);
|
//fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n);
|
||||||
vinprevns.push_back(tx.vin[i].prevout.n);
|
}
|
||||||
}
|
for (i=0; i<numvouts; i++)
|
||||||
for (i=0; i<numvouts-1; i++)
|
{
|
||||||
vouts.push_back(tx.vout[i]);
|
//char destaddr[64];
|
||||||
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
//Getscriptaddress(destaddr,tx.vout[i].scriptPubKey);
|
||||||
//fprintf(stderr,"size of data.%d\n",(int32_t)data.size());
|
//fprintf(stderr,"%s %.8f ",destaddr,(double)tx.vout[i].nValue/COIN);
|
||||||
hash = Hash(data.begin(),data.end());
|
vouts.push_back(tx.vout[i]);
|
||||||
memcpy(msg,&hash,sizeof(hash));
|
}
|
||||||
return(0);
|
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
||||||
} else return(-1);
|
//fprintf(stderr,"numvins.%d numvouts.%d size of data.%d\n",numvins,numvouts,(int32_t)data.size());
|
||||||
|
hash = Hash(data.begin(),data.end());
|
||||||
|
memcpy(msg,&hash,sizeof(hash));
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
||||||
@@ -3367,7 +3369,10 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
|||||||
voutpubtxids.push_back(mypubtxid);
|
voutpubtxids.push_back(mypubtxid);
|
||||||
}
|
}
|
||||||
tx = mtx;
|
tx = mtx;
|
||||||
dilithium_Qmsghash(msg,tx,voutpubtxids);
|
dilithium_Qmsghash(msg,tx,(int32_t)voutpubtxids.size(),voutpubtxids);
|
||||||
|
//for (i=0; i<32; i++)
|
||||||
|
// fprintf(stderr,"%02x",msg[i]);
|
||||||
|
//fprintf(stderr," msg\n");
|
||||||
sig.resize(32+CRYPTO_BYTES);
|
sig.resize(32+CRYPTO_BYTES);
|
||||||
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
||||||
return(cclib_error(result,"couldnt get bigpub"));
|
return(cclib_error(result,"couldnt get bigpub"));
|
||||||
@@ -3423,7 +3428,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
numvouts = tx.vout.size();
|
numvouts = tx.vout.size();
|
||||||
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
||||||
{
|
{
|
||||||
if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 )
|
if ( dilithium_Qmsghash(msg,tx,numvouts-1,voutpubtxids) < 0 )
|
||||||
return eval->Invalid("couldnt get Qmsghash");
|
return eval->Invalid("couldnt get Qmsghash");
|
||||||
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
||||||
return eval->Invalid("couldnt get bigpub");
|
return eval->Invalid("couldnt get bigpub");
|
||||||
@@ -3432,7 +3437,15 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
||||||
return eval->Invalid("failed dilithium verify");
|
return eval->Invalid("failed dilithium verify");
|
||||||
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
||||||
|
{
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
fprintf(stderr,"%02x",msg[i]);
|
||||||
|
fprintf(stderr," vs ");
|
||||||
|
for (i=0; i<mlen; i++)
|
||||||
|
fprintf(stderr,"%02x",msg2[i]);
|
||||||
|
fprintf(stderr,"mlen.%d\n",mlen);
|
||||||
return eval->Invalid("failed dilithium msg verify");
|
return eval->Invalid("failed dilithium msg verify");
|
||||||
|
}
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
} else return eval->Invalid("failed decode Qsend");
|
} else return eval->Invalid("failed decode Qsend");
|
||||||
|
|||||||
@@ -131,21 +131,21 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag)
|
|||||||
rs->num = 0;
|
rs->num = 0;
|
||||||
retflag = 0;
|
retflag = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ( (fp= fopen("savefile","wb")) != 0 )
|
/*if ( (fp= fopen("savefile","wb")) != 0 )
|
||||||
{
|
{
|
||||||
//save_file(rs,fp,0);
|
save_file(rs,fp,0);
|
||||||
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<0x150; i++)
|
for (i=0; i<0x150; i++)
|
||||||
fprintf(stderr,"%02x",fgetc(fp));
|
fprintf(stderr,"%02x",fgetc(fp));
|
||||||
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}*/
|
||||||
roguefname(fname,rs->seed,rs->counter+1);
|
roguefname(fname,rs->seed,rs->counter+1);
|
||||||
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
||||||
}
|
//}
|
||||||
} else fprintf(stderr,"error writing (%s)\n",fname);
|
} else fprintf(stderr,"error writing (%s)\n",fname);
|
||||||
} else fprintf(stderr,"error creating (%s)\n",fname);
|
} else fprintf(stderr,"error creating (%s)\n",fname);
|
||||||
return(retflag);
|
return(retflag);
|
||||||
|
|||||||
Reference in New Issue
Block a user