@kynesyslabs/demosdk 1.4.7 → 1.4.8
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/l2ps/L2PS.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export default class L2PS {
|
|
|
6
6
|
uid: forge.pki.rsa.PublicKey;
|
|
7
7
|
pam: string;
|
|
8
8
|
decryptionKey: forge.pki.rsa.PrivateKey;
|
|
9
|
+
partecipatingNodes: Map<string, string>;
|
|
9
10
|
encryptedTransactions: Map<string, EncryptedTransaction>;
|
|
10
11
|
constructor();
|
|
12
|
+
getPartecipatingNodes(): Promise<Map<string, string>>;
|
|
11
13
|
getEncryptedTransactions(blockNumber: number): Promise<EncryptedTransaction[]>;
|
|
12
14
|
getEncryptedTransaction(eHash: string): Promise<EncryptedTransaction>;
|
|
13
15
|
private encryptTx;
|
package/build/l2ps/L2PS.js
CHANGED
|
@@ -28,8 +28,9 @@ const forge = __importStar(require("node-forge"));
|
|
|
28
28
|
const encryption_1 = require("../encryption");
|
|
29
29
|
const websdk_1 = require("../websdk");
|
|
30
30
|
class L2PS {
|
|
31
|
-
// TODO Add encryptedTransactions to the Block class and edit the db consequently
|
|
32
31
|
constructor() {
|
|
32
|
+
// This will be retrieved from the db (blocks)
|
|
33
|
+
this.partecipatingNodes = new Map(); // ? Map<publicKey, connectionstring (as in Peer)>
|
|
33
34
|
// Transactions that belong to the L2PS (hash -> transaction)
|
|
34
35
|
this.encryptedTransactions = new Map();
|
|
35
36
|
let rsaKeyPair = forge.pki.rsa.generateKeyPair({ bits: 2048, e: 0x10001 });
|
|
@@ -38,6 +39,18 @@ class L2PS {
|
|
|
38
39
|
this.pam = forge.pki.publicKeyToRSAPublicKeyPem(this.uid);
|
|
39
40
|
this.decryptionKey = rsaKeyPair.privateKey;
|
|
40
41
|
}
|
|
42
|
+
// SECTION L2PS methods
|
|
43
|
+
async getPartecipatingNodes() {
|
|
44
|
+
var lastBlockResponse = await websdk_1.demos.nodeCall("getLastBlock", {});
|
|
45
|
+
var lastBlock = lastBlockResponse.response;
|
|
46
|
+
// REVIEW Is toString() the correct way to convert the public key to string?
|
|
47
|
+
this.partecipatingNodes = lastBlock.content.l2ps_partecipating_nodes[this.uid.toString()];
|
|
48
|
+
return this.partecipatingNodes;
|
|
49
|
+
}
|
|
50
|
+
// ! TODO Add a method to set the partecipating nodes
|
|
51
|
+
// The above method should be authorized through an encrypted message: if decryption succeeds, then the node is authorized to enter in the partecipating nodes
|
|
52
|
+
// ? The above method does not take into account the public key of the node, it should be added (bans and so on)
|
|
53
|
+
// ! TODO Add a method to create a new L2PS with a new set of partecipating nodes
|
|
41
54
|
// SECTION Control methods
|
|
42
55
|
// REVIEW See if it works based on the below // ?
|
|
43
56
|
async getEncryptedTransactions(blockNumber) {
|
package/build/l2ps/L2PS.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"L2PS.js","sourceRoot":"","sources":["../../../src/l2ps/L2PS.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,kDAAmC;AAInC,6CAAuC;AACvC,qCAAiC;AAEjC,MAAqB,IAAI;
|
|
1
|
+
{"version":3,"file":"L2PS.js","sourceRoot":"","sources":["../../../src/l2ps/L2PS.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,kDAAmC;AAInC,6CAAuC;AACvC,qCAAiC;AAEjC,MAAqB,IAAI;IAarB;QAPA,8CAA8C;QAC9C,uBAAkB,GAAwB,IAAI,GAAG,EAAE,CAAA,CAAC,kDAAkD;QAEtG,6DAA6D;QAC7D,0BAAqB,GAAsC,IAAI,GAAG,EAAE,CAAA;QAIhE,IAAI,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QAC1E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Content {
|
|
5
5
|
ordered_transactions: string[];
|
|
6
|
-
encrypted_transactions: EncryptedTransaction[];
|
|
7
6
|
per_address_transactions: Map<string, string[]>;
|
|
8
7
|
web2data: {};
|
|
9
8
|
previousHash: string;
|
|
10
9
|
timestamp: number;
|
|
11
10
|
peerlist: IPeer[];
|
|
11
|
+
l2ps_partecipating_nodes: Map<string, Map<string, string>>;
|
|
12
|
+
l2ps_banned_nodes: Map<string, string>;
|
|
13
|
+
encrypted_transactions_hashes: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface L2PSBlockExtension extends BlockContent {
|
|
16
|
+
l2ps_transactions: EncryptedTransaction[];
|
|
12
17
|
}
|
|
13
18
|
export interface Block {
|
|
14
19
|
number: number;
|