Skip to content

Commit

Permalink
chore: update outdated references to note_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbinth committed Jun 27, 2024
1 parent 7aefa76 commit 3cbce40
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/architecture/transactions/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ To import the transaction procedures set `use.miden::tx` at the beginning of the
| Procedure name | Inputs | Outputs | Context | Description |
|--------------------------|------------------|-------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `get_block_number` | `[]` | `[num]` | account, note | <ul> <li>Returns the block number `num` of the last known block at the time of transaction execution. |
| `get_block_hash` | `[]` | `[H]` | account, note | <ul> <li>Returns the block hash `H` of the last known block at the time of transaction execution.</li> </ul> |
| `get_input_notes_hash` | `[]` | `[COM]` | account, note | <ul> <li>Returns the input notes hash `COM`. </li><li>This is computed as a sequential hash of (nullifier, script_root) tuples over all input notes. </li> </ul> |
| `get_output_notes_hash` | `[0, 0, 0, 0]` | `[COM]` | account, note | <ul> <li>Returns the output notes hash `COM`. </li><li>This is computed as a sequential hash of (note_hash, note_metadata) tuples over all output notes. </li> </ul> |
| `get_block_hash` | `[]` | `[H]` | account, note | <ul> <li>Returns the block hash `H` of the last known block at the time of transaction execution.</li> </ul> |
| `get_input_notes_hash` | `[]` | `[COM]` | account, note | <ul> <li>Returns the input notes hash `COM`. </li><li>This is computed as a sequential hash of (nullifier, empty_word_or_note_hash) tuples over all input notes. The `empty_word_or_notes_hash` functions as a flag, if the value is set to zero, then the notes are authenticated by the transaction kernel. If the value is non-zero, then note authentication will be delayed to the batch/block kernel. The delayed authentication allows a transaction to consume a public note that is not yet included to a block. </li> </ul> |
| `get_output_notes_hash` | `[0, 0, 0, 0]` | `[COM]` | account, note | <ul> <li>Returns the output notes hash `COM`. </li><li>This is computed as a sequential hash of (note_id, note_metadata) tuples over all output notes. </li> </ul> |
| `create_note` | `[ASSET, tag, RECIPIENT]` | `[ptr]` | account | <ul> <li>Creates a new note and returns a pointer to the memory address at which the note is stored.</li><li> `ASSET` is the asset to be included in the note. </li><li>`tag` is the tag to be included in the note. `RECIPIENT` is the recipient of the note.</li><li> `ptr` is the pointer to the memory address at which the note is stored.</li> </ul> |


Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export.get_input_notes_commitment
# => [COM]
end

#! Returns the output notes hash. This is computed as a sequential hash of (note_hash, note_metadata)
#! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata)
#! tuples over all output notes.
#!
#! Inputs: [0, 0, 0, 0]
Expand Down
4 changes: 2 additions & 2 deletions miden-lib/asm/miden/kernels/tx/memory.masm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const.CONSUMED_NOTE_DATA_SECTION_OFFSET=1064960
const.CONSUMED_NOTE_NUM_PTR=1048576

# The offsets at which data of a consumed note is stored relative to the start of its data segment
const.CONSUMED_NOTE_HASH_OFFSET=0
const.CONSUMED_NOTE_ID_OFFSET=0
const.CONSUMED_NOTE_CORE_DATA_OFFSET=1
const.CONSUMED_NOTE_SERIAL_NUM_OFFSET=1
const.CONSUMED_NOTE_SCRIPT_ROOT_OFFSET=2
Expand All @@ -151,7 +151,7 @@ const.CONSUMED_NOTE_ASSETS_OFFSET=8
const.CREATED_NOTE_SECTION_OFFSET=4194304

# The offsets at which data of a created note is stored relative to the start of its data segment.
const.CREATED_NOTE_HASH_OFFSET=0
const.CREATED_NOTE_ID_OFFSET=0
const.CREATED_NOTE_METADATA_OFFSET=1
const.CREATED_NOTE_RECIPIENT_OFFSET=2
const.CREATED_NOTE_ASSETS_HASH_OFFSET=3
Expand Down
20 changes: 10 additions & 10 deletions miden-lib/asm/miden/kernels/tx/note.masm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const.ERR_NOTE_TOO_MANY_ASSETS=0x0002002A
# =================================================================================================

# The diff between the memory address after first mem_stream operation and the next target when
# generating the consumed notes commitment. Must be NOTE_MEM_SIZE - 2;
# generating the output notes commitment. Must be NOTE_MEM_SIZE - 2;
const.OUTPUT_NOTE_HASHING_MEM_DIFF=510

# INPUT NOTE PROCEDURES
Expand Down Expand Up @@ -219,20 +219,20 @@ proc.compute_output_note_assets_hash
# => []
end

#! Computes the hash of an output note located at the specified memory address.
#! Computes the ID of an output note located at the specified memory address.
#!
#! The hash is computed as follows:
#! The note ID is computed as follows:
#! - we define, recipient =
#! hash(hash(hash(serial_num, [0; 4]), script_hash), input_hash)
#! - we then compute the output note hash as:
#! hash(recipient, assets_hash)
#!
#! Stack: [note_data_ptr]
#! Output: [OUTPUT_NOTE_HASH]
#! Output: [NOTE_ID]
#!
#! - note_data_ptr is a pointer to the data section of the output note.
#! - OUTPUT_NOTE_HASH is the hash of the output note located at note_data_ptr.
proc.compute_output_note_hash
#! - NOTE_ID is the ID of the output note located at note_data_ptr.
proc.compute_output_note_id
# pad capacity elements of hasher
padw

Expand All @@ -250,7 +250,7 @@ proc.compute_output_note_hash
end

#! Computes a commitment to the output notes. This is computed as a sequential hash of
#! (note_hash, note_metadata) tuples.
#! (note_id, note_metadata) tuples.
#!
#! Stack: []
#! Output: [OUTPUT_NOTES_COMMITMENT]
Expand Down Expand Up @@ -280,14 +280,14 @@ export.compute_output_notes_commitment
# loop and hash output notes
while.true
# compute output note hash (this also computes the note's asset hash)
dup.12 exec.compute_output_note_hash
# => [NOTE_HASH, PERM, PERM, PERM, note_ptr, end_ptr, ...]
dup.12 exec.compute_output_note_id
# => [NOTE_ID, PERM, PERM, PERM, note_ptr, end_ptr, ...]

# drop output note hash from stack
dropw
# => [PERM, PERM, PERM, note_ptr, end_ptr, ...]

# permute over (note_hash, note_metadata)
# permute over (note_id, note_metadata)
mem_stream hperm
# => [PERM, PERM, PERM, note_ptr + 2, end_ptr, ...]

Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/miden/kernels/tx/tx.masm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export.memory::get_blk_num->get_block_number
#! - INPUT_NOTES_COMMITMENT is the input notes commitment hash.
export.memory::get_input_notes_commitment

#! Returns the output notes hash. This is computed as a sequential hash of (note_hash, note_metadata)
#! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata)
#! tuples over all output notes.
#!
#! Inputs: []
Expand Down
2 changes: 1 addition & 1 deletion miden-lib/asm/miden/tx.masm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export.get_input_notes_commitment
# => [INPUT_NOTES_COMMITMENT]
end

#! Returns the output notes hash. This is computed as a sequential hash of (note_hash, note_metadata)
#! Returns the output notes hash. This is computed as a sequential hash of (note_id, note_metadata)
#! tuples over all output notes.
#!
#! Inputs: [0, 0, 0, 0]
Expand Down

0 comments on commit 3cbce40

Please sign in to comment.