Skip to content
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

[NCC-Y7H] Create compute_function_id helper which enforces minimal TLV encoding #2154

Merged
merged 17 commits into from
Jan 11, 2024

Conversation

vicsn
Copy link
Contributor

@vicsn vicsn commented Nov 6, 2023

Motivation

As defense in depth, in case we allow custom program_id's in the future, it is good practice to encode the length of each input. Some implementation notes:

  • requires resampling
  • we could also encode a "type" prefix as extra defense in depth, but the function_id code lives quite separate from other code.
  • I did not spot other invocations of A::hash which would warrant an extra TLV encoding. There might be a problem if end-users hash containers themselves (in Leo or Aleo instructions), but then it is up to them to implement TLV encoding.
  • If this design looks good we could rename the program/id folder to program/program_id to distinguish it from program/function_id.
  • Technically we don't have to pass in network_id when in console mode, as it can be derived from the type, but I do it anyway to be consistent with the Circuit implementation

Test Plan

I did not add more tests.

@vicsn vicsn requested a review from raychu86 November 6, 2023 09:45
@vicsn vicsn force-pushed the function_id_tlv_encoding branch from e0e368d to b9abacc Compare November 6, 2023 11:19
@howardwu howardwu changed the base branch from testnet3 to mainnet November 10, 2023 02:47
Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
Signed-off-by: Howard Wu <9260812+howardwu@users.noreply.github.com>
@howardwu howardwu merged commit 0a6bae7 into mainnet Jan 11, 2024
@howardwu howardwu deleted the function_id_tlv_encoding branch January 11, 2024 00:48
@raychu86 raychu86 changed the title [NCC Y7H] Create compute_function_id helper which enforces minimal TLV encoding [NCC-Y7H] Create compute_function_id helper which enforces minimal TLV encoding Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants