This is an extremely WIP proof of concept for an NFT with shielded transfers. It was created as part of 0xPARC's first Applied ZK Learning Group.
The ZkNft
contract has four methods (it's not ERC-721 compatible):
mint(id)
mints the token id
to the sender.shield(..., [commitment, id])
shields the token id
and adds the commitmentunshield(..., [nullifier, id, owner, root])
unshields the token.transfer(nullifier, newCommitment, root)
is similar to unshield, but insteadIn practice this means that transferring a token means sending your secret to the other person, and then they can do the transfer that changes the secret to a new one only known by them.
yarn
to install the dependenciesnpx hardhat circom
to build the circuits and generate theVerifier.sol
file.node generate-inputs.js
. This will generate the input values for./generate-calldata.sh
to generate the calldata used by the script tonpx hardhat run script.js
to run the example script. This will