Skip to content

Commit

Permalink
add contract address
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyyang committed Mar 10, 2024
1 parent 51ac962 commit ba3801a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ This will generate `zkey` files, `vkey.json` in `build` directory, and Solidity
> Note: We are using a custom fork of `snarkjs` which generated **chunked zkeys**. Chunked zkeys make it easier to use in browser, especially since we have large circuit. You can switch to regular `snarkjs` in `package.json` if you don't want to use chunked zkeys.

For browser use, the script also compresses the chunked zkeys.
For browser use, the script also compresses the chunked zkeys.

**The compressed zkeys, vkey, wasm are copied to /build/artifacts` directory. This directory can be served using a local server or uploaded to S3 for use in the browser.

To upload to S3, the below script can be used.
```bash
python3 upload_to_s3.py --build-dir <project-path>/hedwig/packages/circuits/build --circuit-name oracle
python3 upload_to_s3.py --build-dir <project-path>/hedwig/packages/circuits/build --circuit-name oracle
```

There are helper functions in `@zk-email/helpers` package to download and decompress the zkeys in the browser.
Expand Down Expand Up @@ -129,7 +129,12 @@ PRIVATE_KEY=<pk-hex> forge script script/DeployOracle.s.sol:Deploy -vvvv --rpc-u
Currently deployed contracts on Sepolia:

```
Deployed SimpleOracle at address: 0x4370da73a076563448CAd69bD11437fa0814713a
Deployed SimpleOracle at address:
0x4370da73a076563448CAd69bD11437fa0814713a # Etherum Sepolia
0xB74C6Eaf47ed115Ac175872a35140c5590737D95 # Avalanche
0xB74C6Eaf47ed115Ac175872a35140c5590737D95 # Flare Coston2
0xB74C6Eaf47ed115Ac175872a35140c5590737D95 # Solana neon evm devnet
```

### UI
Expand Down
45 changes: 19 additions & 26 deletions packages/app/src/pages/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const MainPage: React.FC<{}> = (props) => {
// reformatProofForChain(proof),
// publicSignals ? JSON.parse(publicSignals) : [],
"BTC",
"70k",
"69.5k",
],
enabled: true, // !!(proof && publicSignals),
onError: (error: { message: any }) => {
Expand Down Expand Up @@ -199,9 +199,6 @@ export const MainPage: React.FC<{}> = (props) => {
)}
<div className="title">
<Header>Proof of Price: Hedwig Demo</Header>
<Header>
<SubHeader>BTC Price: {BTCPrice} </SubHeader>
</Header>
</div>

<Col
Expand All @@ -213,26 +210,18 @@ export const MainPage: React.FC<{}> = (props) => {
}}
>
<span>
Welcome to a demo page for Hedwig technology.{" "}
<a href="https://github.com/zk-email-verify/zk-email-verify/">
Our library
</a>{" "}
will allow you to generate zero knowledge proofs proving you received
some email and mask out any private data, without trusting our server
to maintain a zk-oracle. This demo is just one use-case that lets you
update price data on-chain, by verifying
emails (and their normally-hidden headers) from Mail Brew daily newsletter, and fetch
BTC price.
Welcome to a demo page for Hedwig that allows you to generate zero
knowledge proofs proving you received some email and mask out any
private data, without trusting our server to maintain a zk-oracle.
This demo is just one use-case that lets you update price data
on-chain, by verifying emails (and their normally-hidden headers) from
Mail Brew daily newsletter, and fetch BTC price.
<br />
If you wish to generate a ZK proof of BTC Price data, you must:
</span>
<NumberedStep step={1}>
Signup for newsletter {" "}
<a
href="https://mailbrew.com/"
target="_blank"
rel="noreferrer"
>
Signup for newsletter{" "}
<a href="https://mailbrew.com/" target="_blank" rel="noreferrer">
daily digest
</a>{" "}
from Mail brew and create a BTC price feed.
Expand All @@ -253,12 +242,12 @@ export const MainPage: React.FC<{}> = (props) => {
open source, and you are not trusting us with any private information.
</NumberedStep>
<NumberedStep step={5}>
Click <b>"Verify"</b> and then <b>"Update BTC price"</b>,
and approve! Note
that it is 700K gas right now so only feasible on Sepolia, though we
intend to reduce this soon.
Click <b>"Verify"</b> and then <b>"Update BTC price"</b>, and approve!
</NumberedStep>
</Col>
<Col>
<Header style={{border: "2px solid black", padding: 30}}>BTC Price: {BTCPrice} </Header>
</Col>
<Main>
<Column>
<SubHeader>Input</SubHeader>
Expand Down Expand Up @@ -366,8 +355,12 @@ export const MainPage: React.FC<{}> = (props) => {
// import.meta.env.VITE_CIRCUIT_ARTIFACTS_URL,
// CIRCUIT_NAME
// );
const proof = JSON.parse('{"pi_a": ["19201501460375869359786976350200749752225831881815567077814357716475109214225", "11505143118120261821370828666956392917988845645366364291926723724764197308214", "1"], "pi_b": [["17114997753466635923095897108905313066875545082621248342234075865495571603410", "7192405994185710518536526038522451195158265656066550519902313122056350381280"], ["13696222194662648890012762427265603087145644894565446235939768763001479304886", "2757027655603295785352548686090997179551660115030413843642436323047552012712"], ["1", "0"]], "pi_c": ["6168386124525054064559735110298802977718009746891233616490776755671099515304", "11077116868070103472532367637450067545191977757024528865783681032080180232316", "1"], "protocol": "groth16", "curve": "bn128"}');
const publicSignals = JSON.parse('["0", "0", "0", "0", "0", "0", "0", "0", "32767059066617856", "30803244233155956", "0", "0", "0", "0", "27917065853693287", "28015", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "113659471951225", "0", "0", "1634582323953821262989958727173988295", "1938094444722442142315201757874145583", "375300260153333632727697921604599470", "1369658125109277828425429339149824874", "1589384595547333389911397650751436647", "1428144289938431173655248321840778928", "1919508490085653366961918211405731923", "2358009612379481320362782200045159837", "518833500408858308962881361452944175", "1163210548821508924802510293967109414", "1361351910698751746280135795885107181", "1445969488612593115566934629427756345", "2457340995040159831545380614838948388", "2612807374136932899648418365680887439", "16021263889082005631675788949457422", "299744519975649772895460843780023483", "3933359104846508935112096715593287", "556307310756571904145052207427031380052712977221"]');
const proof = JSON.parse(
'{"pi_a": ["19201501460375869359786976350200749752225831881815567077814357716475109214225", "11505143118120261821370828666956392917988845645366364291926723724764197308214", "1"], "pi_b": [["17114997753466635923095897108905313066875545082621248342234075865495571603410", "7192405994185710518536526038522451195158265656066550519902313122056350381280"], ["13696222194662648890012762427265603087145644894565446235939768763001479304886", "2757027655603295785352548686090997179551660115030413843642436323047552012712"], ["1", "0"]], "pi_c": ["6168386124525054064559735110298802977718009746891233616490776755671099515304", "11077116868070103472532367637450067545191977757024528865783681032080180232316", "1"], "protocol": "groth16", "curve": "bn128"}'
);
const publicSignals = JSON.parse(
'["0", "0", "0", "0", "0", "0", "0", "0", "32767059066617856", "30803244233155956", "0", "0", "0", "0", "27917065853693287", "28015", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "113659471951225", "0", "0", "1634582323953821262989958727173988295", "1938094444722442142315201757874145583", "375300260153333632727697921604599470", "1369658125109277828425429339149824874", "1589384595547333389911397650751436647", "1428144289938431173655248321840778928", "1919508490085653366961918211405731923", "2358009612379481320362782200045159837", "518833500408858308962881361452944175", "1163210548821508924802510293967109414", "1361351910698751746280135795885107181", "1445969488612593115566934629427756345", "2457340995040159831545380614838948388", "2612807374136932899648418365680887439", "16021263889082005631675788949457422", "299744519975649772895460843780023483", "3933359104846508935112096715593287", "556307310756571904145052207427031380052712977221"]'
);
console.log("Finished proof generation");
console.timeEnd("zk-gen");
recordTimeForActivity("finishedProving");
Expand Down

0 comments on commit ba3801a

Please sign in to comment.