Skip to content

change modifier onlyVerified to onlyValidProof and unit tests#14

Merged
Dprof-in-tech merged 1 commit intodewdrop-labs:mainfrom
mnusurov:main
Mar 3, 2025
Merged

change modifier onlyVerified to onlyValidProof and unit tests#14
Dprof-in-tech merged 1 commit intodewdrop-labs:mainfrom
mnusurov:main

Conversation

@mnusurov
Copy link
Copy Markdown

@mnusurov mnusurov commented Feb 11, 2025

PR Description

This PR introduces several key updates and improvements to enhance the security and functionality of our wallet system, with a particular focus on integrating zero-knowledge (ZK) proof verification. The changes span across the wallet contract, its related tests, and the World ID interface.


Changes

Wallet Contract (src/Wallet.sol)

  • Immutable Variables:
    Changed owner and worldID to immutable for improved efficiency.
  • Nullifier Hashes:
    Introduced the nullifierHashes mapping to store used nullifier hashes.
  • Modifier Update:
    Replaced the onlyVerified modifier with onlyValidProof to ensure that a valid ZK proof is provided.
  • Transfer Function:
    Modified the transfer function to accept a ZK proof as an additional parameter.
  • Function Removal:
    Removed the createWorldId function since it was empty.
  • Token Support:
    Removed the usdt state variable and added USDT as a supported token in the constructor.

Wallet Test (test/Wallet.t.sol)

  • Variable Renaming:
    Renamed worldID to mockWorldID for clarity.
  • Setup Update:
    Updated the setUp function to use mockWorldID.
  • Test Enhancements:
    • Updated tests to supply a valid ZK proof when calling the transfer function.
    • Added tests to verify the validity of ZK proofs and the proper recording of nullifier hashes.

Wallet Factory Test (test/WalletFactory.t.sol)

  • Address Update:
    Changed mockWorldID to a hardcoded address.
  • Test Update:
    Updated the test_CreateWallet function to use the new hardcoded mockWorldID address.

Transfer Test (test/Transfer.t.sol)

  • Mock Replacement:
    Removed the MockWorldIDContract and replaced it with MockWorldID.
  • Proof Handling:
    • Updated tests to provide a valid ZK proof when calling the transfer function.
    • Added checks to verify both valid and invalid proofs.

Mock World ID (test/mocks/MockWorldID.sol)

  • Function Implementation:
    Implemented the verifyProof and generateZkProof functions to simulate ZK proof verification and generation.

World ID Interface (src/IWorldID.sol)

  • Interface Update:
    Updated the interface to include the verifyProof function, ensuring compatibility with the new ZK proof verification process.

Summary

This PR improves the wallet contract by:

  • Enhancing security with strict ZK proof verification.
  • Optimizing contract behavior by using immutable variables and removing redundant code.
  • Updating tests and interfaces to ensure consistency and correctness in handling ZK proofs and nullifier hashes.

Please review the changes and provide any feedback or suggestions for further improvement.

@mnusurov
Copy link
Copy Markdown
Author

closes #1

@mnusurov
Copy link
Copy Markdown
Author

hey @Dprof-in-tech friendly reminder )

@Dprof-in-tech Dprof-in-tech self-requested a review March 3, 2025 07:38
Copy link
Copy Markdown
Contributor

@Dprof-in-tech Dprof-in-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautiful work. Also I'm sorry for the time taken to review this. I've been away for a while

@Dprof-in-tech Dprof-in-tech merged commit 90b7024 into dewdrop-labs:main Mar 3, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants