This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.
- Node
$ git clone https://github.com/BkCrypt0/BkCrypt0SmartContract.git
$ cd BkCrypt0SmartContract
$ npm install --save-dev
- Copy and update from file .env_example
These contracts supply for users function what verify their proof. It currently includes age verification and place verification.
It has 4 main contracts.
-
Verifier: these contracts verifier will verify proof was submit on Smart Contract. To generate verifier contracts. Please see project please see project BKCrypt0-Circuit
-
Lib_AddressManager: this contract will store add of verifier contracts
-
MerkleTreeWithHistory: this is abstract contract, it will store neccessory information of Claim Tree and Revoke Tree on Smart Contract
-
KYC: this contract is used for verify user proof and update root tree
Admin role:
-
Update new root claim or revoke on Smart Contract which play an important role when verify user's proof
-
set address contract what is used to verify proof
-
set root history size which store history of some latest proofs. Because of updating proof, so it will has case that user hold their proof with old root and submit it for third party without its updated
User role:
- use function was provided by admin for verifying proof
If you use our service, please ignore these steps.
Compile contract before deploying.
hardhat compile
deploy contracts in the following order
hardhat run scripts/deploy-upgrades/deploy-libAddressManager.js
save LibAddressManager address to .env file. Then, continues deploying:
hardhat run scripts/deploy-upgrades/deploy-kyc.js
hardhat run scripts/deploy-upgrades/deploy-veriferClaim.js
hardhat run scripts/deploy-upgrades/deploy-veriferRevoke.js
hardhat run scripts/deploy-upgrades/deploy-verifierAge.js
hardhat run scripts/deploy-upgrades/deploy-verfierPlace.js
When deploying completed, save its address to .env file. Then, set address for address of verifer contracts in contract Lib_AddressManager. You can see example in file setLibAddressManager
The other contracts is used for BkCrypt0-Frontend. It supply poseidonHash and verifierSparseMerkleTree function. To deploy, run:
hardhat run scripts/deploy-upgrades/deploy-hashPoseidon.js
hardhat run scripts/deploy-upgrades/deploy-sparseMerkleTree.js
-
To update root. Please see example in file testUpdateRootClaim or file testUpdateRootRevoke
-
To create proof and public file for update root. Please see our server project BKCrypt0-Server
Please update claim and/or revoke root if meet error "Can't file merkle tree root". Generate new signature if signature was expired time.
-
To verify age proof. Please see example in file testVerifyAge.
-
To verify place proof. Please see example in file testVerifyPlace.
-
To create inputProof file for verify age or place proof. Please see our server project BKCrypt0-Server
To use PoseidonHash and VerifierSMT function. Please see our server project BKCrypt0-Frontend