@totemsdk/omnia-factory 0.1.7 → 0.1.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/dist/commitment.js +2 -2
- package/dist/factory.js +4 -4
- package/dist/settlement.js +3 -3
- package/dist/virtual.js +1 -1
- package/package.json +2 -2
package/dist/commitment.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computeFactoryStateCommitment = computeFactoryStateCommitment;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@totemsdk/core");
|
|
5
5
|
/**
|
|
6
6
|
* Compute the canonical 32-byte state commitment for N-of-N factory signing.
|
|
7
7
|
*
|
|
@@ -26,5 +26,5 @@ function computeFactoryStateCommitment(factoryId, sequence, pendingAllocations,
|
|
|
26
26
|
.map(([k, v]) => [k, v.toString()])),
|
|
27
27
|
virtualChannelIds: [...virtualChannelIds].sort(),
|
|
28
28
|
};
|
|
29
|
-
return (0,
|
|
29
|
+
return (0, core_1.sha3_256)(new TextEncoder().encode(JSON.stringify(canonical)));
|
|
30
30
|
}
|
package/dist/factory.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.enforceConservation = enforceConservation;
|
|
|
4
4
|
exports.createFactory = createFactory;
|
|
5
5
|
exports.acceptFactory = acceptFactory;
|
|
6
6
|
exports.reallocate = reallocate;
|
|
7
|
-
const sha3_js_1 = require("@noble/hashes/sha3.js");
|
|
8
7
|
const core_1 = require("@totemsdk/core");
|
|
8
|
+
const core_2 = require("@totemsdk/core");
|
|
9
9
|
const omnia_1 = require("@totemsdk/omnia");
|
|
10
10
|
const txpow_1 = require("@totemsdk/txpow");
|
|
11
11
|
const script_js_1 = require("./script.js");
|
|
@@ -50,7 +50,7 @@ async function leaseSign(factoryId, commitment, purpose, participant, bundle) {
|
|
|
50
50
|
// Verify the signature against the REGISTERED participant public key digest —
|
|
51
51
|
// not self-reported from the signer, ensuring the signer matches the factory record.
|
|
52
52
|
const verifyFn = bundle.verify
|
|
53
|
-
?? ((s, c, pkd) => (0,
|
|
53
|
+
?? ((s, c, pkd) => (0, core_2.wotsVerifyDigest)(s, c, (0, core_2.hexToBytes)(pkd)));
|
|
54
54
|
if (!verifyFn(sig, commitment, participant.publicKeyDigest)) {
|
|
55
55
|
await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
|
|
56
56
|
throw new Error(`Signature verification failed for party '${participant.partyId}' — refusing to commit`);
|
|
@@ -81,7 +81,7 @@ function generateFactoryId(participants, tokenId) {
|
|
|
81
81
|
tokenId,
|
|
82
82
|
nonce,
|
|
83
83
|
});
|
|
84
|
-
return Buffer.from((0,
|
|
84
|
+
return Buffer.from((0, core_1.sha3_256)(new TextEncoder().encode(input))).toString('hex');
|
|
85
85
|
}
|
|
86
86
|
// ─── createFactory ────────────────────────────────────────────────────────────
|
|
87
87
|
/**
|
|
@@ -140,7 +140,7 @@ async function createFactory(participants, tokenId, bundle, chainProvider) {
|
|
|
140
140
|
const draftBytes = (0, omnia_1.omniaDraftToMinimaBytes)(fundingDraft);
|
|
141
141
|
const txBody = (0, txpow_1.serializeTxBody)(draftBytes, new Uint8Array(0));
|
|
142
142
|
const mined = await (0, txpow_1.mineTxPoW)(txBody, txpow_1.TX_POW_MIN_DIFFICULTY);
|
|
143
|
-
const fullTxPoW = (0,
|
|
143
|
+
const fullTxPoW = (0, core_2.concatBytes)((0, core_2.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01])), txBody);
|
|
144
144
|
await chainProvider.broadcastTxPoW(Buffer.from(fullTxPoW).toString('hex'));
|
|
145
145
|
fundingTxId = Buffer.from(mined.txpowId).toString('hex');
|
|
146
146
|
fundingCoinId = `${fundingTxId}-0`;
|
package/dist/settlement.js
CHANGED
|
@@ -91,7 +91,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
|
|
|
91
91
|
throw err;
|
|
92
92
|
}
|
|
93
93
|
const verifyFn = bundle.verify
|
|
94
|
-
?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.
|
|
94
|
+
?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.hexToBytes)(pkd)));
|
|
95
95
|
if (!verifyFn(sig, txDigest, p.publicKeyDigest)) {
|
|
96
96
|
await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
|
|
97
97
|
throw new Error(`Settlement signature verification failed for party '${p.partyId}'`);
|
|
@@ -100,7 +100,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
|
|
|
100
100
|
witnessParts.push(sig);
|
|
101
101
|
}
|
|
102
102
|
// Concatenated WOTS signatures form the N-of-N MULTISIG witness.
|
|
103
|
-
const witnessBytes = (0, core_1.concatBytes)(
|
|
103
|
+
const witnessBytes = witnessParts.reduce((a, b) => (0, core_1.concatBytes)(a, b));
|
|
104
104
|
const payload = {
|
|
105
105
|
factoryId: factory.factoryId,
|
|
106
106
|
sequence: factory.currentSequence,
|
|
@@ -112,7 +112,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
|
|
|
112
112
|
const draftBytes = (0, omnia_1.omniaDraftToMinimaBytes)(settlementDraft);
|
|
113
113
|
const txBody = (0, txpow_1.serializeTxBody)(draftBytes, witnessBytes);
|
|
114
114
|
const mined = await (0, txpow_1.mineTxPoW)(txBody, txpow_1.TX_POW_MIN_DIFFICULTY);
|
|
115
|
-
const fullTxPoW = (0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01]), txBody);
|
|
115
|
+
const fullTxPoW = (0, core_1.concatBytes)((0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01])), txBody);
|
|
116
116
|
await chainProvider.broadcastTxPoW(Buffer.from(fullTxPoW).toString('hex'));
|
|
117
117
|
payload.txpowId = Buffer.from(mined.txpowId).toString('hex');
|
|
118
118
|
}
|
package/dist/virtual.js
CHANGED
|
@@ -26,7 +26,7 @@ async function leaseSign(factoryId, commitment, purpose, partyId, publicKeyDiges
|
|
|
26
26
|
throw err;
|
|
27
27
|
}
|
|
28
28
|
const verifyFn = bundle.verify
|
|
29
|
-
?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.
|
|
29
|
+
?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.hexToBytes)(pkd)));
|
|
30
30
|
if (!verifyFn(sig, commitment, publicKeyDigest)) {
|
|
31
31
|
await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
|
|
32
32
|
throw new Error(`Signature verification failed for party '${partyId}' — aborting virtual channel operation`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-factory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Channel factory layer for Omnia — N-of-N MULTISIG funding, virtual channel management, and factory settlement",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"prepare": "
|
|
16
|
+
"prepare": "tsc",
|
|
17
17
|
"clean": "rm -rf dist",
|
|
18
18
|
"test": "node ../../node_modules/jest/bin/jest.js --config jest.config.cjs --passWithNoTests"
|
|
19
19
|
},
|