Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add]zk-kit/utils/ #782

Closed
wants to merge 1 commit into from
Closed

Conversation

jancris100
Copy link

@jancris100 jancris100 commented May 14, 2024

Description

Add Dependencies about @zk-kit/utils and remplace checkParameters

Feature

dojoengine/book#272

Install @zk-kit/utils if is necessary

Related Issue(s)

Closes #773

Checklist

  • [x ] My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • [x ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • [x ] I have run yarn format and yarn lint without getting any errors
  • [ x] I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@@ -9,7 +9,7 @@
"dirBuild": "./build",
"optimization": 2,
"inspect": true,
"include": ["../../node_modules/circomlib/circuits", "../../node_modules/@zk-kit/binary-merkle-root.circom/src"],
"include": ["../../node_modules/circomlib/circuits", "../../node_modules/@zk-kit/circuits/circom"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"include": ["../../node_modules/circomlib/circuits", "../../node_modules/@zk-kit/circuits/circom"],
"include": ["../../node_modules/circomlib/circuits", "../../node_modules/@zk-kit/binary-merkle-root.circom/src"],

@@ -24,7 +24,7 @@
"access": "public"
},
"dependencies": {
"@zk-kit/binary-merkle-root.circom": "1.0.0",
"@zk-kit/circuits": "0.2.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@zk-kit/circuits": "0.2.4",
"@zk-kit/binary-merkle-root.circom": "1.0.0",

@@ -40,16 +45,16 @@ export default class SemaphoreEthers {
* @param options Configuration options for the ethers provider and the Semaphore contract.
*/
constructor(networkOrEthereumURL: EthersNetwork | string = defaultNetwork, options: EthersOptions = {}) {
checkParameter(networkOrEthereumURL, "networkOrSubgraphURL", "string")
requireString(networkOrEthereumURL, "networkOrSubgraphURL");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; is not allowed in this repo. Please, run yarn format:write to format the code automatically.

Comment on lines -239 to -259

describe("isGroupMember", () => {
it("Should return true because the member is part of the group", async () => {
const semaphore = new SemaphoreEthers()

const isMember = await semaphore.isGroupMember("42", "1")

expect(isMember).toBeTruthy()
})
it("Should return false because the member is not part of the group", async () => {
ContractMocked.mockReturnValueOnce({
hasMember: () => false
} as any)

const semaphore = new SemaphoreEthers()

const isMember = await semaphore.isGroupMember("48", "2")

expect(isMember).toBeFalsy()
})
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this test been removed?

Comment on lines -61 to -84

it("Should generate a Semaphore proof without passing the tree depth", async () => {
const group = new Group([1n, 2n, identity.commitment])

proof = await generateProof(identity, group, message, scope)

expect(typeof proof).toBe("object")
expect(BigInt(proof.merkleTreeRoot)).toBe(group.root)
}, 70000)

it("Should throw an error because snarkArtifacts is not an object", async () => {
const group = new Group([1n, 2n, identity.commitment])
const fun = () => generateProof(identity, group, message, scope, undefined, "hello" as any)

await expect(fun).rejects.toThrow("is not an object")
})

it("Should throw an error because the message value is incorrect", async () => {
const group = new Group([1n, 2n, identity.commitment])

const fun = () => generateProof(identity, group, Number.MAX_VALUE, scope, treeDepth)

await expect(fun).rejects.toThrow("overflow")
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was to keep when you merged from the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@semaphore-protocol/data uses utility functions that can be replaced by @zk-kit/utils
2 participants