-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from zkemail/feat/relayer-refactor
Feat/relayer refactor
- Loading branch information
Showing
30 changed files
with
944 additions
and
321 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const circom_tester = require("circom_tester"); | ||
const wasm_tester = circom_tester.wasm; | ||
import * as path from "path"; | ||
const emailWalletUtils = require("../../utils"); | ||
const relayerUtils = require("../../utils"); | ||
const option = { | ||
include: path.join(__dirname, "../../../node_modules") | ||
}; | ||
|
@@ -14,7 +14,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "Code 123abc"; | ||
// const prefixLen = "ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -23,7 +23,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
for (let idx = 0; idx < 256; ++idx) { | ||
if (idx >= prefixIdxes[0] && idx < prefixIdxes[1]) { | ||
expect(BigInt(paddedStr[idx])).toEqual(witness[2 + idx]); | ||
|
@@ -37,7 +37,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "Swap 0.1 ETH to DAI code 123abc"; | ||
// const prefixLen = "sepolia+ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -46,7 +46,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
// const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; | ||
// console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); | ||
for (let idx = 0; idx < 256; ++idx) { | ||
|
@@ -62,7 +62,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "Send 0.1 ETH to [email protected] code 123abc"; | ||
// const prefixLen = "sepolia+ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -71,7 +71,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
// const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; | ||
// console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); | ||
for (let idx = 0; idx < 256; ++idx) { | ||
|
@@ -87,7 +87,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "[email protected]"; | ||
// const prefixLen = "sepolia+ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -96,7 +96,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeIdxes(codeStr)[0]; | ||
// const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; | ||
// console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); | ||
for (let idx = 0; idx < 256; ++idx) { | ||
|
@@ -112,7 +112,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "Swap 0.1 ETH to DAI code 123abc"; | ||
// const prefixLen = "sepolia+ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -121,7 +121,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; | ||
// const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; | ||
// console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); | ||
for (let idx = 0; idx < 256; ++idx) { | ||
|
@@ -137,7 +137,7 @@ describe("Invitation Code Regex", () => { | |
const codeStr = "Re: Accept guardian request for 0x04884491560f38342C56E26BDD0fEAbb68E2d2FC Code 01eb9b204cc24c3baee11accc37d253a9c53e92b1a2cc07763475c135d575b76"; | ||
// const prefixLen = "sepolia+ACCOUNTKEY.0x".length; | ||
// const revealed = "123abc"; | ||
const paddedStr = emailWalletUtils.padString(codeStr, 256); | ||
const paddedStr = relayerUtils.padString(codeStr, 256); | ||
const circuitInputs = { | ||
msg: paddedStr, | ||
}; | ||
|
@@ -146,7 +146,7 @@ describe("Invitation Code Regex", () => { | |
await circuit.checkConstraints(witness); | ||
// console.log(witness); | ||
expect(1n).toEqual(witness[1]); | ||
const prefixIdxes = emailWalletUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; | ||
const prefixIdxes = relayerUtils.extractInvitationCodeWithPrefixIdxes(codeStr)[0]; | ||
// const revealedStartIdx = emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))[0][0]; | ||
// console.log(emailWalletUtils.extractSubstrIdxes(codeStr, readFileSync(path.join(__dirname, "../src/regexes/invitation_code.json"), "utf8"))); | ||
for (let idx = 0; idx < 256; ++idx) { | ||
|
Oops, something went wrong.