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

compress user data #39

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hardhat/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PRIVATE_KEY=8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f
PRIVATE_KEY=
RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
2 changes: 1 addition & 1 deletion hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Verifier.js
npx hardhat ignition deploy ./ignition/modules/Verifier.ts
```
10 changes: 4 additions & 6 deletions hardhat/contracts/verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,13 @@ contract Verifier {

}

function verifyUserData(
uint8[32] memory _userData,
function calculatePublicInput(
bytes memory _userData,
uint32[8] memory _memRootBefore,
uint32[8] memory _memRootAfter
) public pure returns (uint256) {
uint256 userData = 0;
for (uint256 i = 0; i < 32; i++) {
userData |= uint256(_userData[i]) << (8 * (31 - i));
}
bytes32 userData = sha256(_userData);

uint256 memRootBefore = 0;
for (uint256 i = 0; i < 8; i++) {
memRootBefore |= uint256(_memRootBefore[i]) << (32 * (7 - i));
Expand Down
12 changes: 7 additions & 5 deletions hardhat/hardhat.config.js → hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require("dotenv").config({ path: __dirname + "/.env" });
require("@nomicfoundation/hardhat-toolbox");
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "dotenv/config";

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
const config: HardhatUserConfig = {
solidity: "0.8.24",
defaultNetwork: "localhost",
defaultNetwork: "hardhat",
networks: {
hardhat: {},
// example
Expand All @@ -16,3 +16,5 @@ module.exports = {
},
},
};

export default config;
6 changes: 0 additions & 6 deletions hardhat/ignition/modules/Verifier.js

This file was deleted.

11 changes: 11 additions & 0 deletions hardhat/ignition/modules/Verifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This setup uses Hardhat Ignition to manage smart contract deployments.
// Learn more about it at https://hardhat.org/ignition

import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

const VerifierModule = buildModule("VerifierModule", (m) => {
const verifier = m.contract("Verifier");
return { verifier };
});

export default VerifierModule;
Loading