@maci-protocol/domainobjs 0.0.0-ci.ec84efe → 0.0.0-ci.eea13a2
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/LICENSE +1 -2
- package/build/ts/ballot.d.ts +8 -7
- package/build/ts/ballot.d.ts.map +1 -1
- package/build/ts/ballot.js +19 -19
- package/build/ts/ballot.js.map +1 -1
- package/build/ts/commands/{PCommand.d.ts → VoteCommand.d.ts} +18 -18
- package/build/ts/commands/VoteCommand.d.ts.map +1 -0
- package/build/ts/commands/{PCommand.js → VoteCommand.js} +30 -30
- package/build/ts/commands/VoteCommand.js.map +1 -0
- package/build/ts/commands/index.d.ts +1 -1
- package/build/ts/commands/index.d.ts.map +1 -1
- package/build/ts/commands/index.js +3 -3
- package/build/ts/commands/index.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 +2 -2
- package/build/ts/constants.js.map +1 -1
- package/build/ts/index.d.ts +5 -4
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +7 -5
- 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 +21 -22
- 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 +12 -12
- package/build/ts/privateKey.d.ts.map +1 -1
- package/build/ts/privateKey.js +20 -20
- package/build/ts/privateKey.js.map +1 -1
- package/build/ts/publicKey.d.ts +16 -16
- package/build/ts/publicKey.d.ts.map +1 -1
- package/build/ts/publicKey.js +27 -27
- package/build/ts/publicKey.js.map +1 -1
- package/build/ts/stateLeaf.d.ts +9 -11
- package/build/ts/stateLeaf.d.ts.map +1 -1
- package/build/ts/stateLeaf.js +22 -26
- package/build/ts/stateLeaf.js.map +1 -1
- package/build/ts/types.d.ts +27 -12
- package/build/ts/types.d.ts.map +1 -1
- package/build/ts/verifyingKey.d.ts +7 -7
- package/build/ts/verifyingKey.d.ts.map +1 -1
- package/build/ts/verifyingKey.js +9 -9
- package/build/ts/verifyingKey.js.map +1 -1
- package/build/ts/voteCounts.d.ts +63 -0
- package/build/ts/voteCounts.d.ts.map +1 -0
- package/build/ts/voteCounts.js +110 -0
- package/build/ts/voteCounts.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/build/ts/commands/PCommand.d.ts.map +0 -1
- package/build/ts/commands/PCommand.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyPair.d.ts","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"keyPair.d.ts","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6D,MAAM,uBAAuB,CAAC;AAIjH,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,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa;IAIzF;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAajC;;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.generatePublicKey)(privateKey.raw));
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
const
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
34
|
+
const rawKeypair = (0, crypto_1.generateKeypair)();
|
|
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
|
|
46
|
-
return (0, crypto_1.
|
|
45
|
+
static generateEcdhSharedKey(privateKey, publicKey) {
|
|
46
|
+
return (0, crypto_1.generateEcdhSharedKey)(privateKey.raw, publicKey.raw);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Check whether two Keypairs are equal
|
|
@@ -51,22 +51,21 @@ class Keypair {
|
|
|
51
51
|
* @returns whether they are equal or not
|
|
52
52
|
*/
|
|
53
53
|
equals(keypair) {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
this.pubKey.rawPubKey[1] === keypair.pubKey.rawPubKey[1];
|
|
54
|
+
const equalPrivateKey = this.privateKey.raw === keypair.privateKey.raw;
|
|
55
|
+
const equalPublic = this.publicKey.raw[0] === keypair.publicKey.raw[0] && this.publicKey.raw[1] === keypair.publicKey.raw[1];
|
|
57
56
|
// If this assertion fails, something is very wrong and this function
|
|
58
57
|
// should not return anything
|
|
59
58
|
// eslint-disable-next-line no-bitwise
|
|
60
|
-
(0, assert_1.default)(!(+
|
|
61
|
-
return
|
|
59
|
+
(0, assert_1.default)(!(+equalPrivateKey ^ +equalPublic));
|
|
60
|
+
return equalPrivateKey;
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
64
63
|
* Serialize into a JSON object
|
|
65
64
|
*/
|
|
66
65
|
toJSON() {
|
|
67
66
|
return {
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
privateKey: this.privateKey.serialize(),
|
|
68
|
+
publicKey: this.publicKey.serialize(),
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
@@ -75,7 +74,7 @@ class Keypair {
|
|
|
75
74
|
* @returns a keypair instance
|
|
76
75
|
*/
|
|
77
76
|
static fromJSON(json) {
|
|
78
|
-
return new Keypair(privateKey_1.
|
|
77
|
+
return new Keypair(privateKey_1.PrivateKey.deserialize(json.privateKey));
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
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,
|
|
1
|
+
{"version":3,"file":"keyPair.js","sourceRoot":"","sources":["../../ts/keyPair.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiH;AAEjH,oDAA4B;AAI5B,6CAA0C;AAC1C,2CAAwC;AAExC;;;;;GAKG;AACH,MAAa,OAAO;IAKlB;;;;OAIG;IACH,YAAY,UAAuB;QAWnC;;;WAGG;QACH,SAAI,GAAG,GAAY,EAAE,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QAdxD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,IAAA,0BAAiB,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QACpE,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,GAAG,IAAA,wBAAe,GAAE,CAAC;YACrC,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAQD;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,UAAsB,EAAE,SAAoB;QACvE,OAAO,IAAA,8BAAqB,EAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAgB;QACrB,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QACvE,MAAM,WAAW,GACf,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE3G,qEAAqE;QACrE,6BAA6B;QAC7B,sCAAsC;QACtC,IAAA,gBAAM,EAAC,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QAE3C,OAAO,eAAe,CAAC;IACzB,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;AAzED,0BAyEC"}
|
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,CAAuD;IAEtG;;;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.raw]);
|
|
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,CA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
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
|
|
12
|
-
|
|
11
|
+
export declare class PrivateKey {
|
|
12
|
+
raw: RawPrivateKey;
|
|
13
13
|
/**
|
|
14
14
|
* Generate a new Private key object
|
|
15
|
-
* @param
|
|
15
|
+
* @param raw the raw private key (a bigint)
|
|
16
16
|
*/
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(raw: RawPrivateKey);
|
|
18
18
|
/**
|
|
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,13 +35,13 @@ 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
|
-
* @param
|
|
41
|
+
* @param serialized the serialized private key
|
|
42
42
|
* @returns whether it is a valid serialized private key
|
|
43
43
|
*/
|
|
44
|
-
static
|
|
44
|
+
static isValidSerialized: (serialized: string) => boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Serialize this object
|
|
47
47
|
*/
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"privateKey.d.ts","sourceRoot":"","sources":["../../ts/privateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,UAAU,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAErG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,GAAG,EAAE,aAAa,CAAC;IAEnB;;;OAGG;gBACS,GAAG,EAAE,aAAa;IAI9B;;;OAGG;IACH,IAAI,QAAO,UAAU,CAAgD;IAErE;;;OAGG;IACH,eAAe,QAAO,MAAM,CAAoD;IAEhF;;;OAGG;IACH,SAAS,QAAO,MAAM,CAOpB;IAEF;;;;OAIG;IACH,MAAM,CAAC,WAAW,GAAI,GAAG,MAAM,KAAG,UAAU,CAG1C;IAEF;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,GAAI,YAAY,MAAM,KAAG,OAAO,CAKtD;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,79 +1,79 @@
|
|
|
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
|
-
* @param
|
|
16
|
+
* @param raw the raw private key (a bigint)
|
|
17
17
|
*/
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(raw) {
|
|
19
19
|
/**
|
|
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.raw.toString()));
|
|
24
24
|
/**
|
|
25
25
|
* Return this Private key as a circuit input
|
|
26
26
|
* @returns the Private key as a circuit input
|
|
27
27
|
*/
|
|
28
|
-
this.asCircuitInputs = () => (0, crypto_1.
|
|
28
|
+
this.asCircuitInputs = () => (0, crypto_1.formatPrivateKeyForBabyJub)(this.raw).toString();
|
|
29
29
|
/**
|
|
30
30
|
* Serialize the private key
|
|
31
31
|
* @returns the serialized private key
|
|
32
32
|
*/
|
|
33
33
|
this.serialize = () => {
|
|
34
|
-
let x = this.
|
|
34
|
+
let x = this.raw.toString(16);
|
|
35
35
|
if (x.length % 2 !== 0) {
|
|
36
36
|
x = `0${x}`;
|
|
37
37
|
}
|
|
38
38
|
return `${exports.SERIALIZED_PRIV_KEY_PREFIX}${x.padStart(64, "0")}`;
|
|
39
39
|
};
|
|
40
|
-
this.
|
|
40
|
+
this.raw = raw;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Serialize this object
|
|
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
|
-
* @param
|
|
71
|
+
* @param serialized the serialized private key
|
|
72
72
|
* @returns whether it is a valid serialized private key
|
|
73
73
|
*/
|
|
74
|
-
|
|
75
|
-
const correctPrefix =
|
|
76
|
-
const
|
|
77
|
-
return correctPrefix &&
|
|
74
|
+
PrivateKey.isValidSerialized = (serialized) => {
|
|
75
|
+
const correctPrefix = serialized.startsWith(exports.SERIALIZED_PRIV_KEY_PREFIX);
|
|
76
|
+
const body = serialized.slice(exports.SERIALIZED_PRIV_KEY_PREFIX.length);
|
|
77
|
+
return correctPrefix && body.length === 64;
|
|
78
78
|
};
|
|
79
79
|
//# sourceMappingURL=privateKey.js.map
|
|
@@ -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,kDAAqG;AAIxF,QAAA,0BAA0B,GAAG,SAAS,CAAC;AAEpD;;;;;;GAMG;AACH,MAAa,UAAU;IAGrB;;;OAGG;IACH,YAAY,GAAkB;QAI9B;;;WAGG;QACH,SAAI,GAAG,GAAe,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAErE;;;WAGG;QACH,oBAAe,GAAG,GAAW,EAAE,CAAC,IAAA,mCAA0B,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEhF;;;WAGG;QACH,cAAS,GAAG,GAAW,EAAE;YACvB,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC9B,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,CAAC,EAAE,CAAC;QAC/D,CAAC,CAAC;QA1BA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAiDD;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAqB;QACnC,OAAO,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;;AA1EH,gCA2EC;AAvCC;;;;GAIG;AACI,sBAAW,GAAG,CAAC,CAAS,EAAc,EAAE;IAC7C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,kCAA0B,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC,AAHiB,CAGhB;AAEF;;;;GAIG;AACI,4BAAiB,GAAG,CAAC,UAAkB,EAAW,EAAE;IACzD,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,kCAA0B,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,kCAA0B,CAAC,MAAM,CAAC,CAAC;IAEjE,OAAO,aAAa,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC;AAC7C,CAAC,AALuB,CAKtB"}
|
package/build/ts/publicKey.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PublicKey as RawPublicKey } from "@maci-protocol/crypto";
|
|
2
2
|
import type { IJsonPublicKey, IG1ContractParams } from "./types";
|
|
3
3
|
export declare const SERIALIZED_PUB_KEY_PREFIX = "macipk.";
|
|
4
4
|
/**
|
|
@@ -9,8 +9,8 @@ export declare const SERIALIZED_PUB_KEY_PREFIX = "macipk.";
|
|
|
9
9
|
* A raw MACI public key can be thought as a pair of
|
|
10
10
|
* BigIntegers (x, y) representing a point on the baby jubjub curve
|
|
11
11
|
*/
|
|
12
|
-
export declare class
|
|
13
|
-
|
|
12
|
+
export declare class PublicKey {
|
|
13
|
+
raw: RawPublicKey;
|
|
14
14
|
/**
|
|
15
15
|
* Create a new instance of a public key
|
|
16
16
|
* @dev You might want to allow an invalid raw key,
|
|
@@ -18,15 +18,15 @@ export declare class PubKey {
|
|
|
18
18
|
* will be random, and likely not be a point on the curve.
|
|
19
19
|
* However we need to match keys to the circuit which does
|
|
20
20
|
* not perform such checks
|
|
21
|
-
* @param
|
|
21
|
+
* @param raw the raw public key
|
|
22
22
|
* @param allowInvalid whether to allow invalid public keys
|
|
23
23
|
*/
|
|
24
|
-
constructor(
|
|
24
|
+
constructor(raw: RawPublicKey, allowInvalid?: boolean);
|
|
25
25
|
/**
|
|
26
26
|
* Create a copy of the public key
|
|
27
27
|
* @returns a copy of the public key
|
|
28
28
|
*/
|
|
29
|
-
copy: () =>
|
|
29
|
+
copy: () => PublicKey;
|
|
30
30
|
/**
|
|
31
31
|
* Return this public key as smart contract parameters
|
|
32
32
|
* @returns the public key as smart contract parameters
|
|
@@ -54,36 +54,36 @@ export declare class PubKey {
|
|
|
54
54
|
hash: () => bigint;
|
|
55
55
|
/**
|
|
56
56
|
* Check whether this public key equals to another public key
|
|
57
|
-
* @param
|
|
57
|
+
* @param key the public key to compare with
|
|
58
58
|
* @returns whether they match
|
|
59
59
|
*/
|
|
60
|
-
equals: (
|
|
60
|
+
equals: (key: PublicKey) => boolean;
|
|
61
61
|
/**
|
|
62
62
|
* Deserialize a serialized public key
|
|
63
63
|
* @param s the serialized public key
|
|
64
64
|
* @returns the deserialized public key
|
|
65
65
|
*/
|
|
66
|
-
static deserialize: (s: string) =>
|
|
66
|
+
static deserialize: (s: string) => PublicKey;
|
|
67
67
|
/**
|
|
68
68
|
* Check whether a serialized public key is serialized correctly
|
|
69
69
|
* @param s the serialized public key
|
|
70
70
|
* @returns whether the serialized public key is valid
|
|
71
71
|
*/
|
|
72
|
-
static
|
|
72
|
+
static isValidSerialized: (s: string) => boolean;
|
|
73
73
|
/**
|
|
74
74
|
* Serialize this object
|
|
75
75
|
*/
|
|
76
76
|
toJSON(): IJsonPublicKey;
|
|
77
77
|
/**
|
|
78
|
-
* Deserialize a JSON object into a
|
|
78
|
+
* Deserialize a JSON object into a PublicKey instance
|
|
79
79
|
* @param json - the json object
|
|
80
|
-
* @returns
|
|
80
|
+
* @returns PublicKey
|
|
81
81
|
*/
|
|
82
|
-
static fromJSON(json: IJsonPublicKey):
|
|
82
|
+
static fromJSON(json: IJsonPublicKey): PublicKey;
|
|
83
83
|
/**
|
|
84
|
-
* Generate a default
|
|
85
|
-
* @returns a default
|
|
84
|
+
* Generate a default padding key
|
|
85
|
+
* @returns a default padding key
|
|
86
86
|
*/
|
|
87
|
-
static
|
|
87
|
+
static generatePaddingKey(): PublicKey;
|
|
88
88
|
}
|
|
89
89
|
//# sourceMappingURL=publicKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicKey.d.ts","sourceRoot":"","sources":["../../ts/publicKey.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"publicKey.d.ts","sourceRoot":"","sources":["../../ts/publicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAEnD;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,GAAG,EAAE,YAAY,CAAC;IAElB;;;;;;;;;OASG;gBACS,GAAG,EAAE,YAAY,EAAE,YAAY,UAAQ;IAOnD;;;OAGG;IACH,IAAI,QAAO,SAAS,CAAoF;IAExG;;;OAGG;IACH,eAAe,QAAO,iBAAiB,CAOrC;IAEF;;;OAGG;IACH,eAAe,QAAO,MAAM,EAAE,CAAsC;IAEpE;;;OAGG;IACH,OAAO,QAAO,MAAM,EAAE,CAA+B;IAErD;;;OAGG;IACH,SAAS,QAAO,MAAM,CAQpB;IAEF;;;OAGG;IACH,IAAI,QAAO,MAAM,CAA4C;IAE7D;;;;OAIG;IACH,MAAM,GAAI,KAAK,SAAS,KAAG,OAAO,CAA6D;IAE/F;;;;OAIG;IACH,MAAM,CAAC,WAAW,GAAI,GAAG,MAAM,KAAG,SAAS,CAGzC;IAEF;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,GAAI,GAAG,MAAM,KAAG,OAAO,CAS7C;IAEF;;OAEG;IACH,MAAM,IAAI,cAAc;IAMxB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS;IAIhD;;;OAGG;IACH,MAAM,CAAC,kBAAkB,IAAI,SAAS;CAYvC"}
|
package/build/ts/publicKey.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.PublicKey = exports.SERIALIZED_PUB_KEY_PREFIX = void 0;
|
|
7
7
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
9
|
exports.SERIALIZED_PUB_KEY_PREFIX = "macipk.";
|
|
@@ -15,7 +15,7 @@ exports.SERIALIZED_PUB_KEY_PREFIX = "macipk.";
|
|
|
15
15
|
* A raw MACI public key can be thought as a pair of
|
|
16
16
|
* BigIntegers (x, y) representing a point on the baby jubjub curve
|
|
17
17
|
*/
|
|
18
|
-
class
|
|
18
|
+
class PublicKey {
|
|
19
19
|
/**
|
|
20
20
|
* Create a new instance of a public key
|
|
21
21
|
* @dev You might want to allow an invalid raw key,
|
|
@@ -23,21 +23,21 @@ class PubKey {
|
|
|
23
23
|
* will be random, and likely not be a point on the curve.
|
|
24
24
|
* However we need to match keys to the circuit which does
|
|
25
25
|
* not perform such checks
|
|
26
|
-
* @param
|
|
26
|
+
* @param raw the raw public key
|
|
27
27
|
* @param allowInvalid whether to allow invalid public keys
|
|
28
28
|
*/
|
|
29
|
-
constructor(
|
|
29
|
+
constructor(raw, allowInvalid = false) {
|
|
30
30
|
/**
|
|
31
31
|
* Create a copy of the public key
|
|
32
32
|
* @returns a copy of the public key
|
|
33
33
|
*/
|
|
34
|
-
this.copy = () => new
|
|
34
|
+
this.copy = () => new PublicKey([BigInt(this.raw[0].toString()), BigInt(this.raw[1].toString())]);
|
|
35
35
|
/**
|
|
36
36
|
* Return this public key as smart contract parameters
|
|
37
37
|
* @returns the public key as smart contract parameters
|
|
38
38
|
*/
|
|
39
39
|
this.asContractParam = () => {
|
|
40
|
-
const [x, y] = this.
|
|
40
|
+
const [x, y] = this.raw;
|
|
41
41
|
return {
|
|
42
42
|
x: x.toString(),
|
|
43
43
|
y: y.toString(),
|
|
@@ -47,18 +47,18 @@ class PubKey {
|
|
|
47
47
|
* Return this public key as circuit inputs
|
|
48
48
|
* @returns an array of strings
|
|
49
49
|
*/
|
|
50
|
-
this.asCircuitInputs = () => this.
|
|
50
|
+
this.asCircuitInputs = () => this.raw.map((x) => x.toString());
|
|
51
51
|
/**
|
|
52
52
|
* Return this public key as an array of bigints
|
|
53
53
|
* @returns the public key as an array of bigints
|
|
54
54
|
*/
|
|
55
|
-
this.asArray = () => [this.
|
|
55
|
+
this.asArray = () => [this.raw[0], this.raw[1]];
|
|
56
56
|
/**
|
|
57
57
|
* Generate a serialized public key from this public key object
|
|
58
58
|
* @returns the string representation of a serialized public key
|
|
59
59
|
*/
|
|
60
60
|
this.serialize = () => {
|
|
61
|
-
const packed = (0, crypto_1.
|
|
61
|
+
const packed = (0, crypto_1.packPublicKey)(this.raw).toString(16);
|
|
62
62
|
if (packed.length % 2 !== 0) {
|
|
63
63
|
return `${exports.SERIALIZED_PUB_KEY_PREFIX}0${packed}`;
|
|
64
64
|
}
|
|
@@ -68,70 +68,70 @@ class PubKey {
|
|
|
68
68
|
* Hash the two baby jubjub coordinates
|
|
69
69
|
* @returns the hash of this public key
|
|
70
70
|
*/
|
|
71
|
-
this.hash = () => (0, crypto_1.hashLeftRight)(this.
|
|
71
|
+
this.hash = () => (0, crypto_1.hashLeftRight)(this.raw[0], this.raw[1]);
|
|
72
72
|
/**
|
|
73
73
|
* Check whether this public key equals to another public key
|
|
74
|
-
* @param
|
|
74
|
+
* @param key the public key to compare with
|
|
75
75
|
* @returns whether they match
|
|
76
76
|
*/
|
|
77
|
-
this.equals = (
|
|
77
|
+
this.equals = (key) => this.raw[0] === key.raw[0] && this.raw[1] === key.raw[1];
|
|
78
78
|
if (!allowInvalid) {
|
|
79
|
-
(0, assert_1.default)((0, crypto_1.inCurve)(
|
|
79
|
+
(0, assert_1.default)((0, crypto_1.inCurve)(raw), "PublicKey not on curve");
|
|
80
80
|
}
|
|
81
|
-
this.
|
|
81
|
+
this.raw = raw;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Serialize this object
|
|
85
85
|
*/
|
|
86
86
|
toJSON() {
|
|
87
87
|
return {
|
|
88
|
-
|
|
88
|
+
publicKey: this.serialize(),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Deserialize a JSON object into a
|
|
92
|
+
* Deserialize a JSON object into a PublicKey instance
|
|
93
93
|
* @param json - the json object
|
|
94
|
-
* @returns
|
|
94
|
+
* @returns PublicKey
|
|
95
95
|
*/
|
|
96
96
|
static fromJSON(json) {
|
|
97
|
-
return
|
|
97
|
+
return PublicKey.deserialize(json.publicKey);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* Generate a default
|
|
101
|
-
* @returns a default
|
|
100
|
+
* Generate a default padding key
|
|
101
|
+
* @returns a default padding key
|
|
102
102
|
*/
|
|
103
|
-
static
|
|
103
|
+
static generatePaddingKey() {
|
|
104
104
|
// This public key is the first Pedersen base
|
|
105
105
|
// point from iden3's circomlib implementation of the Pedersen hash.
|
|
106
106
|
// Since it is generated using a hash-to-curve function, we are
|
|
107
107
|
// confident that no-one knows the private key associated with this
|
|
108
108
|
// public key. See:
|
|
109
109
|
// https://github.com/iden3/circomlib/blob/d5ed1c3ce4ca137a6b3ca48bec4ac12c1b38957a/src/pedersen_printbases.js
|
|
110
|
-
return new
|
|
110
|
+
return new PublicKey([
|
|
111
111
|
BigInt("10457101036533406547632367118273992217979173478358440826365724437999023779287"),
|
|
112
112
|
BigInt("19824078218392094440610104313265183977899662750282163392862422243483260492317"),
|
|
113
113
|
]);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
exports.
|
|
116
|
+
exports.PublicKey = PublicKey;
|
|
117
117
|
/**
|
|
118
118
|
* Deserialize a serialized public key
|
|
119
119
|
* @param s the serialized public key
|
|
120
120
|
* @returns the deserialized public key
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
PublicKey.deserialize = (s) => {
|
|
123
123
|
const len = exports.SERIALIZED_PUB_KEY_PREFIX.length;
|
|
124
|
-
return new
|
|
124
|
+
return new PublicKey((0, crypto_1.unpackPublicKey)(BigInt(`0x${s.slice(len).toString()}`)));
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
127
127
|
* Check whether a serialized public key is serialized correctly
|
|
128
128
|
* @param s the serialized public key
|
|
129
129
|
* @returns whether the serialized public key is valid
|
|
130
130
|
*/
|
|
131
|
-
|
|
131
|
+
PublicKey.isValidSerialized = (s) => {
|
|
132
132
|
const correctPrefix = s.startsWith(exports.SERIALIZED_PUB_KEY_PREFIX);
|
|
133
133
|
try {
|
|
134
|
-
|
|
134
|
+
PublicKey.deserialize(s);
|
|
135
135
|
return correctPrefix;
|
|
136
136
|
}
|
|
137
137
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicKey.js","sourceRoot":"","sources":["../../ts/publicKey.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"publicKey.js","sourceRoot":"","sources":["../../ts/publicKey.ts"],"names":[],"mappings":";;;;;;AAAA,kDAM+B;AAE/B,oDAA4B;AAIf,QAAA,yBAAyB,GAAG,SAAS,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAa,SAAS;IAGpB;;;;;;;;;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