-
Notifications
You must be signed in to change notification settings - Fork 18
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
Lock states #110
Lock states #110
Conversation
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimthematrix I couldn't figure out how we protect locked UTXOs not to be withdrawn.
Can we add a test for that?
for (uint256 i = 0; i < utxos.length; ++i) { | ||
utxosArray[i] = utxos[i]; | ||
} | ||
for (uint256 i = utxos.length; i < 10; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hard coded batch size of 10
in the condition, could this be replaced with MAX_BATCH
?
solidity/contracts/zeto_anon.sol
Outdated
address _lockVerifier, | ||
address _batchLockVerifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these not using the interface types rather than address
?
@@ -382,6 +383,52 @@ describe("Zeto based fungible token with anonymity without encryption or nullifi | |||
}); | |||
}); | |||
|
|||
describe("lockStates() tests", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add a test for withdraw()
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma circom 2.1.9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should consider 2.2.1 for new circuits
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
pragma circom 2.1.9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment here for the version
thanks @Chengxuan for catching the missing checks in the withdraw() function. will add to the next commit along with addressing your other comments |
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
Replace
lockProof()
withlockStates()
, because lockProof() is keyed off of the proof bytes which doesn't guarantee uniqueness of the individual states to be spent. As such it can't prevent the owner from spending the state(s) that are supposed to be used in a multi-step flow such as DvP.For example, consider the following scenario:
assetUTXO-1
, and Bob sends Alice payment two tokenspaymentUTXO-1
andpaymentUTXO-2
p1
, for transferring assetUTXO-1 to assetUTXO-2 with Bob as the ownerp1
and sets the DvP contract as the delegate (who is allowed to submit the proof to complete the transfer)p2
, for spending bothpaymentUTXO-1
andpaymentUTXO-2
in order to pay Alicep2
and sets the DvP contract as the delegatepaymentUTXO-1
to pay Charlie for another trade, that transaction will be successful because it uses a different proofpaymentUTXO-1
, in the input is already spentUsing lockStates() on the other hand, can guarantee that the individual input states are locked and delegated to an orchestration contract, which is the only account that can unlock or spend the states.