From 5f2a383f8ba60cf3b164e9da92439a0bb35bc56b Mon Sep 17 00:00:00 2001 From: Oleh Komendant Date: Fri, 15 Nov 2024 16:43:35 +0200 Subject: [PATCH] Change hash function from the MD5 to the SHA256 --- package-lock.json | 4 ++-- package.json | 2 +- src/core/dependencies/CircomFilesResolver.ts | 4 ++-- src/utils/utils.ts | 11 ++++++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1843f6c..1f7cbca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/hardhat-zkit", - "version": "0.5.1", + "version": "0.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@solarity/hardhat-zkit", - "version": "0.5.1", + "version": "0.5.2", "license": "MIT", "workspaces": [ "test/fixture-projects/*" diff --git a/package.json b/package.json index 6df0dc9..737eeea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/hardhat-zkit", - "version": "0.5.1", + "version": "0.5.2", "description": "The ultimate TypeScript environment for Circom development", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/core/dependencies/CircomFilesResolver.ts b/src/core/dependencies/CircomFilesResolver.ts index d021ebc..e5d16e9 100644 --- a/src/core/dependencies/CircomFilesResolver.ts +++ b/src/core/dependencies/CircomFilesResolver.ts @@ -16,10 +16,10 @@ import { import { assertHardhatInvariant, HardhatError } from "hardhat/internal/core/errors"; import { ERRORS } from "hardhat/internal/core/errors-list"; import { getRealPath } from "hardhat/internal/util/fs-utils"; -import { createNonCryptographicHashBasedIdentifier } from "hardhat/internal/util/hash"; import { CircomFilesParser } from "./parser/CircomFilesParser"; import { CIRCOM_FILE_REG_EXP, NODE_MODULES, NODE_MODULES_REG_EXP, URI_SCHEME_REG_EXP } from "../../constants"; +import { getSHA256Hash } from "../../utils"; import { HardhatZKitError } from "../../errors"; import { @@ -385,7 +385,7 @@ export class CircomFilesResolver { const stats = await fsExtra.stat(absolutePath); const lastModificationDate = new Date(stats.ctime); - const contentHash = createNonCryptographicHashBasedIdentifier(Buffer.from(rawContent)).toString("hex"); + const contentHash = getSHA256Hash(rawContent); const fileData = this._parser.parse(rawContent, absolutePath, contentHash); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 7700617..72bc51b 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,11 +1,10 @@ import fsExtra from "fs-extra"; import https from "https"; +import { createHash } from "crypto"; import { exec } from "child_process"; import * as snarkjs from "snarkjs"; -import { createNonCryptographicHashBasedIdentifier } from "hardhat/internal/util/hash"; - import { ProvingSystemType } from "@solarity/zkit"; import { Reporter } from "../reporter"; @@ -105,7 +104,13 @@ export async function execCall(execFile: string, callArgs: string[]): Promise