Skip to content

Commit

Permalink
helpers: make params of input helpers optional when body is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
saleel committed Apr 1, 2024
1 parent 0d0a7ea commit e042932
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zk-email/helpers",
"version": "3.2.2",
"version": "3.2.3",
"main": "dist",
"scripts": {
"build": "tsc",
Expand Down
14 changes: 10 additions & 4 deletions packages/helpers/src/input-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ type CircuitInput = {
};

export function generateCircuitInputs(params: {
body: Buffer;
message: Buffer;
bodyHash: string;
rsaSignature: BigInt;
rsaPublicKey: BigInt;
body?: Buffer;
bodyHash?: string;
shaPrecomputeSelector?: string;
maxMessageLength: number;
maxBodyLength: number;
maxMessageLength?: number;
maxBodyLength?: number;
ignoreBodyHashCheck?: boolean;
}): CircuitInput {
const {
Expand Down Expand Up @@ -151,6 +151,12 @@ export function generateCircuitInputs(params: {
};

if (!ignoreBodyHashCheck) {
if (!body || !bodyHash) {
throw new Error(
`body and bodyHash are required when ignoreBodyHashCheck is false`
);
}

const bodyHashIndex = message.toString().indexOf(bodyHash);

// 65 comes from the 64 at the end and the 1 bit in the start, then 63 comes from the formula to round it up to the nearest 64.
Expand Down

0 comments on commit e042932

Please sign in to comment.