Browse Source

+ iguana_rwjoinsplit: add proof_size param

blackjok3r
DeckerSU 6 years ago
parent
commit
30c61f0d1d
  1. 16
      iguana/iguana_msg.c
  2. 4
      iguana/iguana_sign.c

16
iguana/iguana_msg.c

@ -600,7 +600,7 @@ int32_t iguana_rwvout(int32_t rwflag,struct OS_memspace *mem,uint8_t *serialized
return(len); return(len);
} }
int32_t iguana_rwjoinsplit(int32_t rwflag,uint8_t *serialized,struct iguana_msgjoinsplit *msg) int32_t iguana_rwjoinsplit(int32_t rwflag,uint8_t *serialized,struct iguana_msgjoinsplit *msg, uint32_t proof_size)
{ {
int32_t len = 0; int32_t len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->vpub_old),&msg->vpub_old); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->vpub_old),&msg->vpub_old);
@ -620,9 +620,9 @@ int32_t iguana_rwjoinsplit(int32_t rwflag,uint8_t *serialized,struct iguana_msgj
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->vmacs[0]),msg->vmacs[0].bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->vmacs[0]),msg->vmacs[0].bytes);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->vmacs[1]),msg->vmacs[1].bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->vmacs[1]),msg->vmacs[1].bytes);
if ( rwflag == 1 ) if ( rwflag == 1 )
memcpy(&serialized[len],msg->zkproof,sizeof(msg->zkproof)); memcpy(&serialized[len],msg->zkproof,proof_size);
else memcpy(msg->zkproof,&serialized[len],sizeof(msg->zkproof)); else memcpy(msg->zkproof,&serialized[len],proof_size);
len += sizeof(msg->zkproof); len += proof_size;
return(len); return(len);
} }
@ -697,8 +697,14 @@ int32_t iguana_rwtx(struct supernet_info *myinfo,uint8_t zcash,int32_t rwflag,st
len += iguana_rwvarint32(rwflag,&serialized[len],&numjoinsplits); len += iguana_rwvarint32(rwflag,&serialized[len],&numjoinsplits);
if ( numjoinsplits > 0 ) if ( numjoinsplits > 0 )
{ {
// for version 4 the ZK proof size is 192, otherwise 296
uint32_t zksnark_proof_size = ZKSNARK_PROOF_SIZE;
if (msg->version >= 4) {
zksnark_proof_size = GROTH_PROOF_SIZE;
}
for (i=0; i<numjoinsplits; i++) for (i=0; i<numjoinsplits; i++)
len += iguana_rwjoinsplit(rwflag,&serialized[len],&joinsplit); len += iguana_rwjoinsplit(rwflag,&serialized[len],&joinsplit,zksnark_proof_size);
if ( rwflag != 0 ) if ( rwflag != 0 )
{ {
memset(joinsplitpubkey,0,sizeof(joinsplitpubkey)); // for now memset(joinsplitpubkey,0,sizeof(joinsplitpubkey)); // for now

4
iguana/iguana_sign.c

@ -33,8 +33,10 @@ const unsigned char ZCASH_SIG_HASH_SAPLING_PERSONALIZATION[16] =
const unsigned char ZCASH_SIG_HASH_OVERWINTER_PERSONALIZATION[16] = const unsigned char ZCASH_SIG_HASH_OVERWINTER_PERSONALIZATION[16] =
{ 'Z','c','a','s','h','S','i','g','H','a','s','h', '\x19', '\x1B', '\xA8', '\x5B' }; { 'Z','c','a','s','h','S','i','g','H','a','s','h', '\x19', '\x1B', '\xA8', '\x5B' };
// make sure coinbase outputs are matured
int32_t iguana_rwjoinsplit(int32_t rwflag,uint8_t *serialized,struct iguana_msgjoinsplit *msg, uint32_t proof_size); // defined in iguana_msg.c
// make sure coinbase outputs are matured
int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *serialized,struct iguana_msgvin *msg) int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *serialized,struct iguana_msgvin *msg)
{ {
int32_t p2shlen,len = 0; uint32_t tmp; int32_t p2shlen,len = 0; uint32_t tmp;

Loading…
Cancel
Save