Skip to content

Commit

Permalink
refactor: Rename jet_j -> jet::j
Browse files Browse the repository at this point in the history
Simfony programs look more like Rust if we write jet::j with the pseudo
namespace `jet` for jets such as `j`.

Because `jet::` includes alphanumeric characters, namely `::`,
`identifier` is automatically separated from `jet` in the PEST grammar.

The important changes happen inside src/. The rest is just adapting
existing examples or documentation.
  • Loading branch information
uncomputable committed Jul 27, 2024
1 parent 734d167 commit 7a17bab
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 146 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ let a: u32 = 10;
let b = {
let c: u32 = 2;
let d: u32 = 3;
assert!(jet_eq_32(a, 10)); // Use variables from outer copes
assert!(jet::eq_32(a, 10)); // Use variables from outer copes
let a: u32 = 7; // Shadow variables from outer scopes
jet_max_32(jet_max_32(c, d), a) // Missing ; because the block returns a value
jet::max_32(jet::max_32(c, d), a) // Missing ; because the block returns a value
};
assert!(jet_eq_32(b, 7));
assert!(jet::eq_32(b, 7));
```

Take a look at the [example programs](https://github.com/BlockstreamResearch/simfony/tree/master/example_progs).
Expand Down
2 changes: 1 addition & 1 deletion doc/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ If `j` is the name of a jet of type B → C

If Γ ⊩ `b`: B

Then Γ ⊩ `jet_j b`: C
Then Γ ⊩ `jet::j b`: C

## Chaining

Expand Down
2 changes: 1 addition & 1 deletion doc/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ If `j` is the name of a jet of type B → C

If Ctx(Ξ) ⊩ `b`: B

Then ⟦`jet_j b`⟧Ξ = comp ⟦`b`⟧Ξ jet_j: A → C
Then ⟦`jet::j b`⟧Ξ = comp ⟦`b`⟧Ξ j: A → C

## Chaining

Expand Down
6 changes: 3 additions & 3 deletions example_progs/add.simf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn main() {
let a: u32 = 2;
let b: u32 = 3;
let (carry, res): (bool, u32) = jet_add_32(a, b);
let add_res: (bool, u32) = jet_add_32(10, 20);
let (carry, res): (bool, u32) = jet::add_32(a, b);
let add_res: (bool, u32) = jet::add_32(10, 20);
let (carry2, res3): (bool, u32) = add_res;
assert!(jet_eq_32(res3, 30));
assert!(jet::eq_32(res3, 30));
}
6 changes: 3 additions & 3 deletions example_progs/array.simf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let []: [u1; 0] = a;

let [d0, d1, d2]: [u8; 3] = d;
assert!(jet_eq_8(d0, 1));
assert!(jet_eq_8(d1, 2));
assert!(jet_eq_8(d2, 3));
assert!(jet::eq_8(d0, 1));
assert!(jet::eq_8(d1, 2));
assert!(jet::eq_8(d2, 3));
}
4 changes: 2 additions & 2 deletions example_progs/cat.simf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn main() {
let ab: u16 = <(u8, u8)>::into((0x10, 0x01));
let c: u16 = 0x1001;
assert!(jet_eq_16(ab, c));
assert!(jet::eq_16(ab, c));
let ab: u8 = <(u4, u4)>::into((0b1011, 0b1101));
let c: u8 = 0b10111101;
assert!(jet_eq_8(ab, c));
assert!(jet::eq_8(ab, c));
}
2 changes: 1 addition & 1 deletion example_progs/checksigfromstackverify.simf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ fn main() {
let pk: u256 = 0xf9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9;
let msg: u256 = witness("msg");
let sig: [u8; 64] = witness("sig");
jet_bip_0340_verify((pk, msg), sig);
jet::bip_0340_verify((pk, msg), sig);
}
22 changes: 11 additions & 11 deletions example_progs/ctv.simf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* that they want to commit.
*/
fn main() {
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_version());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_lock_time());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_script_sigs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_num_inputs());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_sequences_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_num_outputs());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_outputs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_current_index());
let ctv_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::version());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::lock_time());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_script_sigs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::num_inputs());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_sequences_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::num_outputs());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::outputs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::current_index());
let ctv_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);

let expected_hash: u256 = 0xae3d019b30529c6044d2b3d7ee2e0ee5db51a7f05ed5db8f089cd5d455f1fc5d;
assert!(jet_eq_256(ctv_hash, expected_hash));
assert!(jet::eq_256(ctv_hash, expected_hash));
}
8 changes: 4 additions & 4 deletions example_progs/function.simf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn checked_add_32(a: u32, b: u32) -> u32 {
let (carry, sum): (bool, u32) = jet_add_32(a, b);
assert!(<u1>::into(jet_complement_1(<bool>::into(carry))));
let (carry, sum): (bool, u32) = jet::add_32(a, b);
assert!(<u1>::into(jet::complement_1(<bool>::into(carry))));
sum
}

Expand All @@ -19,9 +19,9 @@ fn third() -> u32 {
fn main() {
let sum: u32 = checked_add_32(42, 1);
let expected: u32 = 43;
assert!(jet_eq_32(expected, sum));
assert!(jet::eq_32(expected, sum));

let third: u32 = third();
let expected: u32 = 3;
assert!(jet_eq_32(expected, third));
assert!(jet::eq_32(expected, third));
}
6 changes: 3 additions & 3 deletions example_progs/match.simf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
fn main() {
let bit: bool = match Left(11) {
Left(x: u32) => jet_le_32(10, x),
Right(y: u32) => jet_le_32(y, 10),
Left(x: u32) => jet::le_32(10, x),
Right(y: u32) => jet::le_32(y, 10),
};
assert!(bit);
let bit: bool = match Some(11) {
Some(x: u32) => jet_le_32(10, x),
Some(x: u32) => jet::le_32(10, x),
None => false,
};
assert!(bit);
Expand Down
4 changes: 2 additions & 2 deletions example_progs/nesting.simf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ fn main() {
let v4: u32 = 1;
let v5: u32 = 2;
let v6: u32 = 3;
let v7: u32 = jet_max_32(v4, jet_max_32(v5, v6));
let v7: u32 = jet::max_32(v4, jet::max_32(v5, v6));
v4
};
let res: u32 = 1;
assert!(jet_eq_32(res, v1));
assert!(jet::eq_32(res, v1));
}
6 changes: 3 additions & 3 deletions example_progs/recursive-covenant.simf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* in the first output of the spending transaction.
*/
fn main () {
let this_hash: u256 = jet_current_script_hash();
let spend_hash: u256 = unwrap(jet_output_script_hash(0));
assert!(jet_eq_256(this_hash, spend_hash));
let this_hash: u256 = jet::current_script_hash();
let spend_hash: u256 = unwrap(jet::output_script_hash(0));
assert!(jet::eq_256(this_hash, spend_hash));
}
10 changes: 5 additions & 5 deletions example_progs/scopes.simf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ fn main() {
let v3: u32 = {
let v4: u32 = 2;
let v5: u32 = 3;
assert!(jet_eq_32(v7, 10)); /* Can use upper scope variables here.*/
assert!(jet::eq_32(v7, 10)); /* Can use upper scope variables here.*/
let v7: u32 = 7; /* Can also shadow the upper scope here.*/
jet_max_32(jet_max_32(v4, v5),v7) /* Rust like, missing ; here is the return type of expression.*/
jet::max_32(jet::max_32(v4, v5),v7) /* Rust like, missing ; here is the return type of expression.*/
};
assert!(jet_eq_32(v7, 10)); /* Upper scope is same just like regular Programming languages*/
jet_min_32(v7, v3) /*Return value of v2 block*/
assert!(jet::eq_32(v7, 10)); /* Upper scope is same just like regular Programming languages*/
jet::min_32(v7, v3) /*Return value of v2 block*/
};
v2
};
assert!(jet_eq_32(7, v1));
assert!(jet::eq_32(7, v1));
}
126 changes: 63 additions & 63 deletions example_progs/sighash_all.simf
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,73 @@
* the value that was returned from the dedicated jet.
*/
fn main () {
// jet_sig_all_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tx_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tap_env_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_current_index());
let sig_all_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256= jet_sig_all_hash();
assert!(jet_eq_256(sig_all_hash, expected));
// jet::sig_all_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tx_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tap_env_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::current_index());
let sig_all_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256= jet::sig_all_hash();
assert!(jet::eq_256(sig_all_hash, expected));

// jet_tx_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_version());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_lock_time());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_inputs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_outputs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuances_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_surjection_proofs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_utxos_hash());
let tx_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_tx_hash();
assert!(jet_eq_256(tx_hash, expected));
// jet::tx_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::version());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::lock_time());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::inputs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::outputs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuances_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_surjection_proofs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_utxos_hash());
let tx_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::tx_hash();
assert!(jet::eq_256(tx_hash, expected));

// jet_inputs_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_outpoints_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_sequences_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_annexes_hash());
let inputs_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_inputs_hash();
assert!(jet_eq_256(inputs_hash, expected));
// jet::inputs_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_outpoints_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_sequences_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_annexes_hash());
let inputs_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::inputs_hash();
assert!(jet::eq_256(inputs_hash, expected));

// jet_outputs_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_amounts_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_nonces_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_scripts_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_range_proofs_hash());
let outputs_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_outputs_hash();
assert!(jet_eq_256(outputs_hash, expected));
// jet::outputs_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_amounts_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_nonces_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_scripts_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_range_proofs_hash());
let outputs_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::outputs_hash();
assert!(jet::eq_256(outputs_hash, expected));

// jet_issuances_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuance_asset_amounts_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuance_token_amounts_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuance_range_proofs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuance_blinding_entropy_hash());
let issuances_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_issuances_hash();
assert!(jet_eq_256(issuances_hash, expected));
// jet::issuances_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuance_asset_amounts_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuance_token_amounts_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuance_range_proofs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuance_blinding_entropy_hash());
let issuances_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::issuances_hash();
assert!(jet::eq_256(issuances_hash, expected));

// jet_input_utxos_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_amounts_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_scripts_hash());
let input_utxos_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_input_utxos_hash();
assert!(jet_eq_256(input_utxos_hash, expected));
// jet::input_utxos_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_amounts_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_scripts_hash());
let input_utxos_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::input_utxos_hash();
assert!(jet::eq_256(input_utxos_hash, expected));

// jet_tap_env_hash
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tapleaf_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tappath_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_internal_key());
let tap_env_hash: u256 = jet_sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet_tap_env_hash();
assert!(jet_eq_256(tap_env_hash, expected));
// jet::tap_env_hash
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tapleaf_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tappath_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::internal_key());
let tap_env_hash: u256 = jet::sha_256_ctx_8_finalize(ctx);
let expected: u256 = jet::tap_env_hash();
assert!(jet::eq_256(tap_env_hash, expected));
}
26 changes: 13 additions & 13 deletions example_progs/sighash_all_anyprevoutanyscript.simf
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
* SIGHASH_ALL | SIGHASH_ANYPREVOUTANYSCRIPT.
*/
fn main() {
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
// Blockchain
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
// Transaction
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_version());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_lock_time());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tap_env_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::version());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::lock_time());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tap_env_hash());
// Current input without outpoint, amounts or scriptPubKey
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_current_sequence());
let ctx: Ctx8 = jet_annex_hash(ctx, jet_current_annex_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::current_sequence());
let ctx: Ctx8 = jet::annex_hash(ctx, jet::current_annex_hash());
// All outputs
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_outputs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_issuances_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_output_surjection_proofs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::outputs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::issuances_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::output_surjection_proofs_hash());
// No current index
// Message
let msg: u256 = jet_sha_256_ctx_8_finalize(ctx);
let msg: u256 = jet::sha_256_ctx_8_finalize(ctx);

let pk: u256 = 0xf9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9;
let sig: [u8; 64] = witness("sig");
jet_bip_0340_verify((pk, msg), sig);
jet::bip_0340_verify((pk, msg), sig);
}
22 changes: 11 additions & 11 deletions example_progs/sighash_none.simf
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
* SIGHASH_NONE.
*/
fn main() {
let ctx: Ctx8 = jet_sha_256_ctx_8_init();
let ctx: Ctx8 = jet::sha_256_ctx_8_init();
// Blockchain
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::genesis_block_hash());
// Transaction
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_version());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_lock_time());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_tap_env_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::version());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::lock_time());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::tap_env_hash());
// All inputs
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_inputs_hash());
let ctx: Ctx8 = jet_sha_256_ctx_8_add_32(ctx, jet_input_utxos_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::inputs_hash());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_32(ctx, jet::input_utxos_hash());
// No outputs
// Current index
let ctx: Ctx8 = jet_sha_256_ctx_8_add_4(ctx, jet_current_index());
let ctx: Ctx8 = jet::sha_256_ctx_8_add_4(ctx, jet::current_index());
// Message
let msg: u256 = jet_sha_256_ctx_8_finalize(ctx);
let msg: u256 = jet::sha_256_ctx_8_finalize(ctx);

let pk: u256 = 0xf9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9;
let sig: [u8; 64] = witness("sig");
jet_bip_0340_verify((pk, msg), sig);
jet::bip_0340_verify((pk, msg), sig);
}
Loading

0 comments on commit 7a17bab

Please sign in to comment.