@semaphore-protocol/identity 4.0.0-beta.4 → 4.0.0-beta.5

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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/identity
3
- * @version 4.0.0-beta.4
3
+ * @version 4.0.0-beta.5
4
4
  * @file A library to create Semaphore identities.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -2248,7 +2248,7 @@ function poseidon2(inputs) {
2248
2248
  * The private key of the identity is stored as a hexadecimal string or text.
2249
2249
  * The other attributes are stored as stringified bigint.
2250
2250
  */
2251
- var Identity = /** @class */ (function () {
2251
+ class Identity {
2252
2252
  /**
2253
2253
  * Initializes the class attributes based on a given private key, which must be a hexadecimal string or a text.
2254
2254
  * Hexadecimal strings must not start with '0x' or '0X'.
@@ -2265,8 +2265,8 @@ var Identity = /** @class */ (function () {
2265
2265
  *
2266
2266
  * @param privateKey The private key used to derive the public key (hexadecimal or string).
2267
2267
  */
2268
- function Identity(privateKey) {
2269
- var eddsa;
2268
+ constructor(privateKey) {
2269
+ let eddsa;
2270
2270
  if (privateKey) {
2271
2271
  requireString(privateKey, "privateKey");
2272
2272
  this._privateKey = privateKey;
@@ -2285,50 +2285,34 @@ var Identity = /** @class */ (function () {
2285
2285
  this._publicKey = eddsa.publicKey;
2286
2286
  this._commitment = poseidon2_2(this._publicKey);
2287
2287
  }
2288
- Object.defineProperty(Identity.prototype, "privateKey", {
2289
- /**
2290
- * Returns the private key.
2291
- * @returns The private key as a string (hexadecimal or text).
2292
- */
2293
- get: function () {
2294
- return this._privateKey;
2295
- },
2296
- enumerable: false,
2297
- configurable: true
2298
- });
2299
- Object.defineProperty(Identity.prototype, "secretScalar", {
2300
- /**
2301
- * Returns the secret scalar.
2302
- * @returns The secret scalar as a string.
2303
- */
2304
- get: function () {
2305
- return this._secretScalar;
2306
- },
2307
- enumerable: false,
2308
- configurable: true
2309
- });
2310
- Object.defineProperty(Identity.prototype, "publicKey", {
2311
- /**
2312
- * Returns the public key as a Baby Jubjub {@link https://zkkit.pse.dev/types/_zk_kit_baby_jubjub.Point.html | Point}.
2313
- * @returns The public key as a point.
2314
- */
2315
- get: function () {
2316
- return this._publicKey;
2317
- },
2318
- enumerable: false,
2319
- configurable: true
2320
- });
2321
- Object.defineProperty(Identity.prototype, "commitment", {
2322
- /**
2323
- * Returns the commitment hash of the public key.
2324
- * @returns The commitment as a string.
2325
- */
2326
- get: function () {
2327
- return this._commitment;
2328
- },
2329
- enumerable: false,
2330
- configurable: true
2331
- });
2288
+ /**
2289
+ * Returns the private key.
2290
+ * @returns The private key as a string (hexadecimal or text).
2291
+ */
2292
+ get privateKey() {
2293
+ return this._privateKey;
2294
+ }
2295
+ /**
2296
+ * Returns the secret scalar.
2297
+ * @returns The secret scalar as a string.
2298
+ */
2299
+ get secretScalar() {
2300
+ return this._secretScalar;
2301
+ }
2302
+ /**
2303
+ * Returns the public key as a Baby Jubjub {@link https://zkkit.pse.dev/types/_zk_kit_baby_jubjub.Point.html | Point}.
2304
+ * @returns The public key as a point.
2305
+ */
2306
+ get publicKey() {
2307
+ return this._publicKey;
2308
+ }
2309
+ /**
2310
+ * Returns the commitment hash of the public key.
2311
+ * @returns The commitment as a string.
2312
+ */
2313
+ get commitment() {
2314
+ return this._commitment;
2315
+ }
2332
2316
  /**
2333
2317
  * Generates a signature for a given message using the private key.
2334
2318
  * This method demonstrates how to sign a message and could be used
@@ -2341,9 +2325,9 @@ var Identity = /** @class */ (function () {
2341
2325
  * @param message The message to be signed.
2342
2326
  * @returns A {@link https://zkkit.pse.dev/types/_zk_kit_eddsa_poseidon.Signature.html | Signature} object containing the signature components.
2343
2327
  */
2344
- Identity.prototype.signMessage = function (message) {
2328
+ signMessage(message) {
2345
2329
  return eddsaPoseidon.signMessage(this.privateKey, message);
2346
- };
2330
+ }
2347
2331
  /**
2348
2332
  * Verifies a signature against a given message and public key.
2349
2333
  * This static method allows for the verification of signatures without needing
@@ -2360,10 +2344,9 @@ var Identity = /** @class */ (function () {
2360
2344
  * @param publicKey The public key to use for verification.
2361
2345
  * @returns A boolean indicating whether the signature is valid.
2362
2346
  */
2363
- Identity.verifySignature = function (message, signature, publicKey) {
2347
+ static verifySignature(message, signature, publicKey) {
2364
2348
  return eddsaPoseidon.verifySignature(message, signature, publicKey);
2365
- };
2366
- return Identity;
2367
- }());
2349
+ }
2350
+ }
2368
2351
 
2369
2352
  exports.Identity = Identity;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/identity
3
- * @version 4.0.0-beta.4
3
+ * @version 4.0.0-beta.5
4
4
  * @file A library to create Semaphore identities.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
7
7
  * @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/identity}
8
8
  */
9
- import { signMessage, verifySignature, EdDSAPoseidon } from '@zk-kit/eddsa-poseidon';
9
+ import { EdDSAPoseidon, signMessage, verifySignature } from '@zk-kit/eddsa-poseidon';
10
10
 
11
11
  function getDefaultExportFromCjs (x) {
12
12
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -2246,7 +2246,7 @@ function poseidon2(inputs) {
2246
2246
  * The private key of the identity is stored as a hexadecimal string or text.
2247
2247
  * The other attributes are stored as stringified bigint.
2248
2248
  */
2249
- var Identity = /** @class */ (function () {
2249
+ class Identity {
2250
2250
  /**
2251
2251
  * Initializes the class attributes based on a given private key, which must be a hexadecimal string or a text.
2252
2252
  * Hexadecimal strings must not start with '0x' or '0X'.
@@ -2263,8 +2263,8 @@ var Identity = /** @class */ (function () {
2263
2263
  *
2264
2264
  * @param privateKey The private key used to derive the public key (hexadecimal or string).
2265
2265
  */
2266
- function Identity(privateKey) {
2267
- var eddsa;
2266
+ constructor(privateKey) {
2267
+ let eddsa;
2268
2268
  if (privateKey) {
2269
2269
  requireString(privateKey, "privateKey");
2270
2270
  this._privateKey = privateKey;
@@ -2283,50 +2283,34 @@ var Identity = /** @class */ (function () {
2283
2283
  this._publicKey = eddsa.publicKey;
2284
2284
  this._commitment = poseidon2_2(this._publicKey);
2285
2285
  }
2286
- Object.defineProperty(Identity.prototype, "privateKey", {
2287
- /**
2288
- * Returns the private key.
2289
- * @returns The private key as a string (hexadecimal or text).
2290
- */
2291
- get: function () {
2292
- return this._privateKey;
2293
- },
2294
- enumerable: false,
2295
- configurable: true
2296
- });
2297
- Object.defineProperty(Identity.prototype, "secretScalar", {
2298
- /**
2299
- * Returns the secret scalar.
2300
- * @returns The secret scalar as a string.
2301
- */
2302
- get: function () {
2303
- return this._secretScalar;
2304
- },
2305
- enumerable: false,
2306
- configurable: true
2307
- });
2308
- Object.defineProperty(Identity.prototype, "publicKey", {
2309
- /**
2310
- * Returns the public key as a Baby Jubjub {@link https://zkkit.pse.dev/types/_zk_kit_baby_jubjub.Point.html | Point}.
2311
- * @returns The public key as a point.
2312
- */
2313
- get: function () {
2314
- return this._publicKey;
2315
- },
2316
- enumerable: false,
2317
- configurable: true
2318
- });
2319
- Object.defineProperty(Identity.prototype, "commitment", {
2320
- /**
2321
- * Returns the commitment hash of the public key.
2322
- * @returns The commitment as a string.
2323
- */
2324
- get: function () {
2325
- return this._commitment;
2326
- },
2327
- enumerable: false,
2328
- configurable: true
2329
- });
2286
+ /**
2287
+ * Returns the private key.
2288
+ * @returns The private key as a string (hexadecimal or text).
2289
+ */
2290
+ get privateKey() {
2291
+ return this._privateKey;
2292
+ }
2293
+ /**
2294
+ * Returns the secret scalar.
2295
+ * @returns The secret scalar as a string.
2296
+ */
2297
+ get secretScalar() {
2298
+ return this._secretScalar;
2299
+ }
2300
+ /**
2301
+ * Returns the public key as a Baby Jubjub {@link https://zkkit.pse.dev/types/_zk_kit_baby_jubjub.Point.html | Point}.
2302
+ * @returns The public key as a point.
2303
+ */
2304
+ get publicKey() {
2305
+ return this._publicKey;
2306
+ }
2307
+ /**
2308
+ * Returns the commitment hash of the public key.
2309
+ * @returns The commitment as a string.
2310
+ */
2311
+ get commitment() {
2312
+ return this._commitment;
2313
+ }
2330
2314
  /**
2331
2315
  * Generates a signature for a given message using the private key.
2332
2316
  * This method demonstrates how to sign a message and could be used
@@ -2339,9 +2323,9 @@ var Identity = /** @class */ (function () {
2339
2323
  * @param message The message to be signed.
2340
2324
  * @returns A {@link https://zkkit.pse.dev/types/_zk_kit_eddsa_poseidon.Signature.html | Signature} object containing the signature components.
2341
2325
  */
2342
- Identity.prototype.signMessage = function (message) {
2326
+ signMessage(message) {
2343
2327
  return signMessage(this.privateKey, message);
2344
- };
2328
+ }
2345
2329
  /**
2346
2330
  * Verifies a signature against a given message and public key.
2347
2331
  * This static method allows for the verification of signatures without needing
@@ -2358,10 +2342,9 @@ var Identity = /** @class */ (function () {
2358
2342
  * @param publicKey The public key to use for verification.
2359
2343
  * @returns A boolean indicating whether the signature is valid.
2360
2344
  */
2361
- Identity.verifySignature = function (message, signature, publicKey) {
2345
+ static verifySignature(message, signature, publicKey) {
2362
2346
  return verifySignature(message, signature, publicKey);
2363
- };
2364
- return Identity;
2365
- }());
2347
+ }
2348
+ }
2366
2349
 
2367
2350
  export { Identity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/identity",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "A library to create Semaphore identities.",
5
5
  "type": "module",
6
6
  "license": "MIT",