zkcloudworker 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ts/src/api/api.js +15 -4
- package/lib/ts/src/cloud/cloud.d.ts +16 -6
- package/lib/ts/src/cloud/index.d.ts +5 -0
- package/lib/ts/src/cloud/index.js +21 -0
- package/lib/ts/src/cloud/local.d.ts +7 -4
- package/lib/ts/src/cloud/local.js +15 -4
- package/lib/ts/src/config.d.ts +0 -1
- package/lib/ts/src/config.js +0 -1
- package/lib/ts/src/encryption/client.d.ts +19 -0
- package/lib/ts/src/encryption/client.js +155 -0
- package/lib/ts/src/encryption/connections.d.ts +1 -0
- package/lib/ts/src/encryption/connections.js +4 -0
- package/lib/ts/src/encryption/encryption.d.ts +3 -2
- package/lib/ts/src/encryption/encryption.js +2 -2
- package/lib/ts/src/encryption/index.d.ts +4 -0
- package/lib/ts/src/encryption/index.js +14 -0
- package/lib/ts/src/encryption/messages.d.ts +1 -0
- package/lib/ts/src/encryption/messages.js +27 -14
- package/lib/ts/src/index.d.ts +3 -12
- package/lib/ts/src/index.js +3 -12
- package/lib/ts/src/networks.d.ts +1 -0
- package/lib/ts/src/networks.js +2 -0
- package/lib/ts/src/{fee.js → utils/fee.js} +1 -1
- package/lib/ts/src/utils/fetch.js +1 -1
- package/lib/ts/src/utils/graphql.d.ts +11 -0
- package/lib/ts/src/utils/graphql.js +229 -0
- package/lib/ts/src/utils/index.d.ts +6 -0
- package/lib/ts/src/utils/index.js +22 -0
- package/lib/ts/src/{mina.d.ts → utils/mina.d.ts} +1 -1
- package/lib/ts/src/{mina.js → utils/mina.js} +1 -1
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/api/api.js +15 -4
- package/lib/web/src/api/api.js.map +1 -1
- package/lib/web/src/cloud/cloud.d.ts +16 -6
- package/lib/web/src/cloud/cloud.js.map +1 -1
- package/lib/web/src/cloud/index.d.ts +5 -0
- package/lib/web/src/cloud/index.js +6 -0
- package/lib/web/src/cloud/index.js.map +1 -0
- package/lib/web/src/cloud/local.d.ts +7 -4
- package/lib/web/src/cloud/local.js +15 -4
- package/lib/web/src/cloud/local.js.map +1 -1
- package/lib/web/src/config.d.ts +0 -1
- package/lib/web/src/config.js +0 -1
- package/lib/web/src/config.js.map +1 -1
- package/lib/web/src/encryption/client.d.ts +19 -0
- package/lib/web/src/encryption/client.js +151 -0
- package/lib/web/src/encryption/client.js.map +1 -0
- package/lib/web/src/encryption/connections.d.ts +1 -0
- package/lib/web/src/encryption/connections.js +2 -0
- package/lib/web/src/encryption/connections.js.map +1 -0
- package/lib/web/src/encryption/encryption.d.ts +3 -2
- package/lib/web/src/encryption/encryption.js +4 -3
- package/lib/web/src/encryption/encryption.js.map +1 -1
- package/lib/web/src/encryption/index.d.ts +4 -0
- package/lib/web/src/encryption/index.js +5 -0
- package/lib/web/src/encryption/index.js.map +1 -0
- package/lib/web/src/encryption/messages.d.ts +1 -0
- package/lib/web/src/encryption/messages.js +23 -8
- package/lib/web/src/encryption/messages.js.map +1 -1
- package/lib/web/src/index.d.ts +3 -12
- package/lib/web/src/index.js +3 -12
- package/lib/web/src/index.js.map +1 -1
- package/lib/web/src/networks.d.ts +1 -0
- package/lib/web/src/networks.js +2 -0
- package/lib/web/src/networks.js.map +1 -1
- package/lib/web/src/{fee.js → utils/fee.js} +1 -1
- package/lib/web/src/utils/fee.js.map +1 -0
- package/lib/web/src/utils/fetch.js +1 -1
- package/lib/web/src/utils/fetch.js.map +1 -1
- package/lib/web/src/utils/graphql.d.ts +11 -0
- package/lib/web/src/utils/graphql.js +225 -0
- package/lib/web/src/utils/graphql.js.map +1 -0
- package/lib/web/src/utils/index.d.ts +6 -0
- package/lib/web/src/utils/index.js +7 -0
- package/lib/web/src/utils/index.js.map +1 -0
- package/lib/web/src/{mina.d.ts → utils/mina.d.ts} +1 -1
- package/lib/web/src/{mina.js → utils/mina.js} +1 -1
- package/lib/web/src/utils/mina.js.map +1 -0
- package/lib/web/tsconfig.web.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/lib/ts/src/encryption/nats-client.d.ts +0 -1
- package/lib/ts/src/encryption/nats-client.js +0 -85
- package/lib/web/src/encryption/nats-client.d.ts +0 -1
- package/lib/web/src/encryption/nats-client.js +0 -79
- package/lib/web/src/encryption/nats-client.js.map +0 -1
- package/lib/web/src/fee.js.map +0 -1
- package/lib/web/src/mina.js.map +0 -1
- /package/lib/ts/src/{fee.d.ts → utils/fee.d.ts} +0 -0
- /package/lib/web/src/{fee.d.ts → utils/fee.d.ts} +0 -0
package/lib/web/src/api/api.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import axios from "axios";
|
2
2
|
import chalk from "chalk";
|
3
|
-
import { sleep } from "../mina";
|
3
|
+
import { sleep } from "../utils/mina";
|
4
4
|
import { LocalCloud, LocalStorage } from "../cloud/local";
|
5
5
|
import config from "../config";
|
6
6
|
const { ZKCLOUDWORKER_AUTH, ZKCLOUDWORKER_API } = config;
|
@@ -44,17 +44,28 @@ export class zkCloudWorkerClient {
|
|
44
44
|
*/
|
45
45
|
async recursiveProof(data) {
|
46
46
|
const result = await this.apiHub("recursiveProof", data);
|
47
|
-
if (result.data === "error"
|
47
|
+
if (result.data === "error" ||
|
48
|
+
(typeof result.data === "string" && result.data.startsWith("error")))
|
48
49
|
return {
|
49
50
|
success: false,
|
50
51
|
error: result.error,
|
51
52
|
};
|
52
|
-
else
|
53
|
+
else if (result.success === false || result.data?.success === false)
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
error: result.error ?? result.data?.error ?? "recursiveProof call failed",
|
57
|
+
};
|
58
|
+
else if (result.success === true && result.data?.success === true)
|
53
59
|
return {
|
54
60
|
success: result.success,
|
55
|
-
jobId: result.data,
|
61
|
+
jobId: result.data.jobId,
|
56
62
|
error: result.error,
|
57
63
|
};
|
64
|
+
else
|
65
|
+
return {
|
66
|
+
success: false,
|
67
|
+
error: "recursiveProof call error",
|
68
|
+
};
|
58
69
|
}
|
59
70
|
/**
|
60
71
|
* Starts a new job for the function call using serverless api call
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAc,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAc,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;AAUzD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAO9B;;;OAGG;IACH,YAAY,MAKX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,QAAQ,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;YACpB,IAAI,aAAa,KAAK,SAAS;gBAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,cAAc,CAAC,IAS3B;QAKC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,E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AC,OAAO,IAAI,KAAK,CAAC,CAAC;gBACvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,8DAA8D;IACtD,OAAO,CAAC,IAAS;QACvB,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,IAAI,CAAC;QAClC,IAAI,IAAI,EAAE,SAAS,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;YACpE,OAAO,IAAI,CAAC;QACd,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
@@ -1,11 +1,19 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { Cache
|
2
|
+
import type { Cache } from "o1js";
|
3
3
|
import { blockchain } from "../networks";
|
4
4
|
import { JobData } from "./job";
|
5
5
|
export interface DeployedSmartContract {
|
6
|
-
address:
|
7
|
-
|
6
|
+
address: string;
|
7
|
+
name: string;
|
8
8
|
chain: blockchain;
|
9
|
+
verificationKey: {
|
10
|
+
hash: string;
|
11
|
+
data: string;
|
12
|
+
};
|
13
|
+
}
|
14
|
+
export interface DeployerKeyPair {
|
15
|
+
publicKey: string;
|
16
|
+
privateKey: string;
|
9
17
|
}
|
10
18
|
export interface CloudTransaction {
|
11
19
|
txId: string;
|
@@ -41,9 +49,11 @@ export declare abstract class Cloud {
|
|
41
49
|
isLocalCloud?: boolean;
|
42
50
|
chain: blockchain;
|
43
51
|
});
|
44
|
-
abstract getDeployer(): Promise<
|
45
|
-
abstract releaseDeployer(
|
46
|
-
|
52
|
+
abstract getDeployer(): Promise<DeployerKeyPair | undefined>;
|
53
|
+
abstract releaseDeployer(params: {
|
54
|
+
publicKey: string;
|
55
|
+
txsHashes: string[];
|
56
|
+
}): Promise<void>;
|
47
57
|
abstract getDataByKey(key: string): Promise<string | undefined>;
|
48
58
|
abstract saveDataByKey(key: string, value: string | undefined): Promise<void>;
|
49
59
|
abstract saveFile(filename: string, value: Buffer): Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAgB,KAAK;IAezB,YAAY,MAcX;QACC,MAAM,EACJ,EAAE,EACF,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,GACN,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAwCF;AACD,MAAM,OAAgB,aAAa;IAGjC,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,iBAAiB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,MAAc;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+EAA+E;IAC/E,KAAK,CAAC,OAAO,CAAC,YAAsB;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iDAAiD;IACjD,KAAK,CAAC,mBAAmB,CAAC,YAAgC,IAAkB,CAAC;IAE7E,4CAA4C;IAC5C,KAAK,CAAC,IAAI;QACR,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cloud/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { Cache
|
2
|
+
import { Cache } from "o1js";
|
3
3
|
import { Cloud, zkCloudWorker } from "./cloud";
|
4
4
|
import { JobData } from "./job";
|
5
5
|
import { TaskData } from "./task";
|
6
6
|
import { blockchain } from "../networks";
|
7
|
-
import { CloudTransaction } from "./cloud";
|
7
|
+
import { CloudTransaction, DeployerKeyPair } from "./cloud";
|
8
8
|
import { ApiCommand } from "../api/api";
|
9
9
|
export declare class LocalCloud extends Cloud {
|
10
10
|
readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
@@ -15,8 +15,11 @@ export declare class LocalCloud extends Cloud {
|
|
15
15
|
stepId?: string;
|
16
16
|
localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
17
17
|
});
|
18
|
-
getDeployer(): Promise<
|
19
|
-
releaseDeployer(
|
18
|
+
getDeployer(): Promise<DeployerKeyPair | undefined>;
|
19
|
+
releaseDeployer(params: {
|
20
|
+
publicKey: string;
|
21
|
+
txsHashes: string[];
|
22
|
+
}): Promise<void>;
|
20
23
|
log(msg: string): Promise<void>;
|
21
24
|
getDataByKey(key: string): Promise<string | undefined>;
|
22
25
|
saveDataByKey(key: string, value: string | undefined): Promise<void>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Cache, PrivateKey } from "o1js";
|
2
2
|
import { Cloud } from "./cloud";
|
3
|
-
import { makeString } from "../mina";
|
3
|
+
import { makeString } from "../utils/mina";
|
4
4
|
import { saveFile, loadFile, saveBinaryFile, loadBinaryFile } from "./files";
|
5
5
|
export class LocalCloud extends Cloud {
|
6
6
|
constructor(params) {
|
@@ -25,10 +25,21 @@ export class LocalCloud extends Cloud {
|
|
25
25
|
}
|
26
26
|
async getDeployer() {
|
27
27
|
const deployer = process.env.DEPLOYER;
|
28
|
-
|
28
|
+
try {
|
29
|
+
return deployer === undefined
|
30
|
+
? undefined
|
31
|
+
: {
|
32
|
+
privateKey: deployer,
|
33
|
+
publicKey: PrivateKey.fromBase58(deployer).toPublicKey().toBase58(),
|
34
|
+
};
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
console.error(`getDeployer: process.env.DEPLOYER has wrong encoding, should be base58 private key ("EKE...")`, error);
|
38
|
+
return undefined;
|
39
|
+
}
|
29
40
|
}
|
30
|
-
async releaseDeployer(
|
31
|
-
console.log("LocalCloud: releaseDeployer",
|
41
|
+
async releaseDeployer(params) {
|
42
|
+
console.log("LocalCloud: releaseDeployer", params);
|
32
43
|
}
|
33
44
|
async log(msg) {
|
34
45
|
console.log("LocalCloud:", msg);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../src/cloud/local.ts"],"names":[],"mappings":"AAAA,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AAC;;AA1BM,iBAAI,GAA+B,EAAE,CAAC;AACtC,iBAAI,GAA8B,EAAE,CAAC;AACrC,yBAAY,GAEf,EAAE,CAAC;AACA,kBAAK,GAAgC,EAAE,CAAC"}
|
package/lib/web/src/config.d.ts
CHANGED
package/lib/web/src/config.js
CHANGED
@@ -2,7 +2,6 @@ const config = {
|
|
2
2
|
MINAFEE: "200000000",
|
3
3
|
ZKCLOUDWORKER_AUTH: "M6t4jtbBAFFXhLERHQWyEB9JA9xi4cWqmYduaCXtbrFjb7yaY7TyaXDunKDJNiUTBEcyUomNXJgC",
|
4
4
|
ZKCLOUDWORKER_API: "https://cuq99yahhi.execute-api.eu-west-1.amazonaws.com/dev/zkcloudworker",
|
5
|
-
NATS_SERVER: "nats.socialcap.dev:4222",
|
6
5
|
};
|
7
6
|
export default config;
|
8
7
|
//# sourceMappingURL=config.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,WAAW;IACpB,kBAAkB,EAChB,8EAA8E;IAChF,iBAAiB,EACf,0EAA0E;
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,WAAW;IACpB,kBAAkB,EAChB,8EAA8E;IAChF,iBAAiB,EACf,0EAA0E;CAC7E,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export interface INATSClient {
|
2
|
+
address: string;
|
3
|
+
secret: string;
|
4
|
+
callme: {
|
5
|
+
onOptions: (params: any) => void;
|
6
|
+
onReady: (params: any) => void;
|
7
|
+
onDone: (params: any) => void;
|
8
|
+
};
|
9
|
+
}
|
10
|
+
export declare function NATSClient(callme: {
|
11
|
+
onOptions: (params: any) => void;
|
12
|
+
onReady: (params: any) => void;
|
13
|
+
onDone: (params: any) => void;
|
14
|
+
}): Promise<INATSClient>;
|
15
|
+
export declare function listen(subject: string, callme: {
|
16
|
+
onOptions: (params: any) => void;
|
17
|
+
onReady: (params: any) => void;
|
18
|
+
onDone: (params: any) => void;
|
19
|
+
}): Promise<void>;
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import { PrivateKey } from "o1js";
|
2
|
+
import { connect, JSONCodec } from "nats";
|
3
|
+
import { initializeBindings } from "o1js";
|
4
|
+
import { CipherText } from "./encryption";
|
5
|
+
import { NATS_SERVER } from "./connections";
|
6
|
+
export async function NATSClient(callme) {
|
7
|
+
// create some client address, this will be done by
|
8
|
+
// the web API BEFORE calling a worker
|
9
|
+
const secret = PrivateKey.random();
|
10
|
+
let address = secret.toPublicKey().toBase58();
|
11
|
+
console.log("Client address ", address);
|
12
|
+
// now subscribe and listen in this Address
|
13
|
+
// we use the 'zkcw' prefix for zkCloudWorkers subscriptions
|
14
|
+
await listen(`zkcw:${address}`, callme);
|
15
|
+
return {
|
16
|
+
address: address,
|
17
|
+
secret: secret.toBase58(),
|
18
|
+
callme: callme,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
export async function listen(subject, callme) {
|
22
|
+
// Create a JSON codec for encoding and decoding messages
|
23
|
+
const codec = JSONCodec();
|
24
|
+
const connection = await connect({ servers: NATS_SERVER });
|
25
|
+
// Subscribe to the subject
|
26
|
+
const subscription = connection.subscribe(subject);
|
27
|
+
console.log(`Subscribed to subject ${subject}`);
|
28
|
+
// Process messages received on the subscribed subject
|
29
|
+
(async () => {
|
30
|
+
// Error decoding message: Error: Could not encrypt message={}
|
31
|
+
// Error: Poseidon.Sponge(): bindings are not initialized, try calling `await initializeBindings()` first.
|
32
|
+
// This shouldn't have happened and indicates an internal bug.
|
33
|
+
await initializeBindings();
|
34
|
+
for await (const msg of subscription) {
|
35
|
+
try {
|
36
|
+
const data = codec.decode(msg.data);
|
37
|
+
//console.log(`Received message on subject ${subject}:`, data);
|
38
|
+
// Perform processing logic here
|
39
|
+
const { post, params } = data;
|
40
|
+
// console.log(`Post: `, post, params);
|
41
|
+
switch (post) {
|
42
|
+
case "options":
|
43
|
+
{
|
44
|
+
// the workers announces it is ready
|
45
|
+
// and we receive the worker's publicKey
|
46
|
+
let workerKey = params.key || "";
|
47
|
+
console.log("\nReceived 'options' message from worker");
|
48
|
+
console.log("Worker publicKey: ", workerKey);
|
49
|
+
let options = callme.onOptions(params);
|
50
|
+
console.log("options:", options);
|
51
|
+
// we will use its key to encrypt the message
|
52
|
+
const encryptedOptions = CipherText.encrypt(JSON.stringify(options), workerKey);
|
53
|
+
console.log("Encrypted options: ", encryptedOptions);
|
54
|
+
// we reply with the command we want the worker to execute
|
55
|
+
// and with the encrypted payload
|
56
|
+
msg.respond(codec.encode({
|
57
|
+
success: true,
|
58
|
+
data: {
|
59
|
+
command: "options",
|
60
|
+
encrypted: encryptedOptions,
|
61
|
+
},
|
62
|
+
error: undefined,
|
63
|
+
}));
|
64
|
+
}
|
65
|
+
break;
|
66
|
+
case "ready":
|
67
|
+
{
|
68
|
+
// the workers announces it is ready
|
69
|
+
// and we receive the worker's publicKey
|
70
|
+
let workerKey = params.key || "";
|
71
|
+
console.log("\nReceived 'ready' message from worker");
|
72
|
+
console.log("Worker publicKey: ", workerKey);
|
73
|
+
let payload = callme.onReady(params);
|
74
|
+
console.log("payload:", payload);
|
75
|
+
// we will use its key to encrypt the message
|
76
|
+
const encryptedPayload = CipherText.encrypt(JSON.stringify(payload), workerKey);
|
77
|
+
console.log("Encrypted payload: ", encryptedPayload);
|
78
|
+
// we reply with the command we want the worker to execute
|
79
|
+
// and with the encrypted payload
|
80
|
+
msg.respond(codec.encode({
|
81
|
+
success: true,
|
82
|
+
data: {
|
83
|
+
command: "execute",
|
84
|
+
encrypted: encryptedPayload,
|
85
|
+
},
|
86
|
+
error: undefined,
|
87
|
+
}));
|
88
|
+
}
|
89
|
+
break;
|
90
|
+
case "done":
|
91
|
+
{
|
92
|
+
let result = params.result || "";
|
93
|
+
console.log("\nReceived 'done' message from worker");
|
94
|
+
let done = callme.onDone(params);
|
95
|
+
console.log("done: ", done);
|
96
|
+
msg.respond(codec.encode({
|
97
|
+
success: true,
|
98
|
+
data: {
|
99
|
+
command: "close",
|
100
|
+
status: JSON.stringify(done),
|
101
|
+
},
|
102
|
+
error: undefined,
|
103
|
+
}));
|
104
|
+
// we want to insure that messages that are in flight
|
105
|
+
// get processed, so we are going to drain the
|
106
|
+
// connection. Drain is the same as close, but makes
|
107
|
+
// sure that all messages in flight get seen
|
108
|
+
// by the iterator. After calling drain on the connection
|
109
|
+
// the connection closes.
|
110
|
+
setTimeout(async () => {
|
111
|
+
await connection.drain();
|
112
|
+
}, 1000);
|
113
|
+
}
|
114
|
+
break;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
catch (err) {
|
118
|
+
console.error("Error decoding message: ", err);
|
119
|
+
}
|
120
|
+
}
|
121
|
+
})();
|
122
|
+
}
|
123
|
+
/*
|
124
|
+
async function main(args: string[]) {
|
125
|
+
const nc = await connect({ servers: NATS_SERVER });
|
126
|
+
|
127
|
+
// create some client address, this will be done by
|
128
|
+
// the web API when calling a worker
|
129
|
+
const clientSecret = PrivateKey.random();
|
130
|
+
let clientAddress = clientSecret.toPublicKey().toBase58();
|
131
|
+
console.log("Client address ", clientAddress);
|
132
|
+
|
133
|
+
clientAddress = "B62qrYPDY555koJFAdNaUyw21WCNUgie9bmsBs2gCh6DSdhQmuN4qu6";
|
134
|
+
|
135
|
+
// now subscribe and listen in this Address
|
136
|
+
listen(nc, `zkcw:${clientAddress}`);
|
137
|
+
|
138
|
+
// we want to insure that messages that are in flight
|
139
|
+
// get processed, so we are going to drain the
|
140
|
+
// connection. Drain is the same as close, but makes
|
141
|
+
// sure that all messages in flight get seen
|
142
|
+
// by the iterator. After calling drain on the connection
|
143
|
+
// the connection closes.
|
144
|
+
//await nc.drain();
|
145
|
+
}
|
146
|
+
|
147
|
+
main(process.argv.slice(2)).catch((error) => {
|
148
|
+
console.error(error);
|
149
|
+
});
|
150
|
+
*/
|
151
|
+
//# sourceMappingURL=client.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/encryption/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAIhC;IACC,mDAAmD;IACnD,sCAAsC;IACtC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;IACnC,IAAI,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAExC,2CAA2C;IAC3C,4DAA4D;IAC5D,MAAM,MAAM,CAAC,QAAQ,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IAExC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,MAAM,EAAE,MAAM;KACf,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAe,EACf,MAIC;IAED,yDAAyD;IACzD,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;IAE1B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,yBAAyB,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EAAE;oCACJ,OAAO,EAAE,OAAO;oCAChB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;iCAC7B;gCACD,KAAK,EAAE,SAAS;6BACjB,CAAC,CACH,CAAC;4BAEF,qDAAqD;4BACrD,8CAA8C;4BAC9C,oDAAoD;4BACpD,4CAA4C;4BAC5C,yDAAyD;4BACzD,yBAAyB;4BACzB,UAAU,CAAC,KAAK,IAAI,EAAE;gCACpB,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;4BAC3B,CAAC,EAAE,IAAI,CAAC,CAAC;wBACX,CAAC;wBACD,MAAM;gBACV,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const NATS_SERVER = "nats.socialcap.dev:4222";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../../../src/encryption/connections.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,yBAAyB,CAAC"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Field, Group } from "o1js";
|
2
|
-
export
|
2
|
+
export { CipherText };
|
3
|
+
interface CipherTextObject {
|
3
4
|
cipherText: Field[];
|
4
5
|
publicKey: Group;
|
5
6
|
}
|
6
|
-
|
7
|
+
declare class CipherText {
|
7
8
|
static stringify(cipherText: CipherTextObject): string;
|
8
9
|
static parse(jsonStr: string): CipherTextObject;
|
9
10
|
static encrypt(message: string, publicId: string): string;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Field, PublicKey, PrivateKey, Encoding, Group, Encryption, initializeBindings, } from "o1js";
|
2
|
-
export
|
2
|
+
export { CipherText };
|
3
|
+
class CipherText {
|
3
4
|
static stringify(cipherText) {
|
4
5
|
return JSON.stringify(cipherText);
|
5
6
|
}
|
@@ -13,8 +14,8 @@ export class CipherText {
|
|
13
14
|
static encrypt(message, publicId) {
|
14
15
|
try {
|
15
16
|
let fields = Encoding.stringToFields(message);
|
16
|
-
let
|
17
|
-
return CipherText.stringify(
|
17
|
+
let encripted = Encryption.encrypt(fields, PublicKey.fromBase58(publicId));
|
18
|
+
return CipherText.stringify(encripted);
|
18
19
|
}
|
19
20
|
catch (err) {
|
20
21
|
throw Error(`Could not encrypt message='${message}' using key='${publicId}'.` +
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../../../../src/encryption/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../../../../src/encryption/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,KAAK,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,UAAU,EAAE,CAAC;AAOtB,MAAM,UAAU;IACd,MAAM,CAAC,SAAS,CAAC,UAA4B;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAe;QAC1B,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO;YACL,SAAS,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC;YACnC,UAAU,EAAE,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE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,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
|
@@ -1,2 +1,3 @@
|
|
1
|
+
export declare function postOptionsMessage(clientAddress: string, workerAddress: string): Promise<any>;
|
1
2
|
export declare function postReadyMessage(clientAddress: string, workerAddress: string): Promise<any>;
|
2
3
|
export declare function postDoneMessage(clientAddress: string, encrypted: string): Promise<any>;
|
@@ -1,31 +1,46 @@
|
|
1
1
|
import { connect, JSONCodec } from "nats";
|
2
|
-
import
|
3
|
-
const { NATS_SERVER } = config;
|
2
|
+
import { NATS_SERVER } from "./connections";
|
4
3
|
const codec = JSONCodec();
|
4
|
+
export async function postOptionsMessage(clientAddress, workerAddress) {
|
5
|
+
// connect to the NATS server and send a 'ready' request
|
6
|
+
const nc = await connect({ servers: NATS_SERVER });
|
7
|
+
const msg = await nc.request(`zkcw:${clientAddress}`, codec.encode({
|
8
|
+
"post": "options",
|
9
|
+
"params": { "key": workerAddress }
|
10
|
+
}));
|
11
|
+
const response = codec.decode(msg.data);
|
12
|
+
console.log("Response: ", response);
|
13
|
+
// disconect and clean all pendings
|
14
|
+
await nc.drain();
|
15
|
+
return response;
|
16
|
+
}
|
17
|
+
;
|
5
18
|
export async function postReadyMessage(clientAddress, workerAddress) {
|
6
19
|
// connect to the NATS server and send a 'ready' request
|
7
20
|
const nc = await connect({ servers: NATS_SERVER });
|
8
21
|
const msg = await nc.request(`zkcw:${clientAddress}`, codec.encode({
|
9
|
-
post: "ready",
|
10
|
-
params: { key: workerAddress }
|
22
|
+
"post": "ready",
|
23
|
+
"params": { "key": workerAddress }
|
11
24
|
}));
|
12
25
|
const response = codec.decode(msg.data);
|
13
26
|
console.log("Response: ", response);
|
14
|
-
//
|
27
|
+
// disconect and clean all pendings
|
15
28
|
await nc.drain();
|
16
29
|
return response;
|
17
30
|
}
|
31
|
+
;
|
18
32
|
export async function postDoneMessage(clientAddress, encrypted) {
|
19
33
|
// connect to the NATS server and send a 'ready' request
|
20
34
|
const nc = await connect({ servers: NATS_SERVER });
|
21
35
|
const msg = await nc.request(`zkcw:${clientAddress}`, codec.encode({
|
22
|
-
post: "done",
|
23
|
-
params: { result: encrypted }
|
36
|
+
"post": "done",
|
37
|
+
"params": { "result": encrypted }
|
24
38
|
}));
|
25
39
|
const response = codec.decode(msg.data);
|
26
40
|
console.log("Response: ", response);
|
27
|
-
//
|
41
|
+
// disconect and clean all pendings
|
28
42
|
await nc.drain();
|
29
43
|
return response;
|
30
44
|
}
|
45
|
+
;
|
31
46
|
//# sourceMappingURL=messages.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../../src/encryption/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../../src/encryption/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,aAAqB,EACrB,aAAqB;IAErB,wDAAwD;IACxD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACnD,MAAM,GAAG,GAAQ,MAAM,EAAE,CAAC,OAAO,CAC/B,QAAQ,aAAa,EAAE,EACvB,KAAK,CAAC,MAAM,CAAC;QACX,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE;KACnC,CAAC,CACH,CAAA;IACD,MAAM,QAAQ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