Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
fe4695e62d
  1. 8
      crypto777/curve25519.c
  2. 18
      iguana/pangea_api.c

8
crypto777/curve25519.c

@ -1786,9 +1786,9 @@ uint64_t acct777_sign(struct acct777_sig *sig,bits256 privkey,bits256 otherpubke
sig->sigbits = shared = curve25519(privkey,otherpubkey);
memset(buf,0,sizeof(buf));
acct777_rwsig(1,buf,sig);
int32_t i; for (i=0; i<sizeof(buf); i++)
printf("%02x ",buf[i]);
printf(" <<<<<<<<< SIGN.%d allocsize.%d signer.%llu t%u\n",datalen,sig->allocsize,(long long)sig->signer64bits,sig->timestamp);
//int32_t i; for (i=0; i<sizeof(buf); i++)
// printf("%02x ",buf[i]);
//printf(" <<<<<<<<< SIGN.%d allocsize.%d signer.%llu t%u\n",datalen,sig->allocsize,(long long)sig->signer64bits,sig->timestamp);
//char str[65]; printf("shared.(%s) crc.%u datalen.%d\n",bits256_str(str,shared),calc_crc32(0,buf,sizeof(buf)),datalen);
vcalc_sha256cat(sig->sigbits.bytes,buf,sizeof(buf),serialized,datalen);
//printf(" calcsig.%llx pubkey.%llx signer.%llu | t%u crc.%08x len.%d shared.%llx <- %llx * %llx\n",(long long)sig->sigbits.txid,(long long)sig->pubkey.txid,(long long)sig->signer64bits,timestamp,calc_crc32(0,serialized,datalen),datalen,(long long)shared.txid,(long long)privkey.txid,(long long)otherpubkey.txid);
@ -1801,7 +1801,7 @@ uint64_t acct777_validate(struct acct777_sig *sig,bits256 privkey,bits256 pubkey
datalen = (int32_t)(sig->allocsize - sizeof(*sig));
checksig = *sig;
serialized = (uint8_t *)((long)sig + sizeof(*sig));
{ int32_t i; for (i=0; i<datalen; i++) printf("%02x",serialized[i]); printf(" VALIDATE.%d?\n",datalen); }
//{ int32_t i; for (i=0; i<datalen; i++) printf("%02x",serialized[i]); printf(" VALIDATE.%d?\n",datalen); }
acct777_sign(&checksig,privkey,pubkey,sig->timestamp,serialized,datalen);
if ( memcmp(checksig.sigbits.bytes,sig->sigbits.bytes,sizeof(checksig.sigbits)) != 0 )
{

18
iguana/pangea_api.c

@ -565,26 +565,20 @@ ZERO_ARGS(pangea,lobby)
}
else
{
// uint8_t tmp[sizeof(pm->sig)];
bits256 hash;
int32_t datalen; uint8_t *serialized; uint8_t tmp[sizeof(pm->sig)];
pm = (struct pangea_msghdr *)buf;
//acct777_rwsig(0,(void *)&pm->sig,(void *)&pm->sig);
//memcpy(&pm->sig,tmp,sizeof(pm->sig));
iguana_rwbignum(0,pm->sig.pubkey.bytes,sizeof(bits256),hash.bytes);
//iguana_rwbignum(0,pm->tablehash.bytes,sizeof(bits256),hash.bytes);
//pm->tablehash = hash;
int32_t datalen; uint8_t *serialized;
acct777_rwsig(0,(void *)&pm->sig,(void *)tmp);
memcpy(&pm->sig,tmp,sizeof(pm->sig));
datalen = len - (int32_t)sizeof(pm->sig);
serialized = (void *)((long)pm + sizeof(pm->sig));
if ( pangea_validate(pm,acct777_msgprivkey(serialized,datalen),hash) == 0 )
printf("VALIDATED!\n");
if ( pangea_validate(pm,acct777_msgprivkey(serialized,datalen),pm->sig.pubkey) == 0 )
printf("<<<<<<<<<<<<< sigsize.%ld VALIDATED [%ld] len.%d\n",sizeof(pm->sig),(long)serialized-(long)pm,datalen);
else
{
int32_t i; char str[65],str2[65];
for (i=0; i<datalen; i++)
printf("%02x",serialized[i]);
printf("<<<<<<<<<<<<< sigsize.%ld SIG ERROR [%ld] len.%d (%s + %s)\n",sizeof(pm->sig),(long)serialized-(long)pm,datalen,bits256_str(str,acct777_msgprivkey(serialized,datalen)),bits256_str(str2,hash));
printf("<<<<<<<<<<<<< sigsize.%ld SIG ERROR [%ld] len.%d (%s + %s)\n",sizeof(pm->sig),(long)serialized-(long)pm,datalen,bits256_str(str,acct777_msgprivkey(serialized,datalen)),bits256_str(str2,pm->sig.pubkey));
}
}
flag++;

Loading…
Cancel
Save