Skip to content

Commit

Permalink
update nastpec docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbuild3r committed Sep 7, 2023
1 parent b16029f commit 0a60a11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 7 additions & 11 deletions src/WorldIDIdentityManagerImplV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ contract WorldIDIdentityManagerImplV2 is WorldIDIdentityManagerImplV1 {
/// @dev Deletion is performed off-chain and verified on-chain via the `deletionProof`.
/// This saves gas and time over deleting identities one at a time.
///
/// @param deletionProof The proof that given the conditions (`preRoot`, `startIndex` and
/// `identityCommitments`), deletion into the tree results in `postRoot`. Elements 0 and
/// 1 are the `x` and `y` coordinates for `ar` respectively. Elements 2 and 3 are the `x`
/// coordinate for `bs`, and elements 4 and 5 are the `y` coordinate for `bs`. Elements 6
/// and 7 are the `x` and `y` coordinates for `krs`.
/// @param deletionProof The proof that given the conditions (`preRoot` and `packedDeletionIndices`),
/// deletion into the tree results in `postRoot`. Elements 0 and 1 are the `x` and `y`
/// coordinates for `ar` respectively. Elements 2 and 3 are the `x` coordinate for `bs`,
/// and elements 4 and 5 are the `y` coordinate for `bs`. Elements 6 and 7 are the `x`
/// and `y` coordinates for `krs`.
/// @param batchSize The number of identities that are to be deleted in the current batch.
/// @param packedDeletionIndices The indices of the identities that were deleted from the tree.
/// @param preRoot The value for the root of the tree before the `identityCommitments` have been
/// inserted. Must be an element of the field `Kr`.
/// @param packedDeletionIndices The indices of the identities that were deleted from the tree.
/// @param postRoot The root obtained after deleting all of `identityCommitments` into the tree
/// described by `preRoot`. Must be an element of the field `Kr`.
///
Expand Down Expand Up @@ -111,11 +112,6 @@ contract WorldIDIdentityManagerImplV2 is WorldIDIdentityManagerImplV1 {
revert NotLatestRoot(preRoot, _latestRoot);
}

// As the `startIndex` is restricted to a uint32, where
// `type(uint32).max <<< SNARK_SCALAR_FIELD`, we are safe not to check this. As verified in
// the tests, a revert happens if you pass a value larger than `type(uint32).max` when
// calling outside the type-checker's protection.

// We need the post root to be in reduced form.
if (postRoot >= SNARK_SCALAR_FIELD) {
revert UnreducedElement(UnreducedElementType.PostRoot, postRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ contract WorldIDIdentityManagerIdentityDeletion is WorldIDIdentityManagerTest {
vm.assume(SimpleVerify.isValidInput(uint256(prf[0])));
vm.assume(newPreRoot != newPostRoot);
vm.assume(packedDeletionIndices.length <= 1000 && packedDeletionIndices.length > 0);

bytes memory secondIndices = abi.encodePacked(uint32(0), uint32(2), uint32(4), uint32(6));
uint32 secondIndicesLength = uint32(secondIndices.length);

Expand Down
4 changes: 3 additions & 1 deletion src/test/identity-manager/WorldIDIdentityManagerTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ contract WorldIDIdentityManagerTest is WorldIDTest {
0x18cb13df3e79b9f847a1494d0a2e6f3cc0041d9cae7e5ccb8cd1852ecdc4af58;
uint256 internal constant deletionPostRoot =
0x82fcf94594d7363636338e2c29242cc77e3d04f36c8ad64d294d2ab4d251708;
bytes packedDeletionIndices = abi.encodePacked(uint32(0), uint32(2), uint32(4), uint32(6),uint32(8),uint32(10),uint32(12),uint32(14));
bytes packedDeletionIndices = abi.encodePacked(
uint32(0), uint32(2), uint32(4), uint32(6), uint32(8), uint32(10), uint32(12), uint32(14)
);
uint32 deletionBatchSize = 8;
uint256[8] deletionProof;

Expand Down

0 comments on commit 0a60a11

Please sign in to comment.