threshold-elgamal 0.1.26 → 0.1.27

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/README.md CHANGED
@@ -97,14 +97,13 @@ import {
97
97
  thresholdDecrypt,
98
98
  } from "threshold-elgamal";
99
99
 
100
- const primeBits = 2048; // Bit length of the prime modulus
101
100
  const threshold = 3; // A scenario for 3 participants with a threshold of 3
102
- const { prime, generator } = getGroup(2048);
101
+ const { prime, generator } = getGroup(); // 2048-bit by default
103
102
 
104
103
  // Each participant generates their public key share and private key individually
105
- const participant1Keys = generateKeys(1, threshold, primeBits);
106
- const participant2Keys = generateKeys(2, threshold, primeBits);
107
- const participant3Keys = generateKeys(3, threshold, primeBits);
104
+ const participant1Keys = generateKeys(1, threshold);
105
+ const participant2Keys = generateKeys(2, threshold);
106
+ const participant3Keys = generateKeys(3, threshold);
108
107
 
109
108
  // Combine the public keys to form a single public key
110
109
  const combinedPublicKey = combinePublicKeys(
@@ -139,6 +138,7 @@ const thresholdDecryptedMessage = thresholdDecrypt(
139
138
  prime,
140
139
  );
141
140
  console.log(thresholdDecryptedMessage); // 42
141
+ expect(thresholdDecryptedMessage).toBe(secret);
142
142
  ```
143
143
 
144
144
  ### Voting and multiplication with threshold scheme for 3 participants
@@ -157,14 +157,13 @@ import {
157
157
  getGroup,
158
158
  } from "threshold-elgamal";
159
159
 
160
- const primeBits = 2048; // Bit length of the prime modulus
161
160
  const threshold = 3; // A scenario for 3 participants with a threshold of 3
162
- const { prime, generator } = getGroup(2048);
161
+ const { prime, generator } = getGroup(); // 2048-bit by default
163
162
 
164
163
  // Each participant generates their public key share and private key individually
165
- const participant1Keys = generateKeys(1, threshold, primeBits);
166
- const participant2Keys = generateKeys(2, threshold, primeBits);
167
- const participant3Keys = generateKeys(3, threshold, primeBits);
164
+ const participant1Keys = generateKeys(1, threshold);
165
+ const participant2Keys = generateKeys(2, threshold);
166
+ const participant3Keys = generateKeys(3, threshold);
168
167
 
169
168
  // Combine the public keys to form a single public key
170
169
  const combinedPublicKey = combinePublicKeys(
@@ -21,7 +21,7 @@ export declare const randomBigint: (bits: number) => bigint;
21
21
  * @param {2048 | 3072 | 4096} primeBits - The bit length of the prime modulus (2048, 3072, or 4096).
22
22
  * @returns {Object} The group parameters including prime and generator.
23
23
  */
24
- export declare const getGroup: (primeBits: 2048 | 3072 | 4096) => {
24
+ export declare const getGroup: (primeBits?: 2048 | 3072 | 4096) => {
25
25
  prime: bigint;
26
26
  generator: bigint;
27
27
  };
@@ -37,7 +37,7 @@ export const randomBigint = (bits) => {
37
37
  * @param {2048 | 3072 | 4096} primeBits - The bit length of the prime modulus (2048, 3072, or 4096).
38
38
  * @returns {Object} The group parameters including prime and generator.
39
39
  */
40
- export const getGroup = (primeBits) => {
40
+ export const getGroup = (primeBits = 2048) => {
41
41
  switch (primeBits) {
42
42
  case 2048:
43
43
  return GROUPS.ffdhe2048;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "threshold-elgamal",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Threshold ElGamal in TypeScript",
5
5
  "author": "Piotr Piech <piotr@piech.dev>",
6
6
  "license": "MIT",