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 +9 -10
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +1 -1
- package/package.json +1 -1
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(
|
|
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
|
|
106
|
-
const participant2Keys = generateKeys(2, threshold
|
|
107
|
-
const participant3Keys = generateKeys(3, threshold
|
|
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(
|
|
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
|
|
166
|
-
const participant2Keys = generateKeys(2, threshold
|
|
167
|
-
const participant3Keys = generateKeys(3, threshold
|
|
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(
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -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
|
|
24
|
+
export declare const getGroup: (primeBits?: 2048 | 3072 | 4096) => {
|
|
25
25
|
prime: bigint;
|
|
26
26
|
generator: bigint;
|
|
27
27
|
};
|
package/dist/utils/utils.js
CHANGED
|
@@ -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;
|