Skip to content

Commit

Permalink
Merge pull request #153 from jayden-sudo/develop
Browse files Browse the repository at this point in the history
Fixed js file errors
  • Loading branch information
jayden-sudo authored Jun 4, 2024
2 parents f4f9b4e + 4332f27 commit 3eff06a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-ducks-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@soulwallet/zkemail": patch
---

Fixed js file errors
10 changes: 7 additions & 3 deletions packages/soulwallet-zkemail/src/emailProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class EmailProof {
* @memberof EmailProof
*/
constructor(
tmpDir: string,
file_wasm: string,
file_zkey: string,
file_vkey: string,
rapidsnarkProverBin?: string
rapidsnarkProverBin?: string,
tmpDir?: string,
) {
this.vKey = JSON.parse(readFileSync(file_vkey).toString('utf-8'));
// check if file_wasm and file_zkey exist
Expand All @@ -73,7 +73,11 @@ export class EmailProof {
this._file_zkey = file_zkey;


this._tmpDir = tmpDir;
if (tmpDir === undefined) {
this._tmpDir = join(__dirname, '.tmp');
} else {
this._tmpDir = tmpDir;
}
if (!existsSync(this._tmpDir)) {
mkdirSync(this._tmpDir);
}
Expand Down
26 changes: 13 additions & 13 deletions packages/soulwallet-zkemail/src/generateWitness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function builder(code, options) {
wasmModule = await WebAssembly.compile(code);
} catch (err) {
console.log(err);
console.log("\nTry to run circom --c in order to generate c++ code instead\n");
console.log("\\nTry to run circom --c in order to generate c++ code instead\\n");
throw new Error(err);
}
Expand All @@ -77,29 +77,29 @@ async function builder(code, options) {
exceptionHandler: function (code) {
let err;
if (code == 1) {
err = "Signal not found.\n";
err = "Signal not found.\\n";
} else if (code == 2) {
err = "Too many signals set.\n";
err = "Too many signals set.\\n";
} else if (code == 3) {
err = "Signal already set.\n";
err = "Signal already set.\\n";
} else if (code == 4) {
err = "Assert Failed.\n";
err = "Assert Failed.\\n";
} else if (code == 5) {
err = "Not enough memory.\n";
err = "Not enough memory.\\n";
} else if (code == 6) {
err = "Input signal array access exceeds the size.\n";
err = "Input signal array access exceeds the size.\\n";
} else {
err = "Unknown error.\n";
err = "Unknown error.\\n";
}
throw new Error(err + errStr);
},
printErrorMessage: function () {
errStr += getMessage() + "\n";
errStr += getMessage() + "\\n";
// console.error(getMessage());
},
writeBufferMessage: function () {
const msg = getMessage();
if (msg === "\n") {
if (msg === "\\n") {
console.log(msgStr);
msgStr = "";
} else {
Expand Down Expand Up @@ -195,13 +195,13 @@ class WitnessCalculator {
const fArr = flatArray(input[k]);
let signalSize = this.instance.exports.getInputSignalSize(hMSB, hLSB);
if (signalSize < 0) {
throw new Error("Signal " + k + " not found\n");
throw new Error("Signal " + k + " not found\\n");
}
if (fArr.length < signalSize) {
throw new Error("Not enough values for input signal " + k + "\n");
throw new Error("Not enough values for input signal " + k + "\\n");
}
if (fArr.length > signalSize) {
throw new Error("Too many values for input signal " + k + "\n");
throw new Error("Too many values for input signal " + k + "\\n");
}
for (let i = 0; i < fArr.length; i++) {
const arrFr = toArray32(normalize(fArr[i], this.prime), this.n32)
Expand Down

0 comments on commit 3eff06a

Please sign in to comment.