Skip to content

Commit

Permalink
Require lexical order for Context Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Jan 22, 2024
1 parent 7cd4554 commit 8f85f16
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tips/TIP-0045/tip-0045.md
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,12 @@ The following criteria defines whether a payload passes the syntactical validati
- Context Inputs:
- `Context Inputs Count` must be `0 ≤ x ≤ Max Inputs Count`.
- `Context Input Type` must denote an allowed input type, listed in section [Context Inputs](#context-inputs).
- The Context Inputs must be lexically ordered and unique, both based on the following comparison criteria:
- `Context Input Type` as the first criteria for all Context Inputs.
- `Index` as the second criteria for _Reward Inputs_.
- `Account ID` as the second criteria for _Block Issuance Credit Inputs_.
- There must be zero or one _Commitment Input_.
- All _Reward Inputs_ must reference a different `Index` and it must hold that: `Index < Inputs Count`.
- All _Block Issuance Credit Inputs_ must reference a different `Account ID`.
- For each `Index` in the _Reward Inputs_ it must hold that: `Index < Inputs Count`.
- Outputs:
- `Outputs Count` must be `0 < x ≤ Max Outputs Count`.
- For each output the following must be true:
Expand Down Expand Up @@ -1268,6 +1271,12 @@ used deposit address. Ed25519 addresses are not meant to be used like email addr
side mismatch. While this would reduce the size of a transaction, it would make it impossible to debug the reason for
having an invalid signature and transaction. With the current solution we intend to optimize for ease of development.
- Uniqueness of all inputs is kept as it prevents introducing double spends in the same transaction.
- The sorting criteria for _Commitment Inputs_ is only based on their _Context Input Type_ and does not take into
account the _Commitment ID_, which allows for an optimization when determining whether there are zero or one
_Commitment Inputs_. An algorithm checking lexical order and uniqueness will detect the violation of the desired "at
most one" semantic as soon as two or more _Commitment Inputs_ are present, since those would be considered duplicates.
- Requiring lexical order in various places (such as for _Context Inputs_) is mostly an optimization in order to allow
for efficient duplicate detection.

# Test Vectors

Expand Down

0 comments on commit 8f85f16

Please sign in to comment.