@maci-protocol/domainobjs 0.0.0-ci.f9da2fc → 0.0.0-ci.fb960ed
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/build/ts/commands/PCommand.d.ts +7 -7
- package/build/ts/commands/PCommand.d.ts.map +1 -1
- package/build/ts/commands/PCommand.js +13 -13
- package/build/ts/commands/PCommand.js.map +1 -1
- package/build/ts/commands/types.d.ts +1 -1
- package/build/ts/commands/types.d.ts.map +1 -1
- package/build/ts/constants.d.ts +2 -2
- package/build/ts/constants.d.ts.map +1 -1
- package/build/ts/constants.js +1 -1
- package/build/ts/constants.js.map +1 -1
- package/build/ts/index.d.ts +2 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +3 -3
- package/build/ts/index.js.map +1 -1
- package/build/ts/keyPair.d.ts +10 -10
- package/build/ts/keyPair.d.ts.map +1 -1
- package/build/ts/keyPair.js +19 -19
- package/build/ts/keyPair.js.map +1 -1
- package/build/ts/message.d.ts +3 -3
- package/build/ts/message.d.ts.map +1 -1
- package/build/ts/message.js +2 -2
- package/build/ts/message.js.map +1 -1
- package/build/ts/privateKey.d.ts +7 -7
- package/build/ts/privateKey.d.ts.map +1 -1
- package/build/ts/privateKey.js +11 -11
- package/build/ts/privateKey.js.map +1 -1
- package/build/ts/publicKey.d.ts +9 -9
- package/build/ts/publicKey.d.ts.map +1 -1
- package/build/ts/publicKey.js +14 -14
- package/build/ts/publicKey.js.map +1 -1
- package/build/ts/stateLeaf.d.ts +4 -4
- package/build/ts/stateLeaf.d.ts.map +1 -1
- package/build/ts/stateLeaf.js +13 -13
- package/build/ts/stateLeaf.js.map +1 -1
- package/build/ts/types.d.ts +8 -8
- package/build/ts/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Signature, type EcdhSharedKey } from "@maci-protocol/crypto";
|
|
2
2
|
import type { IJsonPCommand } from "./types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PrivateKey } from "../privateKey";
|
|
4
4
|
import { Message } from "../message";
|
|
5
|
-
import {
|
|
5
|
+
import { PublicKey } from "../publicKey";
|
|
6
6
|
export interface IDecryptMessage {
|
|
7
7
|
command: PCommand;
|
|
8
8
|
signature: Signature;
|
|
@@ -13,7 +13,7 @@ export interface IDecryptMessage {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class PCommand {
|
|
15
15
|
stateIndex: bigint;
|
|
16
|
-
|
|
16
|
+
newPublicKey: PublicKey;
|
|
17
17
|
voteOptionIndex: bigint;
|
|
18
18
|
newVoteWeight: bigint;
|
|
19
19
|
nonce: bigint;
|
|
@@ -22,14 +22,14 @@ export declare class PCommand {
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a new PCommand
|
|
24
24
|
* @param stateIndex the state index of the user
|
|
25
|
-
* @param
|
|
25
|
+
* @param newPublicKey the new public key of the user
|
|
26
26
|
* @param voteOptionIndex the index of the vote option
|
|
27
27
|
* @param newVoteWeight the new vote weight of the user
|
|
28
28
|
* @param nonce the nonce of the message
|
|
29
29
|
* @param pollId the poll ID
|
|
30
30
|
* @param salt the salt of the message
|
|
31
31
|
*/
|
|
32
|
-
constructor(stateIndex: bigint,
|
|
32
|
+
constructor(stateIndex: bigint, newPublicKey: PublicKey, voteOptionIndex: bigint, newVoteWeight: bigint, nonce: bigint, pollId: bigint, salt?: bigint);
|
|
33
33
|
/**
|
|
34
34
|
* Create a deep clone of this PCommand
|
|
35
35
|
* @returns a copy of the PCommand
|
|
@@ -48,13 +48,13 @@ export declare class PCommand {
|
|
|
48
48
|
/**
|
|
49
49
|
* @notice Signs this command and returns a Signature.
|
|
50
50
|
*/
|
|
51
|
-
sign: (
|
|
51
|
+
sign: (privateKey: PrivateKey) => Signature;
|
|
52
52
|
/**
|
|
53
53
|
* @notice Returns true if the given signature is a correct signature of this
|
|
54
54
|
* command and signed by the private key associated with the given public
|
|
55
55
|
* key.
|
|
56
56
|
*/
|
|
57
|
-
verifySignature: (signature: Signature,
|
|
57
|
+
verifySignature: (signature: Signature, publicKey: PublicKey) => boolean;
|
|
58
58
|
/**
|
|
59
59
|
* @notice Encrypts this command along with a signature to produce a Message.
|
|
60
60
|
* To save gas, we can constrain the following values to 50 bits and pack
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PCommand.d.ts","sourceRoot":"","sources":["../../../ts/commands/PCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EAEd,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"PCommand.d.ts","sourceRoot":"","sources":["../../../ts/commands/PCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EAEd,KAAK,aAAa,EAGnB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,QAAQ,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,UAAU,EAAE,MAAM,CAAC;IAEnB,YAAY,EAAE,SAAS,CAAC;IAExB,eAAe,EAAE,MAAM,CAAC;IAExB,aAAa,EAAE,MAAM,CAAC;IAEtB,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IAEf,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;OASG;gBAED,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAwB;IAkBhC;;;OAGG;IACH,IAAI,GAAI,CAAC,SAAS,QAAQ,OAAK,CAAC,CASZ;IAEpB;;;;;OAKG;IACH,OAAO,QAAO,MAAM,EAAE,CAcpB;IAEF,eAAe,QAAO,MAAM,EAAE,CAAmB;IAKjD,MAAM,GAAI,SAAS,QAAQ,KAAG,OAAO,CAOR;IAE7B,IAAI,QAAO,MAAM,CAA0B;IAE3C;;OAEG;IACH,IAAI,GAAI,YAAY,UAAU,KAAG,SAAS,CAAwD;IAElG;;;;OAIG;IACH,eAAe,GAAI,WAAW,SAAS,EAAE,WAAW,SAAS,KAAG,OAAO,CACR;IAE/D;;;;;;;;;OASG;IACH,OAAO,GAAI,WAAW,SAAS,EAAE,WAAW,aAAa,KAAG,OAAO,CAUjE;IAEF;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,GAAI,SAAS,OAAO,EAAE,WAAW,aAAa,EAAE,eAAa,KAAG,eAAe,CAyC3F;IAEF;;OAEG;IACH,MAAM,IAAI,aAAa;IAYvB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ;CAa/C"}
|
|
@@ -16,19 +16,19 @@ class PCommand {
|
|
|
16
16
|
/**
|
|
17
17
|
* Create a new PCommand
|
|
18
18
|
* @param stateIndex the state index of the user
|
|
19
|
-
* @param
|
|
19
|
+
* @param newPublicKey the new public key of the user
|
|
20
20
|
* @param voteOptionIndex the index of the vote option
|
|
21
21
|
* @param newVoteWeight the new vote weight of the user
|
|
22
22
|
* @param nonce the nonce of the message
|
|
23
23
|
* @param pollId the poll ID
|
|
24
24
|
* @param salt the salt of the message
|
|
25
25
|
*/
|
|
26
|
-
constructor(stateIndex,
|
|
26
|
+
constructor(stateIndex, newPublicKey, voteOptionIndex, newVoteWeight, nonce, pollId, salt = (0, crypto_1.genRandomSalt)()) {
|
|
27
27
|
/**
|
|
28
28
|
* Create a deep clone of this PCommand
|
|
29
29
|
* @returns a copy of the PCommand
|
|
30
30
|
*/
|
|
31
|
-
this.copy = () => new PCommand(BigInt(this.stateIndex.toString()), this.
|
|
31
|
+
this.copy = () => new PCommand(BigInt(this.stateIndex.toString()), this.newPublicKey.copy(), BigInt(this.voteOptionIndex.toString()), BigInt(this.newVoteWeight.toString()), BigInt(this.nonce.toString()), BigInt(this.pollId.toString()), BigInt(this.salt.toString()));
|
|
32
32
|
/**
|
|
33
33
|
* @notice Returns this Command as an array. Note that 5 of the Command's fields
|
|
34
34
|
* are packed into a single 250-bit value. This allows Messages to be
|
|
@@ -43,7 +43,7 @@ class PCommand {
|
|
|
43
43
|
(BigInt(this.nonce) << BigInt(150)) +
|
|
44
44
|
(BigInt(this.pollId) << BigInt(200));
|
|
45
45
|
/* eslint-enable no-bitwise */
|
|
46
|
-
const command = [params, ...this.
|
|
46
|
+
const command = [params, ...this.newPublicKey.asArray(), this.salt];
|
|
47
47
|
(0, assert_1.default)(command.length === 4);
|
|
48
48
|
return command;
|
|
49
49
|
};
|
|
@@ -52,7 +52,7 @@ class PCommand {
|
|
|
52
52
|
* Check whether this command has deep equivalence to another command
|
|
53
53
|
*/
|
|
54
54
|
this.equals = (command) => this.stateIndex === command.stateIndex &&
|
|
55
|
-
this.
|
|
55
|
+
this.newPublicKey.equals(command.newPublicKey) &&
|
|
56
56
|
this.voteOptionIndex === command.voteOptionIndex &&
|
|
57
57
|
this.newVoteWeight === command.newVoteWeight &&
|
|
58
58
|
this.nonce === command.nonce &&
|
|
@@ -62,13 +62,13 @@ class PCommand {
|
|
|
62
62
|
/**
|
|
63
63
|
* @notice Signs this command and returns a Signature.
|
|
64
64
|
*/
|
|
65
|
-
this.sign = (
|
|
65
|
+
this.sign = (privateKey) => (0, crypto_1.sign)(privateKey.rawPrivKey.toString(), this.hash());
|
|
66
66
|
/**
|
|
67
67
|
* @notice Returns true if the given signature is a correct signature of this
|
|
68
68
|
* command and signed by the private key associated with the given public
|
|
69
69
|
* key.
|
|
70
70
|
*/
|
|
71
|
-
this.verifySignature = (signature,
|
|
71
|
+
this.verifySignature = (signature, publicKey) => (0, crypto_1.verifySignature)(this.hash(), signature, publicKey.rawPubKey);
|
|
72
72
|
/**
|
|
73
73
|
* @notice Encrypts this command along with a signature to produce a Message.
|
|
74
74
|
* To save gas, we can constrain the following values to 50 bits and pack
|
|
@@ -93,7 +93,7 @@ class PCommand {
|
|
|
93
93
|
(0, assert_1.default)(limit50Bits >= nonce);
|
|
94
94
|
(0, assert_1.default)(limit50Bits >= pollId);
|
|
95
95
|
this.stateIndex = stateIndex;
|
|
96
|
-
this.
|
|
96
|
+
this.newPublicKey = newPublicKey;
|
|
97
97
|
this.voteOptionIndex = voteOptionIndex;
|
|
98
98
|
this.newVoteWeight = newVoteWeight;
|
|
99
99
|
this.nonce = nonce;
|
|
@@ -106,7 +106,7 @@ class PCommand {
|
|
|
106
106
|
toJSON() {
|
|
107
107
|
return {
|
|
108
108
|
stateIndex: this.stateIndex.toString(),
|
|
109
|
-
|
|
109
|
+
newPublicKey: this.newPublicKey.serialize(),
|
|
110
110
|
voteOptionIndex: this.voteOptionIndex.toString(),
|
|
111
111
|
newVoteWeight: this.newVoteWeight.toString(),
|
|
112
112
|
nonce: this.nonce.toString(),
|
|
@@ -120,7 +120,7 @@ class PCommand {
|
|
|
120
120
|
* @returns a PCommand instance
|
|
121
121
|
*/
|
|
122
122
|
static fromJSON(json) {
|
|
123
|
-
const command = new PCommand(BigInt(json.stateIndex), publicKey_1.
|
|
123
|
+
const command = new PCommand(BigInt(json.stateIndex), publicKey_1.PublicKey.deserialize(json.newPublicKey), BigInt(json.voteOptionIndex), BigInt(json.newVoteWeight), BigInt(json.nonce), BigInt(json.pollId), BigInt(json.salt));
|
|
124
124
|
return command;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -158,10 +158,10 @@ PCommand.decrypt = (message, sharedKey, force = false) => {
|
|
|
158
158
|
const nonce = extract(p, 150);
|
|
159
159
|
const pollId = extract(p, 200);
|
|
160
160
|
// create new public key but allow it to be invalid (as when passing an mismatched
|
|
161
|
-
//
|
|
162
|
-
const
|
|
161
|
+
// encryptionPublicKey, a message will not decrypt resulting in potentially invalid public keys)
|
|
162
|
+
const newPublicKey = new publicKey_1.PublicKey([decrypted[1], decrypted[2]], true);
|
|
163
163
|
const salt = decrypted[3];
|
|
164
|
-
const command = new PCommand(stateIndex,
|
|
164
|
+
const command = new PCommand(stateIndex, newPublicKey, voteOptionIndex, newVoteWeight, nonce, pollId, salt);
|
|
165
165
|
const signature = {
|
|
166
166
|
R8: [decrypted[4], decrypted[5]],
|
|
167
167
|
S: decrypted[6],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PCommand.js","sourceRoot":"","sources":["../../../ts/commands/PCommand.ts"],"names":[],"mappings":";;;;;;AAAA,kDAY+B;AAE/B,oDAA4B;AAK5B,wCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"PCommand.js","sourceRoot":"","sources":["../../../ts/commands/PCommand.ts"],"names":[],"mappings":";;;;;;AAAA,kDAY+B;AAE/B,oDAA4B;AAK5B,wCAAqC;AACrC,4CAAyC;AAOzC;;;GAGG;AACH,MAAa,QAAQ;IAenB;;;;;;;;;OASG;IACH,YACE,UAAkB,EAClB,YAAuB,EACvB,eAAuB,EACvB,aAAqB,EACrB,KAAa,EACb,MAAc,EACd,OAAe,IAAA,sBAAa,GAAE;QAkBhC;;;WAGG;QACH,SAAI,GAAG,GAA0B,EAAE,CACjC,IAAI,QAAQ,CACV,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAClC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,EACxB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EACvC,MAAM,CAAC,IAAI,CAA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AM,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/commands/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/build/ts/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "./publicKey";
|
|
2
2
|
import { StateLeaf } from "./stateLeaf";
|
|
3
3
|
export declare const blankStateLeaf: StateLeaf;
|
|
4
4
|
export declare const blankStateLeafHash: bigint;
|
|
5
|
-
export declare const padKey:
|
|
5
|
+
export declare const padKey: PublicKey;
|
|
6
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../ts/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../ts/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,cAAc,WAA2B,CAAC;AACvD,eAAO,MAAM,kBAAkB,QAAwB,CAAC;AACxD,eAAO,MAAM,MAAM,WAAwB,CAAC"}
|
package/build/ts/constants.js
CHANGED
|
@@ -5,5 +5,5 @@ const publicKey_1 = require("./publicKey");
|
|
|
5
5
|
const stateLeaf_1 = require("./stateLeaf");
|
|
6
6
|
exports.blankStateLeaf = stateLeaf_1.StateLeaf.genBlankLeaf();
|
|
7
7
|
exports.blankStateLeafHash = exports.blankStateLeaf.hash();
|
|
8
|
-
exports.padKey = publicKey_1.
|
|
8
|
+
exports.padKey = publicKey_1.PublicKey.genPadKey();
|
|
9
9
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../ts/constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../ts/constants.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,2CAAwC;AAE3B,QAAA,cAAc,GAAG,qBAAS,CAAC,YAAY,EAAE,CAAC;AAC1C,QAAA,kBAAkB,GAAG,sBAAc,CAAC,IAAI,EAAE,CAAC;AAC3C,QAAA,MAAM,GAAG,qBAAS,CAAC,SAAS,EAAE,CAAC"}
|
package/build/ts/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Ballot } from "./ballot";
|
|
2
2
|
export { Message } from "./message";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { PrivateKey, SERIALIZED_PRIV_KEY_PREFIX } from "./privateKey";
|
|
4
|
+
export { PublicKey, SERIALIZED_PUB_KEY_PREFIX } from "./publicKey";
|
|
5
5
|
export { Keypair } from "./keyPair";
|
|
6
6
|
export { StateLeaf } from "./stateLeaf";
|
|
7
7
|
export { blankStateLeaf, blankStateLeafHash, padKey } from "./constants";
|
package/build/ts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEzE,YAAY,EACV,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/build/ts/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VerifyingKey = exports.PCommand = exports.padKey = exports.blankStateLeafHash = exports.blankStateLeaf = exports.StateLeaf = exports.Keypair = exports.SERIALIZED_PUB_KEY_PREFIX = exports.
|
|
3
|
+
exports.VerifyingKey = exports.PCommand = exports.padKey = exports.blankStateLeafHash = exports.blankStateLeaf = exports.StateLeaf = exports.Keypair = exports.SERIALIZED_PUB_KEY_PREFIX = exports.PublicKey = exports.SERIALIZED_PRIV_KEY_PREFIX = exports.PrivateKey = exports.Message = exports.Ballot = void 0;
|
|
4
4
|
var ballot_1 = require("./ballot");
|
|
5
5
|
Object.defineProperty(exports, "Ballot", { enumerable: true, get: function () { return ballot_1.Ballot; } });
|
|
6
6
|
var message_1 = require("./message");
|
|
7
7
|
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_1.Message; } });
|
|
8
8
|
var privateKey_1 = require("./privateKey");
|
|
9
|
-
Object.defineProperty(exports, "
|
|
9
|
+
Object.defineProperty(exports, "PrivateKey", { enumerable: true, get: function () { return privateKey_1.PrivateKey; } });
|
|
10
10
|
Object.defineProperty(exports, "SERIALIZED_PRIV_KEY_PREFIX", { enumerable: true, get: function () { return privateKey_1.SERIALIZED_PRIV_KEY_PREFIX; } });
|
|
11
11
|
var publicKey_1 = require("./publicKey");
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return publicKey_1.PublicKey; } });
|
|
13
13
|
Object.defineProperty(exports, "SERIALIZED_PUB_KEY_PREFIX", { enumerable: true, get: function () { return publicKey_1.SERIALIZED_PUB_KEY_PREFIX; } });
|
|
14
14
|
var keyPair_1 = require("./keyPair");
|
|
15
15
|
Object.defineProperty(exports, "Keypair", { enumerable: true, get: function () { return keyPair_1.Keypair; } });
|
package/build/ts/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,2CAAsE;AAA7D,wGAAA,UAAU,OAAA;AAAE,wHAAA,0BAA0B,OAAA;AAE/C,yCAAmE;AAA1D,sGAAA,SAAS,OAAA;AAAE,sHAAA,yBAAyB,OAAA;AAE7C,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,yCAAyE;AAAhE,2GAAA,cAAc,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAAE,mGAAA,MAAM,OAAA;AAmBnD,uCAA8E;AAA7B,oGAAA,QAAQ,OAAA;AAEzD,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
|
package/build/ts/keyPair.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EcdhSharedKey } from "@maci-protocol/crypto";
|
|
2
2
|
import type { IJsonKeyPair } from "./types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PrivateKey } from "./privateKey";
|
|
4
|
+
import { PublicKey } from "./publicKey";
|
|
5
5
|
/**
|
|
6
6
|
* @notice A KeyPair is a pair of public and private keys
|
|
7
7
|
* This is a MACI keypair, which is not to be
|
|
@@ -9,14 +9,14 @@ import { PubKey } from "./publicKey";
|
|
|
9
9
|
* A MACI keypair is comprised of a MACI public key and a MACI private key
|
|
10
10
|
*/
|
|
11
11
|
export declare class Keypair {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
privateKey: PrivateKey;
|
|
13
|
+
publicKey: PublicKey;
|
|
14
14
|
/**
|
|
15
15
|
* Create a new instance of a Keypair
|
|
16
|
-
* @param
|
|
17
|
-
* @notice if no
|
|
16
|
+
* @param privateKey the private key (optional)
|
|
17
|
+
* @notice if no privateKey is passed, it will automatically generate a new private key
|
|
18
18
|
*/
|
|
19
|
-
constructor(
|
|
19
|
+
constructor(privateKey?: PrivateKey);
|
|
20
20
|
/**
|
|
21
21
|
* Create a deep clone of this Keypair
|
|
22
22
|
* @returns a copy of the Keypair
|
|
@@ -24,11 +24,11 @@ export declare class Keypair {
|
|
|
24
24
|
copy: () => Keypair;
|
|
25
25
|
/**
|
|
26
26
|
* Generate a shared key
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
27
|
+
* @param privateKey
|
|
28
|
+
* @param publicKey
|
|
29
29
|
* @returns
|
|
30
30
|
*/
|
|
31
|
-
static genEcdhSharedKey(
|
|
31
|
+
static genEcdhSharedKey(privateKey: PrivateKey, publicKey: PublicKey): EcdhSharedKey;
|
|
32
32
|
/**
|
|
33
33
|
* Check whether two Keypairs are equal
|
|
34
34
|
* @param keypair the keypair to compare with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyPair.d.ts","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2C,MAAM,uBAAuB,CAAC;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keyPair.d.ts","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2C,MAAM,uBAAuB,CAAC;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,UAAU,EAAE,UAAU,CAAC;IAEvB,SAAS,EAAE,SAAS,CAAC;IAErB;;;;OAIG;gBACS,UAAU,CAAC,EAAE,UAAU;IAWnC;;;OAGG;IACH,IAAI,QAAO,OAAO,CAAwC;IAE1D;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa;IAIpF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAcjC;;OAEG;IACH,MAAM,IAAI,YAAY;IAOtB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;CAG7C"}
|
package/build/ts/keyPair.js
CHANGED
|
@@ -17,33 +17,33 @@ const publicKey_1 = require("./publicKey");
|
|
|
17
17
|
class Keypair {
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of a Keypair
|
|
20
|
-
* @param
|
|
21
|
-
* @notice if no
|
|
20
|
+
* @param privateKey the private key (optional)
|
|
21
|
+
* @notice if no privateKey is passed, it will automatically generate a new private key
|
|
22
22
|
*/
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(privateKey) {
|
|
24
24
|
/**
|
|
25
25
|
* Create a deep clone of this Keypair
|
|
26
26
|
* @returns a copy of the Keypair
|
|
27
27
|
*/
|
|
28
|
-
this.copy = () => new Keypair(this.
|
|
29
|
-
if (
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
28
|
+
this.copy = () => new Keypair(this.privateKey.copy());
|
|
29
|
+
if (privateKey) {
|
|
30
|
+
this.privateKey = privateKey;
|
|
31
|
+
this.publicKey = new publicKey_1.PublicKey((0, crypto_1.genPubKey)(privateKey.rawPrivKey));
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const rawKeyPair = (0, crypto_1.genKeypair)();
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
35
|
+
this.privateKey = new privateKey_1.PrivateKey(rawKeyPair.privateKey);
|
|
36
|
+
this.publicKey = new publicKey_1.PublicKey(rawKeyPair.publicKey);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Generate a shared key
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
41
|
+
* @param privateKey
|
|
42
|
+
* @param publicKey
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
|
-
static genEcdhSharedKey(
|
|
46
|
-
return (0, crypto_1.genEcdhSharedKey)(
|
|
45
|
+
static genEcdhSharedKey(privateKey, publicKey) {
|
|
46
|
+
return (0, crypto_1.genEcdhSharedKey)(privateKey.rawPrivKey, publicKey.rawPubKey);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Check whether two Keypairs are equal
|
|
@@ -51,9 +51,9 @@ class Keypair {
|
|
|
51
51
|
* @returns whether they are equal or not
|
|
52
52
|
*/
|
|
53
53
|
equals(keypair) {
|
|
54
|
-
const equalPrivKey = this.
|
|
55
|
-
const equalPubKey = this.
|
|
56
|
-
this.
|
|
54
|
+
const equalPrivKey = this.privateKey.rawPrivKey === keypair.privateKey.rawPrivKey;
|
|
55
|
+
const equalPubKey = this.publicKey.rawPubKey[0] === keypair.publicKey.rawPubKey[0] &&
|
|
56
|
+
this.publicKey.rawPubKey[1] === keypair.publicKey.rawPubKey[1];
|
|
57
57
|
// If this assertion fails, something is very wrong and this function
|
|
58
58
|
// should not return anything
|
|
59
59
|
// eslint-disable-next-line no-bitwise
|
|
@@ -65,8 +65,8 @@ class Keypair {
|
|
|
65
65
|
*/
|
|
66
66
|
toJSON() {
|
|
67
67
|
return {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
privateKey: this.privateKey.serialize(),
|
|
69
|
+
publicKey: this.publicKey.serialize(),
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -75,7 +75,7 @@ class Keypair {
|
|
|
75
75
|
* @returns a keypair instance
|
|
76
76
|
*/
|
|
77
77
|
static fromJSON(json) {
|
|
78
|
-
return new Keypair(privateKey_1.
|
|
78
|
+
return new Keypair(privateKey_1.PrivateKey.deserialize(json.privateKey));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
exports.Keypair = Keypair;
|
package/build/ts/keyPair.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyPair.js","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA+F;AAE/F,oDAA4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SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAEjE,qEAAqE;QACrE,6BAA6B;QAC7B,sCAAsC;QACtC,IAAA,gBAAM,EAAC,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QAExC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YACvC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;SACtC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAkB;QAChC,OAAO,IAAI,OAAO,CAAC,uBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AA1ED,0BA0EC"}
|
package/build/ts/message.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PublicKey } from "./publicKey";
|
|
2
2
|
import type { IMessageContractParams } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* @notice An encrypted command and signature.
|
|
@@ -29,10 +29,10 @@ export declare class Message {
|
|
|
29
29
|
asCircuitInputs: () => bigint[];
|
|
30
30
|
/**
|
|
31
31
|
* Hash the message data and a public key
|
|
32
|
-
* @param
|
|
32
|
+
* @param encryptionPublicKey the public key that is used to encrypt this message
|
|
33
33
|
* @returns the hash of the message data and the public key
|
|
34
34
|
*/
|
|
35
|
-
hash: (
|
|
35
|
+
hash: (encryptionPublicKey: PublicKey) => bigint;
|
|
36
36
|
/**
|
|
37
37
|
* Create a copy of the message
|
|
38
38
|
* @returns a copy of the message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../ts/message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../ts/message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,qBAAa,OAAO;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,MAAM,CAAC,WAAW,SAAM;IAExB;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE;IAK1B;;;OAGG;IACH,OAAO,CAAC,OAAO,CAA6B;IAE5C;;;OAGG;IACH,eAAe,QAAO,sBAAsB,CAEzC;IAEH;;;OAGG;IACH,eAAe,QAAO,MAAM,EAAE,CAAmB;IAEjD;;;;OAIG;IACH,IAAI,GAAI,qBAAqB,SAAS,KAAG,MAAM,CAA6D;IAE5G;;;OAGG;IACH,IAAI,QAAO,OAAO,CAAoE;IAEtF;;;;OAIG;IACH,MAAM,GAAI,GAAG,OAAO,KAAG,OAAO,CAM5B;IAEF;;OAEG;IACH,MAAM,IAAI,sBAAsB;IAIhC;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO;CAGvD"}
|
package/build/ts/message.js
CHANGED
|
@@ -35,10 +35,10 @@ class Message {
|
|
|
35
35
|
this.asCircuitInputs = () => this.asArray();
|
|
36
36
|
/**
|
|
37
37
|
* Hash the message data and a public key
|
|
38
|
-
* @param
|
|
38
|
+
* @param encryptionPublicKey the public key that is used to encrypt this message
|
|
39
39
|
* @returns the hash of the message data and the public key
|
|
40
40
|
*/
|
|
41
|
-
this.hash = (
|
|
41
|
+
this.hash = (encryptionPublicKey) => (0, crypto_1.hash12)([...this.data, ...encryptionPublicKey.rawPubKey]);
|
|
42
42
|
/**
|
|
43
43
|
* Create a copy of the message
|
|
44
44
|
* @returns a copy of the message
|
package/build/ts/message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../ts/message.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA+C;AAE/C,oDAA4B;AAK5B;;GAEG;AACH,MAAa,OAAO;IAKlB;;;;OAIG;IACH,YAAY,IAAc;QAK1B;;;WAGG;QACK,YAAO,GAAG,GAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QAE5C;;;WAGG;QACH,oBAAe,GAAG,GAA2B,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACjD,CAAC,CAAC;QAEH;;;WAGG;QACH,oBAAe,GAAG,GAAa,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEjD;;;;WAIG;QACH,SAAI,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../ts/message.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA+C;AAE/C,oDAA4B;AAK5B;;GAEG;AACH,MAAa,OAAO;IAKlB;;;;OAIG;IACH,YAAY,IAAc;QAK1B;;;WAGG;QACK,YAAO,GAAG,GAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QAE5C;;;WAGG;QACH,oBAAe,GAAG,GAA2B,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SACjD,CAAC,CAAC;QAEH;;;WAGG;QACH,oBAAe,GAAG,GAAa,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEjD;;;;WAIG;QACH,SAAI,GAAG,CAAC,mBAA8B,EAAU,EAAE,CAAC,IAAA,eAAM,EAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;QAE5G;;;WAGG;QACH,SAAI,GAAG,GAAY,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAEtF;;;;WAIG;QACH,WAAM,GAAG,CAAC,CAAU,EAAW,EAAE;YAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC;QAhDA,IAAA,gBAAM,EAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAgDD;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAA4B;QAC1C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;;AA3EH,0BA4EC;AAzEQ,mBAAW,GAAG,EAAE,AAAL,CAAM"}
|
package/build/ts/privateKey.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PrivateKey as RawPrivKey } from "@maci-protocol/crypto";
|
|
2
2
|
import type { IJsonPrivateKey } from "./types";
|
|
3
3
|
export declare const SERIALIZED_PRIV_KEY_PREFIX = "macisk.";
|
|
4
4
|
/**
|
|
5
|
-
* @notice
|
|
5
|
+
* @notice PrivateKey is a TS Class representing a MACI PrivateKey
|
|
6
6
|
* which is a seed to be used to generate a public key (point on the curve)
|
|
7
7
|
* This is a MACI private key, which is not to be
|
|
8
8
|
* confused with an Ethereum private key.
|
|
9
9
|
* A serialized MACI private key is prefixed by 'macisk.'
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class PrivateKey {
|
|
12
12
|
rawPrivKey: RawPrivKey;
|
|
13
13
|
/**
|
|
14
14
|
* Generate a new Private key object
|
|
@@ -19,7 +19,7 @@ export declare class PrivKey {
|
|
|
19
19
|
* Create a copy of this Private key
|
|
20
20
|
* @returns a copy of the Private key
|
|
21
21
|
*/
|
|
22
|
-
copy: () =>
|
|
22
|
+
copy: () => PrivateKey;
|
|
23
23
|
/**
|
|
24
24
|
* Return this Private key as a circuit input
|
|
25
25
|
* @returns the Private key as a circuit input
|
|
@@ -35,7 +35,7 @@ export declare class PrivKey {
|
|
|
35
35
|
* @param s the serialized private key
|
|
36
36
|
* @returns the deserialized private key
|
|
37
37
|
*/
|
|
38
|
-
static deserialize: (s: string) =>
|
|
38
|
+
static deserialize: (s: string) => PrivateKey;
|
|
39
39
|
/**
|
|
40
40
|
* Check if the serialized private key is valid
|
|
41
41
|
* @param s the serialized private key
|
|
@@ -49,8 +49,8 @@ export declare class PrivKey {
|
|
|
49
49
|
/**
|
|
50
50
|
* Deserialize this object from a JSON object
|
|
51
51
|
* @param json - the json object
|
|
52
|
-
* @returns the deserialized object as a
|
|
52
|
+
* @returns the deserialized object as a PrivateKey instance
|
|
53
53
|
*/
|
|
54
|
-
static fromJSON(json: IJsonPrivateKey):
|
|
54
|
+
static fromJSON(json: IJsonPrivateKey): PrivateKey;
|
|
55
55
|
}
|
|
56
56
|
//# sourceMappingURL=privateKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privateKey.d.ts","sourceRoot":"","sources":["../../ts/privateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,
|
|
1
|
+
{"version":3,"file":"privateKey.d.ts","sourceRoot":"","sources":["../../ts/privateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,UAAU,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;gBACS,UAAU,EAAE,UAAU;IAIlC;;;OAGG;IACH,IAAI,QAAO,UAAU,CAAuD;IAE5E;;;OAGG;IACH,eAAe,QAAO,MAAM,CAAwD;IAEpF;;;OAGG;IACH,SAAS,QAAO,MAAM,CAOpB;IAEF;;;;OAIG;IACH,MAAM,CAAC,WAAW,GAAI,GAAG,MAAM,KAAG,UAAU,CAG1C;IAEF;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,GAAI,GAAG,MAAM,KAAG,OAAO,CAKpD;IAEF;;OAEG;IACH,MAAM,IAAI,eAAe;IAMzB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU;CAGnD"}
|
package/build/ts/privateKey.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PrivateKey = exports.SERIALIZED_PRIV_KEY_PREFIX = void 0;
|
|
4
4
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
5
5
|
exports.SERIALIZED_PRIV_KEY_PREFIX = "macisk.";
|
|
6
6
|
/**
|
|
7
|
-
* @notice
|
|
7
|
+
* @notice PrivateKey is a TS Class representing a MACI PrivateKey
|
|
8
8
|
* which is a seed to be used to generate a public key (point on the curve)
|
|
9
9
|
* This is a MACI private key, which is not to be
|
|
10
10
|
* confused with an Ethereum private key.
|
|
11
11
|
* A serialized MACI private key is prefixed by 'macisk.'
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class PrivateKey {
|
|
14
14
|
/**
|
|
15
15
|
* Generate a new Private key object
|
|
16
16
|
* @param rawPrivKey the raw private key (a bigint)
|
|
@@ -20,7 +20,7 @@ class PrivKey {
|
|
|
20
20
|
* Create a copy of this Private key
|
|
21
21
|
* @returns a copy of the Private key
|
|
22
22
|
*/
|
|
23
|
-
this.copy = () => new
|
|
23
|
+
this.copy = () => new PrivateKey(BigInt(this.rawPrivKey.toString()));
|
|
24
24
|
/**
|
|
25
25
|
* Return this Private key as a circuit input
|
|
26
26
|
* @returns the Private key as a circuit input
|
|
@@ -44,34 +44,34 @@ class PrivKey {
|
|
|
44
44
|
*/
|
|
45
45
|
toJSON() {
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
privateKey: this.serialize(),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Deserialize this object from a JSON object
|
|
52
52
|
* @param json - the json object
|
|
53
|
-
* @returns the deserialized object as a
|
|
53
|
+
* @returns the deserialized object as a PrivateKey instance
|
|
54
54
|
*/
|
|
55
55
|
static fromJSON(json) {
|
|
56
|
-
return
|
|
56
|
+
return PrivateKey.deserialize(json.privateKey);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
exports.
|
|
59
|
+
exports.PrivateKey = PrivateKey;
|
|
60
60
|
/**
|
|
61
61
|
* Deserialize the private key
|
|
62
62
|
* @param s the serialized private key
|
|
63
63
|
* @returns the deserialized private key
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
PrivateKey.deserialize = (s) => {
|
|
66
66
|
const x = s.slice(exports.SERIALIZED_PRIV_KEY_PREFIX.length);
|
|
67
|
-
return new
|
|
67
|
+
return new PrivateKey(BigInt(`0x${x}`));
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* Check if the serialized private key is valid
|
|
71
71
|
* @param s the serialized private key
|
|
72
72
|
* @returns whether it is a valid serialized private key
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
PrivateKey.isValidSerializedPrivKey = (s) => {
|
|
75
75
|
const correctPrefix = s.startsWith(exports.SERIALIZED_PRIV_KEY_PREFIX);
|
|
76
76
|
const x = s.slice(exports.SERIALIZED_PRIV_KEY_PREFIX.length);
|
|
77
77
|
return correctPrefix && x.length === 64;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privateKey.js","sourceRoot":"","sources":["../../ts/privateKey.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"privateKey.js","sourceRoot":"","sources":["../../ts/privateKey.ts"],"names":[],"mappings":";;;AAAA,kDAA+F;AAIlF,QAAA,0BAA0B,GAAG,SAAS,CAAC;AAEpD;;;;;;GAMG;AACH,MAAa,UAAU;IAGrB;;;OAGG;IACH,YAAY,UAAsB;QAIlC;;;WAGG;QACH,SAAI,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAE5E;;;WAGG;QACH,oBAAe,GAAG,GAAW,EAAE,CAAC,IAAA,gCAAuB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEpF;;;WAGG;QACH,cAAS,GAAG,GAAW,EAAE;YACvB,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;YACd,CAAC;YAED,OAAO,GAAG,kCAA0B,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG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