-
Notifications
You must be signed in to change notification settings - Fork 107
feat: insert unpadded note inputs into advice_inputs
#2232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
fdfc8bc
532fb2e
ce6e809
95ee9ea
a5bfeff
51922fe
b8b04ff
07d5876
4cb4f34
42ffa50
ef80b95
86465bd
3be5dfd
c538e70
8aefd5b
d8c3d22
24aa334
58b12b6
4d3ae8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,7 @@ end | |
| #! | ||
| #! Where: | ||
| #! - dest_ptr is the memory address to write the note inputs. | ||
| #! - NOTE_INPUTS_COMMITMENT is the sequential hash of the padded note's inputs. | ||
| #! - NOTE_INPUTS_COMMITMENT is the commitment to the note's (unpadded) inputs. | ||
| #! - INPUTS is the data corresponding to the note's inputs. | ||
| #! | ||
| #! Panics if: | ||
|
|
@@ -274,7 +274,10 @@ end | |
| #! Operand stack: [num_inputs, dest_ptr] | ||
| proc write_inputs_to_memory | ||
| # load the inputs from the advice map to the advice stack | ||
| adv.push_mapvaln | ||
| # we pad the number of inputs to the next multiple of 8 so that we can use the | ||
| # `pipe_words_to_memory` instruction with an even number of words, even though the padded zeros | ||
| # are ignored during the commitment computation | ||
| adv.push_mapvaln.8 | ||
| # OS => [NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [advice_num_inputs, [INPUT_VALUES]] | ||
|
|
||
|
|
@@ -283,12 +286,6 @@ proc write_inputs_to_memory | |
| # OS => [num_inputs, advice_num_inputs, NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [[INPUT_VALUES]] | ||
|
|
||
| # Validate the note inputs length. Round up the number of inputs to the next multiple of 8: that | ||
| # value should be equal to the length obtained from the `adv.push_mapvaln` procedure. | ||
| u32divmod.8 neq.0 add mul.8 | ||
| # OS => [rounded_up_num_inputs, advice_num_inputs, NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [[INPUT_VALUES]] | ||
bobbinth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| assert_eq.err=ERR_NOTE_INVALID_NUMBER_OF_INPUTS | ||
| # OS => [NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [[INPUT_VALUES]] | ||
|
|
@@ -303,13 +300,23 @@ proc write_inputs_to_memory | |
| # OS => [even_num_words, NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [[INPUT_VALUES]] | ||
|
|
||
| # prepare the stack for the `pipe_preimage_to_memory` procedure | ||
| # prepare the stack for the `pipe_words_to_memory` procedure | ||
| dup.6 swap | ||
| # OS => [even_num_words, dest_ptr, NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [[INPUT_VALUES]] | ||
|
|
||
| # write the inputs from the advice stack into memory | ||
| exec.mem::pipe_preimage_to_memory drop | ||
| # OS => [num_inputs, dest_ptr] | ||
| exec.mem::pipe_words_to_memory | ||
bobbinth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # OS => [C, B, A, dest_ptr', NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
| # AS => [] | ||
|
|
||
| # drop the hasher state and dest_ptr' | ||
| dropw dropw dropw drop | ||
| # OS => [NOTE_INPUTS_COMMITMENT, num_inputs, dest_ptr] | ||
|
|
||
| # compute and validate the inputs commitment (over the unpadded values) | ||
| dup.5 dup.5 swap | ||
| exec.note::compute_inputs_commitment | ||
| assert_eqw.err=ERR_NOTE_DATA_DOES_NOT_MATCH_COMMITMENT | ||
| # => [num_inputs, dest_ptr] | ||
|
||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.