mirror of
https://github.com/privacy-scaling-explorations/zk-kit.git
synced 2026-04-22 03:00:15 -04:00
Merge branch 'dev' of github.com:appliedzkp/zk-kit into dev
Former-commit-id: 12fd472645b54925da42909f0555bec6b48f234b [formerly 95f6fef6b8cd30f64d1156543d58548e0afb1917] [formerly 199c44944419332e0f7cb9170a238083f323ce4d [formerly c4962e6bfb97bb25c23ea31312c02de41d151f17]] [formerly 9be3f6d2ba7c99f2122ec892a8fc6f6336d93f3f [formerly 632d5eeb60df32520ba0650ccc7c2a4c3abf7ec6] [formerly 7c026bf14099676730a3ab0af7f2dec0ee8d7311 [formerly e798a2081de1234d956e1b1a55faf7e86bbe32f5]]] Former-commit-id: 7daac55a82b117710559c01ea7cc0bce996af0d4 [formerly 5115dfd310cc2232e8b75db8ae2e94f7e9b3f73d] [formerly fb34f91c89b6cb44748fe37f654dcfe9c8f529cd [formerly abe720fa8a5e034e3d93e40a0aa4249536322c12]] Former-commit-id: 4367243671b36c07725c3ea575d51e3ed5910891 [formerly c1b9f9059290985c802b70a13e5a092364d55cd7] Former-commit-id: 20f7734e65e186d579f7a930d8731cc81bd31e26
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^8.3.0",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"typedoc": "^0.22.11"
|
||||
},
|
||||
@@ -38,6 +39,6 @@
|
||||
"@ethersproject/bignumber": "^5.5.0",
|
||||
"@ethersproject/random": "^5.5.1",
|
||||
"circomlibjs": "0.0.8",
|
||||
"js-sha256": "^0.9.0"
|
||||
"crypto-js": "^4.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BigNumber } from "@ethersproject/bignumber"
|
||||
import { randomBytes } from "@ethersproject/random"
|
||||
import { sha256 as _sha256 } from "js-sha256"
|
||||
import _sha256 from "crypto-js/sha256"
|
||||
|
||||
/**
|
||||
* Returns an hexadecimal sha256 hash of the message passed as parameter.
|
||||
@@ -8,11 +8,9 @@ import { sha256 as _sha256 } from "js-sha256"
|
||||
* @returns The hexadecimal hash of the message.
|
||||
*/
|
||||
export function sha256(message: string): string {
|
||||
const hash = _sha256.create()
|
||||
const hash = _sha256(message)
|
||||
|
||||
hash.update(message)
|
||||
|
||||
return hash.hex()
|
||||
return hash.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,6 +245,11 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/crypto-js@^4.1.1":
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.1.1.tgz#602859584cecc91894eb23a4892f38cfa927890d"
|
||||
integrity sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==
|
||||
|
||||
"@types/estree@0.0.39":
|
||||
version "0.0.39"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
|
||||
@@ -752,6 +757,11 @@ crypto-browserify@3.12.0:
|
||||
randombytes "^2.0.0"
|
||||
randomfill "^1.0.3"
|
||||
|
||||
crypto-js@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
|
||||
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
|
||||
|
||||
d@1, d@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a"
|
||||
@@ -1618,11 +1628,6 @@ js-cleanup@^1.2.0:
|
||||
perf-regexes "^1.0.1"
|
||||
skip-regex "^1.0.2"
|
||||
|
||||
js-sha256@^0.9.0:
|
||||
version "0.9.0"
|
||||
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
|
||||
integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==
|
||||
|
||||
js-sha3@0.8.0, js-sha3@^0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
|
||||
|
||||
@@ -90,11 +90,11 @@ or [JSDelivr](https://www.jsdelivr.com/):
|
||||
|
||||
```typescript
|
||||
import { SparseMerkleTree } from "@zk-kit/sparse-merkle-tree"
|
||||
import { sha256 } from "js-sha256"
|
||||
import sha256 from "crypto-js/sha256"
|
||||
import { poseidon } from "circomlibjs"
|
||||
|
||||
// Hexadecimal hashes.
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join(""))
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join("")).toString()
|
||||
const tree = new SparseMerkleTree(hash)
|
||||
|
||||
// Big number hashes.
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^8.3.0",
|
||||
"circomlibjs": "^0.0.8",
|
||||
"js-sha256": "^0.9.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"typedoc": "^0.22.11"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { poseidon, smt } from "circomlibjs"
|
||||
import { sha256 } from "js-sha256"
|
||||
import sha256 from "crypto-js/sha256"
|
||||
import { ChildNodes, SparseMerkleTree } from "../src"
|
||||
|
||||
describe("Sparse Merkle tree", () => {
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join(""))
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join("")).toString()
|
||||
const testKeys = ["a", "3", "2b", "20", "9", "17"]
|
||||
|
||||
describe("Create hexadecimal trees", () => {
|
||||
@@ -177,7 +177,7 @@ describe("Sparse Merkle tree", () => {
|
||||
})
|
||||
|
||||
it("Should not create a big number tree if the hash function does not return a big number", () => {
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join(""))
|
||||
const hash = (childNodes: ChildNodes) => sha256(childNodes.join("")).toString()
|
||||
|
||||
const fun = () => new SparseMerkleTree(hash, true)
|
||||
|
||||
|
||||
@@ -258,6 +258,11 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/crypto-js@^4.1.1":
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.1.1.tgz#602859584cecc91894eb23a4892f38cfa927890d"
|
||||
integrity sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==
|
||||
|
||||
"@types/estree@0.0.39":
|
||||
version "0.0.39"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
|
||||
@@ -803,6 +808,11 @@ crypto-browserify@3.12.0:
|
||||
randombytes "^2.0.0"
|
||||
randomfill "^1.0.3"
|
||||
|
||||
crypto-js@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
|
||||
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
|
||||
|
||||
d@1, d@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a"
|
||||
@@ -1693,11 +1703,6 @@ js-cleanup@^1.2.0:
|
||||
perf-regexes "^1.0.1"
|
||||
skip-regex "^1.0.2"
|
||||
|
||||
js-sha256@^0.9.0:
|
||||
version "0.9.0"
|
||||
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
|
||||
integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==
|
||||
|
||||
js-sha3@0.8.0, js-sha3@^0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
|
||||
|
||||
Reference in New Issue
Block a user