trac-msb 0.0.18 → 0.0.19

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trac-msb",
3
3
  "main": "src/index.js",
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "pear": {
6
6
  "name": "trac-msb",
7
7
  "type": "terminal"
package/src/functions.js CHANGED
@@ -11,7 +11,8 @@ export function sanitizeTransaction(parsedTx) {
11
11
  typeof parsedTx.w === 'string' &&
12
12
  typeof parsedTx.i === 'string' &&
13
13
  typeof parsedTx.ipk === 'string' &&
14
- typeof parsedTx.is === 'string'
14
+ typeof parsedTx.is === 'string' &&
15
+ typeof parsedTx.in === 'string'
15
16
  );
16
17
  }
17
18
 
package/src/index.js CHANGED
@@ -67,8 +67,8 @@ export class MainSettlementBus extends ReadyResource {
67
67
  if (null === await view.get(op.key) &&
68
68
  sanitizeTransaction(postTx) &&
69
69
  postTx.op === 'post-tx' &&
70
- crypto.verify(Buffer.from(postTx.tx, 'utf-8'), Buffer.from(postTx.is, 'hex'), Buffer.from(postTx.ipk, 'hex')) &&// sender verification
71
- crypto.verify(Buffer.from(postTx.tx, 'utf-8'), Buffer.from(postTx.ws, 'hex'), Buffer.from(postTx.wp, 'hex')) &&// writer verification
70
+ crypto.verify(Buffer.from(postTx.tx + postTx.in, 'utf-8'), Buffer.from(postTx.is, 'hex'), Buffer.from(postTx.ipk, 'hex')) &&// sender verification
71
+ crypto.verify(Buffer.from(postTx.tx + postTx.wn, 'utf-8'), Buffer.from(postTx.ws, 'hex'), Buffer.from(postTx.wp, 'hex')) &&// writer verification
72
72
  Buffer.byteLength(JSON.stringify(postTx)) <= 4096
73
73
  ) {
74
74
  await view.put(op.key, op.value);
@@ -154,11 +154,12 @@ export class MainSettlementBus extends ReadyResource {
154
154
 
155
155
  if (sanitizeTransaction(parsedPreTx) &&
156
156
  parsedPreTx.op === 'pre-tx' &&
157
- crypto.verify(Buffer.from(parsedPreTx.tx, 'utf-8'), Buffer.from(parsedPreTx.is, 'hex'), Buffer.from(parsedPreTx.ipk, 'hex')) &&
157
+ crypto.verify(Buffer.from(parsedPreTx.tx + parsedPreTx.in, 'utf-8'), Buffer.from(parsedPreTx.is, 'hex'), Buffer.from(parsedPreTx.ipk, 'hex')) &&
158
158
  parsedPreTx.w === _this.writerLocalKey &&
159
159
  null === await _this.base.view.get(parsedPreTx.tx)
160
160
  ) {
161
- const signature = crypto.sign(Buffer.from(parsedPreTx.tx, 'utf-8'), Buffer.from(this.wallet.secretKey, 'hex'));
161
+ const nonce = Math.random() + '-' + Date.now();
162
+ const signature = crypto.sign(Buffer.from(parsedPreTx.tx + nonce, 'utf-8'), Buffer.from(this.wallet.secretKey, 'hex'));
162
163
  const append_tx = {
163
164
  op: 'post-tx',
164
165
  tx: parsedPreTx.tx,
@@ -169,6 +170,7 @@ export class MainSettlementBus extends ReadyResource {
169
170
  ch: parsedPreTx.ch,
170
171
  in: parsedPreTx.in,
171
172
  ws: signature.toString('hex'),
173
+ wn : nonce,
172
174
  wp: this.wallet.publicKey,
173
175
  };
174
176
  _this.tx_pool.push({ tx: parsedPreTx.tx, append_tx : append_tx });