mirror of
https://github.com/interep-project/contracts.git
synced 2026-01-13 23:37:59 -05:00
24 lines
754 B
TypeScript
24 lines
754 B
TypeScript
import { Identity } from "@semaphore-protocol/identity"
|
|
import { utils } from "ethers"
|
|
|
|
export const SNARK_SCALAR_FIELD = BigInt(
|
|
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
|
|
)
|
|
|
|
export function createGroupId(provider: string, name: string): bigint {
|
|
return BigInt(utils.solidityKeccak256(["bytes32", "bytes32"], [provider, name])) % SNARK_SCALAR_FIELD
|
|
}
|
|
|
|
export function createIdentityCommitments(n: number): bigint[] {
|
|
const identityCommitments: bigint[] = []
|
|
|
|
for (let i = 0; i < n; i++) {
|
|
const identity = new Identity(i.toString())
|
|
const identityCommitment = identity.generateCommitment()
|
|
|
|
identityCommitments.push(identityCommitment)
|
|
}
|
|
|
|
return identityCommitments
|
|
}
|