@semaphore-protocol/identity 4.3.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,4 +94,17 @@ export declare class Identity {
94
94
  * @returns A boolean indicating whether the signature is valid.
95
95
  */
96
96
  static verifySignature(message: BigNumberish, signature: Signature, publicKey: Point): boolean;
97
+ /**
98
+ * Generates the commitment from the given public key.
99
+ * This static method is particularly useful after signature verification,
100
+ * as it allows retrieval of the corresponding commitment associated with the public key.
101
+ *
102
+ * @example
103
+ * const identity = new Identity()
104
+ * Identity.generateCommitment(identity.publicKey)
105
+ *
106
+ * @param publicKey The public key to generate the commitment.
107
+ * @returns The Semaphore identity commitment.
108
+ */
109
+ static generateCommitment(publicKey: Point): bigint;
97
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/identity",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "A library to create Semaphore identities.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,17 +31,15 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rollup/plugin-alias": "^5.1.0",
34
- "@rollup/plugin-commonjs": "^25.0.7",
35
- "@rollup/plugin-node-resolve": "^15.2.3",
36
34
  "@rollup/plugin-typescript": "^11.1.6",
37
35
  "rimraf": "^5.0.5",
38
36
  "rollup": "^4.12.0",
39
37
  "rollup-plugin-cleanup": "^3.2.1"
40
38
  },
41
39
  "dependencies": {
42
- "@zk-kit/baby-jubjub": "1.0.1",
43
- "@zk-kit/eddsa-poseidon": "1.0.2",
44
- "@zk-kit/utils": "1.2.0",
45
- "poseidon-lite": "0.2.0"
40
+ "@zk-kit/baby-jubjub": "1.0.3",
41
+ "@zk-kit/eddsa-poseidon": "1.0.4",
42
+ "@zk-kit/utils": "1.2.1",
43
+ "poseidon-lite": "0.3.0"
46
44
  }
47
45
  }
package/src/index.ts CHANGED
@@ -138,4 +138,20 @@ export class Identity {
138
138
  static verifySignature(message: BigNumberish, signature: Signature, publicKey: Point): boolean {
139
139
  return verifySignature(message, signature, publicKey)
140
140
  }
141
+
142
+ /**
143
+ * Generates the commitment from the given public key.
144
+ * This static method is particularly useful after signature verification,
145
+ * as it allows retrieval of the corresponding commitment associated with the public key.
146
+ *
147
+ * @example
148
+ * const identity = new Identity()
149
+ * Identity.generateCommitment(identity.publicKey)
150
+ *
151
+ * @param publicKey The public key to generate the commitment.
152
+ * @returns The Semaphore identity commitment.
153
+ */
154
+ static generateCommitment(publicKey: Point): bigint {
155
+ return poseidon2(publicKey)
156
+ }
141
157
  }