Skip to content

Commit

Permalink
Updated smart contracts and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
manudev97 committed Jul 14, 2024
1 parent 70f57a8 commit a579ca0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/hardhat/circuits/withdraw_js/input.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{"root": "0x257c5ee15d6ffaffb9798c823bcdb102c8bae45fa7af86c88995be5114870098",
"nullifierHash": "0x160914ca8ad166446dae3f0c1aa2f39f5b6bb58cd9fe8a8e711e64b0ae1488c1",
"nullifier": "0xa9734f92298a725255320baaad2115c6ff237c51bde326d47b23e58b3d320a26",
"secret": "0x717c77c331480ff4dfcfa431e1d8e34bdcd9541b38c92bd749b85724e9650694",
"pathElements": ["0x1d27baa01438d26e8a52f6914806cf329e273630404a9731e3035c38554973dd", "0x22ad4ea9d906223178e5e07ce96027769ee28e66bcfc00237e69c08845cd3972"],
"pathIndices": [0,0]
{"root": "0x11aecbbfb437e5677960ee0a9cf0e43975214b8c0cfe0327d2f618e73c05c5ea",
"nullifierHash": "0x157cef5f4ba2f139aecb41b479d2efbc6d888aa89a4ff10ec6850c69829f960f",
"nullifier": "0x0990fb0fa550d25d6ef750aa84898d944af9568656c913d14056615d86dddc54",
"secret": "0x07ecd6ff9737eb11d19e77a84bf2d9269a72569fd656ee7773ea4a5f3cbc321d",
"pathElements": ["0x1d83cc0d4195d4cc2315f3741630e89c22600c66c88684ed2b6e579472700dbb", "0x22ad4ea9d906223178e5e07ce96027769ee28e66bcfc00237e69c08845cd3972"],
"pathIndices": [1,0]
}
11 changes: 7 additions & 4 deletions packages/hardhat/contracts/ATM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ contract ATM is MerkleTree {
// _merkleTreeHeight --> la altura del árbol Merkle de los depósitos
// Hasher address (Poseidon 1 args): 0xCc735e52E393f125cAFc4E0aEbD80AEd81eA4B41
// Verifier address: 0x0918fe077e800b24E1D64c2FE9bb6a12E0255CA9
// ZKATM_TOKENaddress: 0x2a8f9804C5f830ECbe831B2717D210B6d9895134
// ZKATM_TOKEN address: 0x2a8f9804C5f830ECbe831B2717D210B6d9895134
// ZKATM_TOKEN new address: 0xa78a484c097d27a4922fF07033c702c2Da85b6FC
// ATM address: 0x556E6C30C2a28ef3C9c9C464E8Cf0F561678F779
// ATM new address: 0xdB7a0b5fB1c909cdBcB19F3748cB957470E94B57 --> 0xd1020f336bebdd4649Daa32B6bAb0660492A7C5b
constructor(
IVerifier _verifier,
address _hasher,
Expand Down Expand Up @@ -72,16 +75,16 @@ contract ATM is MerkleTree {
bytes32 nullifierHash
) {
// Puedes ajustar cómo generas el nullifier
nullifier = bytes32(keccak256(abi.encodePacked(block.timestamp, msg.sender)));
nullifier = bytes32(uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % MerkleTree.FIELD_SIZE);
// Puedes ajustar cómo generas el secret
secret = bytes32(keccak256(abi.encodePacked(nullifier, block.timestamp, msg.sender)));
secret = bytes32(uint256(keccak256(abi.encodePacked(nullifier, block.timestamp, msg.sender))) % MerkleTree.FIELD_SIZE);
commitment = hasher.poseidon([nullifier, secret]);
nullifierHash = hasher.poseidon([nullifier, nullifier]);
}

// commitment el compromiso de nota, que es poseidonhash(anulador + secreto)
function deposit(bytes32 commitment, uint256 _amount) public {
require(!commitments[commitment], "El compromiso ya se ha insertao");
require(!commitments[commitment], "El compromiso ya se ha insertado");
if(balance[msg.sender] < _amount) revert InsufficientBalance();
require(_amount == denomination, "La cantidad depositada no es admitida");

Expand Down
1 change: 1 addition & 0 deletions packages/hardhat/contracts/ZKATM_Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ contract ZKATM_Token is ERC20, ERC20Pausable, Ownable {
{
super._update(from, to, value);
}

}
28 changes: 28 additions & 0 deletions packages/hardhat/prover/proof1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"pi_a": [
"15610497059691956035252491506848626911735552927523219101705418352897110394961",
"6935556491942605023345017061848679200612220759855072886068160065267325098792",
"1"
],
"pi_b": [
[
"4191136645756518990235268327929900762076605183087794444539638719327958737292",
"1668063499757034116969778207573842296987746247396844748178383032773169571286"
],
[
"689624125900386562345764048500814766628683029719634633615302763708508236269",
"5785150316575724395019058012764903226018464197346840175394865546424804783812"
],
[
"1",
"0"
]
],
"pi_c": [
"15278007640223608456607296240935591538184745715844485970898642343214241323461",
"21512958455359336217957052130510178353331330877954337233673987472684720627822",
"1"
],
"protocol": "groth16",
"curve": "bn128"
}
4 changes: 4 additions & 0 deletions packages/hardhat/prover/public1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
"7998156038024386212248324169752773107020882108161389030375061360593131128298",
"9719310942818382580626812540950309168735855044625659354930391833116447577615"
]

0 comments on commit a579ca0

Please sign in to comment.