Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This PR closes #818 and closes #262 and removes the need for specific circuits based on the commitments and nullifiers. Instead we have 3 circuits (deposit, transfer, withdraw) that can support variable number of commitment/nullifiers. There are considerable changes to the way the circuits and commitment selection works in this PR.
Circuits
verify
functions (e.g.verify_nullifier
,verify_commitment
andverify_structure
).Note: There is no longer a specific
single_transfer
circuit as the transfer circuit handles all scenarios (hence the constraint is as large as possible to also handle double_transfer). Similarly, withdraw must be able to accommodate the most complex scenario of 2 inputs with a single output, which increases the constraints significantly.Commitment Selection
We now have the flexibility to better select the type of transaction that will be performed based on the current user's UTXO (notes). Previously, commitment selection was based on:
Note: A double transfer would fail if the sum of inputs were equal to the required output (i.e. it had to be strictly greater than). Withdraw's needed to be of exact value.
With the new flexible circuits we perform the following checks
This is still subject to change, especially in the prioritising of (3) and (4). Note that a withdraw now attempts to do (1) to (3) instead of being restricted to an exactly matching input.
Testing
This can be tested by running
npm run test-circuits
while nightfall is running