Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Use toUints for generateModPubSig
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonLewis committed Mar 8, 2024
1 parent 7beabea commit 3f4ad1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/authBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IJwtProvider } from "./jwtProvider";
import { typeDataRecovery } from "./samples";
import { sampleProofA, sampleProofB, sampleProofC } from "./samples/constants";

import { ZkauthJwtV02, string2Uints } from ".";
import { ZkauthJwtV02, toUints } from ".";

export interface typeDataArgs {
verifyingContract: string;
Expand Down Expand Up @@ -280,7 +280,7 @@ export function calcGuardianId(subHash: string, guardian: string) {
}

export const generateModPubSig = (modBytes: string | Buffer) => {
return string2Uints(modBytes, ZkauthJwtV02.maxPubLen);
return toUints(Buffer.from(modBytes), ZkauthJwtV02.maxPubLen);
};

export const generateJwtPubSig = (jwt: string) => {
Expand Down
20 changes: 0 additions & 20 deletions src/circuit-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ export function toHex(buffer: Buffer): string {
return buffer.toString("hex");
}

function bufferToUints(buffer: Buffer, chunkLen: number): string[] {
const result: string[] = [];
_.map(_.chunk(buffer, chunkLen), (slice: Buffer) => {
result.push(BigInt("0x" + Buffer.from(slice).toString("hex")).toString());
});
return result;
}

export function toUints(buffer: Buffer, maxLen: number): string[] {
const stretched = stretch(buffer, maxLen);
const result: string[] = [];
Expand Down Expand Up @@ -98,15 +90,3 @@ export function sha256BlockLen(buf: string | Buffer): number {
// 1 is for 0x80, 8 is for length bits (64 bits)
return Math.ceil((buf.length + 1 + 8) / 64);
}

export function string2Uints(str: string | Buffer, maxLen: number): string[] {
const numBits = 248;
const numBytes = numBits / 8;

let paddedStr = Buffer.from(str);

// Pad the string to the max length
paddedStr = stretch(paddedStr, maxLen);

return bufferToUints(paddedStr, numBytes);
}

0 comments on commit 3f4ad1e

Please sign in to comment.