Skip to content
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

change modifier onlyVerified to onlyValidProof and unit tests #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mnusurov
Copy link

@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
Author

closes #1

@mnusurov
Copy link
Author

hey @Dprof-in-tech friendly reminder )

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.

1 participant