Skip to content

Commit

Permalink
add cpp tests for hashing wrapper transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jan 5, 2023
1 parent 2ea4b47 commit 6bb6d60
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 2 deletions.
17 changes: 17 additions & 0 deletions app/src/crypto_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,24 @@ zxerr_t crypto_getBytesToSign(const outer_layer_tx_t *outerTxn, uint8_t *toSign,
// Hash SigningTxn
cx_sha256_final(&ctx, toSign);
#else
picohash_ctx_t ctx;
picohash_init_sha256(&ctx);

// Code - Code hash
CHECK_ZXERR(crypto_serializeCodeHash((uint8_t*) &tmpBuff, sizeof(tmpBuff)))
picohash_update(&ctx, &tmpBuff, 2);
picohash_update(&ctx, &code_hash, sizeof(code_hash));

// Data
CHECK_ZXERR(crypto_serializeData((const uint64_t)outerTxn->dataSize, (uint8_t*) &tmpBuff, sizeof(tmpBuff), &tmpSize))
picohash_update(&ctx, &tmpBuff, tmpSize);
picohash_update(&ctx, outerTxn->data, outerTxn->dataSize);

// Timestamp
CHECK_ZXERR(crypto_serializeTimestamp(&outerTxn->timestamp, (uint8_t*) &tmpBuff, sizeof(tmpBuff), &tmpSize))
picohash_update(&ctx, &tmpBuff, tmpSize);

picohash_final(&ctx, toSign);
#endif

return zxerr_ok;
Expand Down
Loading

0 comments on commit 6bb6d60

Please sign in to comment.