BlockstreamResearch / simplicity

Simplicity is a blockchain programming language designed as an alternative to Bitcoin script.
MIT License
305 stars 45 forks source link

Per input/output transaction hash jets #224

Closed roconnor-blockstream closed 7 months ago

roconnor-blockstream commented 8 months ago

The tx-hash and *-hash jets for Elements transactions generally hash parts of the transaction across all input and or outputs. This lets you do something like CTV and APO. However, for covenants you typically want to hash all the data that corresponds to a specific input or specific output.

This PR refactors some of the existing jet specifications changing their CMRs.

apoelstra commented 8 months ago
primitive/elements/jets.c: In function 'input_utxo_hash':
primitive/elements/jets.c:1110:17: error: declaration of 'utxo' shadows a global declaration [-Werror=shadow]
 1110 |     const utxo* utxo = &env->tx->input[i].txo;
      |                 ^~~~
In file included from primitive/elements/ops.h:7,
                 from primitive/elements/jets.c:3:
primitive/elements/primitive.h:138:3: note: shadowed declaration is here
  138 | } utxo;
      |   ^~~~
roconnor-blockstream commented 8 months ago

@apoelstra This is ready for your review.

apoelstra commented 8 months ago

LGTM.

Two observations:

apoelstra commented 8 months ago

Looks like primitiveEnumJet.inc is not updated

++++ diff primitiveEnumJet.inc /nix/store/571z6kp50kw0x4v2x5vsgg3qk4qqp4jl-source/C/primitive/elements/primitiveEnumJet.inc
174a175
> INPUT_HASH,
183a185
> INPUT_UTXO_HASH,
201a204
> ISSUANCE_HASH,
329a333
> OUTPUT_HASH,
roconnor-blockstream commented 8 months ago

Should be fixed now.