Skip to content

Commit

Permalink
add shielded hash verification
Browse files Browse the repository at this point in the history
  • Loading branch information
chcmedeiros committed Sep 20, 2024
1 parent 8c8fe4d commit 5623c0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ parser_error_t _read(parser_context_t *ctx, parser_tx_t *v) {

CHECK_ERROR(validateTransactionParams(v))

CHECK_ERROR(verifyShieldedHash(ctx))
if(ctx->tx_obj->transaction.isMasp) {
CHECK_ERROR(verifyShieldedHash(ctx))
}

if (ctx->offset != ctx->bufferLen) {
return parser_unexpected_unparsed_bytes;
Expand Down
4 changes: 4 additions & 0 deletions app/src/parser_impl_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ parser_error_t verifyShieldedHash(parser_context_t *ctx) {
return parser_invalid_target_hash;
}
}

if (ctx->tx_obj->transfer.has_shielded_hash && memcmp(ctx->tx_obj->transfer.shielded_hash.ptr, tx_id_hash, HASH_LEN) != 0) {
return parser_invalid_target_hash;
}
#endif

return parser_ok;
Expand Down

0 comments on commit 5623c0d

Please sign in to comment.