@vorionsys/atsf-core 0.2.0 → 0.2.1
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/README.md +12 -12
- package/dist/api/server.js +4 -4
- package/dist/api/server.js.map +1 -1
- package/dist/basis/parser.d.ts +210 -210
- package/dist/basis/parser.js.map +1 -1
- package/dist/chain/index.d.ts +147 -0
- package/dist/chain/index.d.ts.map +1 -0
- package/dist/chain/index.js +219 -0
- package/dist/chain/index.js.map +1 -0
- package/dist/common/adapters.d.ts +9 -9
- package/dist/common/adapters.d.ts.map +1 -1
- package/dist/common/adapters.js +6 -6
- package/dist/common/config.d.ts +152 -152
- package/dist/common/types.d.ts +32 -15
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/enforce/index.d.ts +226 -16
- package/dist/enforce/index.d.ts.map +1 -1
- package/dist/enforce/index.js +196 -49
- package/dist/enforce/index.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/intent/index.d.ts +127 -10
- package/dist/intent/index.d.ts.map +1 -1
- package/dist/intent/index.js +121 -16
- package/dist/intent/index.js.map +1 -1
- package/dist/langchain/executor.d.ts +19 -5
- package/dist/langchain/executor.d.ts.map +1 -1
- package/dist/langchain/executor.js +287 -36
- package/dist/langchain/executor.js.map +1 -1
- package/dist/langchain/index.d.ts +2 -1
- package/dist/langchain/index.d.ts.map +1 -1
- package/dist/langchain/index.js +3 -1
- package/dist/langchain/index.js.map +1 -1
- package/dist/langchain/tools.d.ts.map +1 -1
- package/dist/langchain/tools.js +2 -1
- package/dist/langchain/tools.js.map +1 -1
- package/dist/langchain/types.d.ts +41 -0
- package/dist/langchain/types.d.ts.map +1 -1
- package/dist/layers/index.d.ts +1 -1
- package/dist/layers/index.d.ts.map +1 -1
- package/dist/persistence/file.d.ts +35 -3
- package/dist/persistence/file.d.ts.map +1 -1
- package/dist/persistence/file.js +138 -11
- package/dist/persistence/file.js.map +1 -1
- package/dist/persistence/index.d.ts +10 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +15 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/sqlite.d.ts +135 -0
- package/dist/persistence/sqlite.d.ts.map +1 -0
- package/dist/persistence/sqlite.js +372 -0
- package/dist/persistence/sqlite.js.map +1 -0
- package/dist/phase6/ceiling.d.ts +177 -0
- package/dist/phase6/ceiling.d.ts.map +1 -0
- package/dist/phase6/ceiling.js +463 -0
- package/dist/phase6/ceiling.js.map +1 -0
- package/dist/phase6/context.d.ts +207 -0
- package/dist/phase6/context.d.ts.map +1 -0
- package/dist/phase6/context.js +603 -0
- package/dist/phase6/context.js.map +1 -0
- package/dist/phase6/index.d.ts +79 -0
- package/dist/phase6/index.d.ts.map +1 -0
- package/dist/phase6/index.js +152 -0
- package/dist/phase6/index.js.map +1 -0
- package/dist/phase6/presets.d.ts +148 -0
- package/dist/phase6/presets.d.ts.map +1 -0
- package/dist/phase6/presets.js +467 -0
- package/dist/phase6/presets.js.map +1 -0
- package/dist/phase6/provenance.d.ts +148 -0
- package/dist/phase6/provenance.d.ts.map +1 -0
- package/dist/phase6/provenance.js +545 -0
- package/dist/phase6/provenance.js.map +1 -0
- package/dist/phase6/role-gates/index.d.ts +7 -0
- package/dist/phase6/role-gates/index.d.ts.map +1 -0
- package/dist/phase6/role-gates/index.js +7 -0
- package/dist/phase6/role-gates/index.js.map +1 -0
- package/dist/phase6/role-gates/kernel.d.ts +84 -0
- package/dist/phase6/role-gates/kernel.d.ts.map +1 -0
- package/dist/phase6/role-gates/kernel.js +258 -0
- package/dist/phase6/role-gates/kernel.js.map +1 -0
- package/dist/phase6/role-gates/policy.d.ts +110 -0
- package/dist/phase6/role-gates/policy.d.ts.map +1 -0
- package/dist/phase6/role-gates/policy.js +157 -0
- package/dist/phase6/role-gates/policy.js.map +1 -0
- package/dist/phase6/role-gates.d.ts +164 -0
- package/dist/phase6/role-gates.d.ts.map +1 -0
- package/dist/phase6/role-gates.js +536 -0
- package/dist/phase6/role-gates.js.map +1 -0
- package/dist/phase6/types.d.ts +1827 -0
- package/dist/phase6/types.d.ts.map +1 -0
- package/dist/phase6/types.js +450 -0
- package/dist/phase6/types.js.map +1 -0
- package/dist/phase6/weight-presets/canonical.d.ts +93 -0
- package/dist/phase6/weight-presets/canonical.d.ts.map +1 -0
- package/dist/phase6/weight-presets/canonical.js +122 -0
- package/dist/phase6/weight-presets/canonical.js.map +1 -0
- package/dist/phase6/weight-presets/deltas.d.ts +144 -0
- package/dist/phase6/weight-presets/deltas.d.ts.map +1 -0
- package/dist/phase6/weight-presets/deltas.js +184 -0
- package/dist/phase6/weight-presets/deltas.js.map +1 -0
- package/dist/phase6/weight-presets/index.d.ts +8 -0
- package/dist/phase6/weight-presets/index.d.ts.map +1 -0
- package/dist/phase6/weight-presets/index.js +8 -0
- package/dist/phase6/weight-presets/index.js.map +1 -0
- package/dist/phase6/weight-presets/merger.d.ts +79 -0
- package/dist/phase6/weight-presets/merger.d.ts.map +1 -0
- package/dist/phase6/weight-presets/merger.js +161 -0
- package/dist/phase6/weight-presets/merger.js.map +1 -0
- package/dist/proof/index.d.ts +2 -0
- package/dist/proof/index.d.ts.map +1 -1
- package/dist/proof/index.js +24 -0
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/merkle.d.ts +195 -0
- package/dist/proof/merkle.d.ts.map +1 -0
- package/dist/proof/merkle.js +412 -0
- package/dist/proof/merkle.js.map +1 -0
- package/dist/proof/zk-proofs.d.ts +218 -0
- package/dist/proof/zk-proofs.d.ts.map +1 -0
- package/dist/proof/zk-proofs.js +531 -0
- package/dist/proof/zk-proofs.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts +98 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js +160 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.js +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +112 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js +158 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts +62 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.js +104 -0
- package/dist/trust-engine/context-policy/enforcement.js.map +1 -0
- package/dist/trust-engine/context-policy/factory.d.ts +75 -0
- package/dist/trust-engine/context-policy/factory.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/factory.js +130 -0
- package/dist/trust-engine/context-policy/factory.js.map +1 -0
- package/dist/trust-engine/context-policy/index.d.ts +6 -0
- package/dist/trust-engine/context-policy/index.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/index.js +6 -0
- package/dist/trust-engine/context-policy/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts +5 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.js +5 -0
- package/dist/trust-engine/creation-modifiers/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts +112 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.js +166 -0
- package/dist/trust-engine/creation-modifiers/types.js.map +1 -0
- package/dist/trust-engine/index.d.ts +54 -1
- package/dist/trust-engine/index.d.ts.map +1 -1
- package/dist/trust-engine/index.js +118 -1
- package/dist/trust-engine/index.js.map +1 -1
- package/dist/trust-engine/phase6-types.d.ts +123 -0
- package/dist/trust-engine/phase6-types.d.ts.map +1 -0
- package/dist/trust-engine/phase6-types.js +88 -0
- package/dist/trust-engine/phase6-types.js.map +1 -0
- package/package.json +19 -7
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CHAIN Layer - Blockchain Anchoring
|
|
3
|
+
*
|
|
4
|
+
* Anchors proof hashes to Polygon blockchain for immutable verification.
|
|
5
|
+
* Supports batching via Merkle trees for cost efficiency.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Polygon network configuration
|
|
11
|
+
*/
|
|
12
|
+
export declare const POLYGON_NETWORKS: {
|
|
13
|
+
readonly mainnet: {
|
|
14
|
+
readonly rpcUrl: "https://polygon-rpc.com";
|
|
15
|
+
readonly chainId: 137;
|
|
16
|
+
readonly blockExplorer: "https://polygonscan.com";
|
|
17
|
+
readonly name: "Polygon Mainnet";
|
|
18
|
+
};
|
|
19
|
+
readonly amoy: {
|
|
20
|
+
readonly rpcUrl: "https://rpc-amoy.polygon.technology";
|
|
21
|
+
readonly chainId: 80002;
|
|
22
|
+
readonly blockExplorer: "https://amoy.polygonscan.com";
|
|
23
|
+
readonly name: "Polygon Amoy Testnet";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type NetworkName = keyof typeof POLYGON_NETWORKS;
|
|
27
|
+
/**
|
|
28
|
+
* Chain anchor configuration
|
|
29
|
+
*/
|
|
30
|
+
export interface ChainAnchorConfig {
|
|
31
|
+
/** Network to use (mainnet or amoy testnet) */
|
|
32
|
+
network: NetworkName;
|
|
33
|
+
/** Deployed BASISAnchor contract address */
|
|
34
|
+
contractAddress: string;
|
|
35
|
+
/** Private key for transaction signing (hex string) */
|
|
36
|
+
privateKey?: string;
|
|
37
|
+
/** Custom RPC URL override */
|
|
38
|
+
rpcUrl?: string;
|
|
39
|
+
/** Gas limit multiplier (default: 1.2 = 20% buffer) */
|
|
40
|
+
gasMultiplier?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Proof data to anchor
|
|
44
|
+
*/
|
|
45
|
+
export interface ProofToAnchor {
|
|
46
|
+
/** SHA-256 hash of the proof (0x-prefixed hex) */
|
|
47
|
+
proofHash: string;
|
|
48
|
+
/** Agent ID associated with the proof */
|
|
49
|
+
agentId: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Result of anchoring operation
|
|
53
|
+
*/
|
|
54
|
+
export interface AnchorResult {
|
|
55
|
+
/** Batch ID assigned by the contract */
|
|
56
|
+
batchId: bigint;
|
|
57
|
+
/** Transaction hash */
|
|
58
|
+
transactionHash: string;
|
|
59
|
+
/** Block number where anchored */
|
|
60
|
+
blockNumber: number;
|
|
61
|
+
/** Merkle root of the batch */
|
|
62
|
+
merkleRoot: string;
|
|
63
|
+
/** Number of proofs in the batch */
|
|
64
|
+
proofCount: number;
|
|
65
|
+
/** Block explorer URL */
|
|
66
|
+
explorerUrl: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Result of verification operation
|
|
70
|
+
*/
|
|
71
|
+
export interface VerificationResult {
|
|
72
|
+
/** Whether the proof is valid on-chain */
|
|
73
|
+
valid: boolean;
|
|
74
|
+
/** Batch ID containing the proof */
|
|
75
|
+
batchId: bigint;
|
|
76
|
+
/** Merkle root of the batch */
|
|
77
|
+
merkleRoot: string;
|
|
78
|
+
/** Timestamp when anchored */
|
|
79
|
+
anchoredAt: Date;
|
|
80
|
+
/** Block explorer URL */
|
|
81
|
+
explorerUrl: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Compute SHA-256 hash of a string
|
|
85
|
+
*/
|
|
86
|
+
export declare function sha256(data: string): Promise<string>;
|
|
87
|
+
/**
|
|
88
|
+
* Compute keccak256 hash (Ethereum-style)
|
|
89
|
+
* Note: In production, use ethers.keccak256
|
|
90
|
+
*/
|
|
91
|
+
export declare function keccak256Concat(a: string, b: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Compute Merkle root from a list of hashes
|
|
94
|
+
*/
|
|
95
|
+
export declare function computeMerkleRoot(hashes: string[]): Promise<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Compute Merkle proof for a specific leaf
|
|
98
|
+
*/
|
|
99
|
+
export declare function computeMerkleProof(hashes: string[], targetIndex: number): Promise<string[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Verify a Merkle proof
|
|
102
|
+
*/
|
|
103
|
+
export declare function verifyMerkleProof(leaf: string, proof: string[], root: string): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Mock ChainAnchorService for testing
|
|
106
|
+
* In production, use the full implementation with ethers.js
|
|
107
|
+
*/
|
|
108
|
+
export declare class MockChainAnchorService {
|
|
109
|
+
private config;
|
|
110
|
+
private batchCount;
|
|
111
|
+
private batches;
|
|
112
|
+
private proofToBatch;
|
|
113
|
+
constructor(config: ChainAnchorConfig);
|
|
114
|
+
/**
|
|
115
|
+
* Mock anchor batch - simulates blockchain anchoring
|
|
116
|
+
*/
|
|
117
|
+
anchorBatch(proofs: ProofToAnchor[]): Promise<AnchorResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Mock verify proof
|
|
120
|
+
*/
|
|
121
|
+
verifyProof(proofHash: string, merkleProof: string[], batchId: bigint): Promise<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Mock get proof anchor info
|
|
124
|
+
*/
|
|
125
|
+
getProofAnchor(proofHash: string): Promise<VerificationResult | null>;
|
|
126
|
+
/**
|
|
127
|
+
* Get batch info
|
|
128
|
+
*/
|
|
129
|
+
getBatch(batchId: bigint): {
|
|
130
|
+
merkleRoot: string;
|
|
131
|
+
proofHashes: string[];
|
|
132
|
+
timestamp: Date;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Get stats
|
|
136
|
+
*/
|
|
137
|
+
getStats(): {
|
|
138
|
+
batchCount: bigint;
|
|
139
|
+
totalProofs: number;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a chain anchor service
|
|
144
|
+
* Returns mock service by default; use createRealChainAnchor for production
|
|
145
|
+
*/
|
|
146
|
+
export declare function createChainAnchor(config: ChainAnchorConfig): MockChainAnchorService;
|
|
147
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;CAanB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,OAAO,EAAE,WAAW,CAAC;IACrB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACj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;IACG,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAsB3E;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM;oBAnGmB,MAAM;qBAAe,MAAM,EAAE;mBAAa,IAAI;;IAuGzF;;OAEG;IACH,QAAQ;;;;CAMT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,sBAAsB,CAEnF"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CHAIN Layer - Blockchain Anchoring
|
|
3
|
+
*
|
|
4
|
+
* Anchors proof hashes to Polygon blockchain for immutable verification.
|
|
5
|
+
* Supports batching via Merkle trees for cost efficiency.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { createLogger } from '../common/logger.js';
|
|
10
|
+
const logger = createLogger({ component: 'chain' });
|
|
11
|
+
/**
|
|
12
|
+
* Polygon network configuration
|
|
13
|
+
*/
|
|
14
|
+
export const POLYGON_NETWORKS = {
|
|
15
|
+
mainnet: {
|
|
16
|
+
rpcUrl: 'https://polygon-rpc.com',
|
|
17
|
+
chainId: 137,
|
|
18
|
+
blockExplorer: 'https://polygonscan.com',
|
|
19
|
+
name: 'Polygon Mainnet',
|
|
20
|
+
},
|
|
21
|
+
amoy: {
|
|
22
|
+
rpcUrl: 'https://rpc-amoy.polygon.technology',
|
|
23
|
+
chainId: 80002,
|
|
24
|
+
blockExplorer: 'https://amoy.polygonscan.com',
|
|
25
|
+
name: 'Polygon Amoy Testnet',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Compute SHA-256 hash of a string
|
|
30
|
+
*/
|
|
31
|
+
export async function sha256(data) {
|
|
32
|
+
const encoder = new TextEncoder();
|
|
33
|
+
const dataBuffer = encoder.encode(data);
|
|
34
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', dataBuffer);
|
|
35
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
36
|
+
return '0x' + hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Compute keccak256 hash (Ethereum-style)
|
|
40
|
+
* Note: In production, use ethers.keccak256
|
|
41
|
+
*/
|
|
42
|
+
export async function keccak256Concat(a, b) {
|
|
43
|
+
// For testing, use sha256 as a stand-in
|
|
44
|
+
// In production, replace with ethers.keccak256(ethers.concat([a, b]))
|
|
45
|
+
return sha256(a + b);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Compute Merkle root from a list of hashes
|
|
49
|
+
*/
|
|
50
|
+
export async function computeMerkleRoot(hashes) {
|
|
51
|
+
if (hashes.length === 0) {
|
|
52
|
+
throw new Error('Cannot compute Merkle root of empty list');
|
|
53
|
+
}
|
|
54
|
+
if (hashes.length === 1) {
|
|
55
|
+
return hashes[0];
|
|
56
|
+
}
|
|
57
|
+
let layer = [...hashes];
|
|
58
|
+
while (layer.length > 1) {
|
|
59
|
+
const nextLayer = [];
|
|
60
|
+
for (let i = 0; i < layer.length; i += 2) {
|
|
61
|
+
if (i + 1 < layer.length) {
|
|
62
|
+
// Hash pair together (sorted for deterministic ordering)
|
|
63
|
+
const [left, right] = [layer[i], layer[i + 1]].sort();
|
|
64
|
+
nextLayer.push(await keccak256Concat(left, right));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Odd element, promote to next layer
|
|
68
|
+
nextLayer.push(layer[i]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
layer = nextLayer;
|
|
72
|
+
}
|
|
73
|
+
return layer[0];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Compute Merkle proof for a specific leaf
|
|
77
|
+
*/
|
|
78
|
+
export async function computeMerkleProof(hashes, targetIndex) {
|
|
79
|
+
if (targetIndex < 0 || targetIndex >= hashes.length) {
|
|
80
|
+
throw new Error('Target index out of bounds');
|
|
81
|
+
}
|
|
82
|
+
const proof = [];
|
|
83
|
+
let layer = [...hashes];
|
|
84
|
+
let index = targetIndex;
|
|
85
|
+
while (layer.length > 1) {
|
|
86
|
+
const siblingIndex = index % 2 === 0 ? index + 1 : index - 1;
|
|
87
|
+
if (siblingIndex < layer.length) {
|
|
88
|
+
proof.push(layer[siblingIndex]);
|
|
89
|
+
}
|
|
90
|
+
// Build next layer
|
|
91
|
+
const nextLayer = [];
|
|
92
|
+
for (let i = 0; i < layer.length; i += 2) {
|
|
93
|
+
if (i + 1 < layer.length) {
|
|
94
|
+
const [left, right] = [layer[i], layer[i + 1]].sort();
|
|
95
|
+
nextLayer.push(await keccak256Concat(left, right));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
nextLayer.push(layer[i]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
layer = nextLayer;
|
|
102
|
+
index = Math.floor(index / 2);
|
|
103
|
+
}
|
|
104
|
+
return proof;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Verify a Merkle proof
|
|
108
|
+
*/
|
|
109
|
+
export async function verifyMerkleProof(leaf, proof, root) {
|
|
110
|
+
let current = leaf;
|
|
111
|
+
for (const sibling of proof) {
|
|
112
|
+
const [left, right] = [current, sibling].sort();
|
|
113
|
+
current = await keccak256Concat(left, right);
|
|
114
|
+
}
|
|
115
|
+
return current === root;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Mock ChainAnchorService for testing
|
|
119
|
+
* In production, use the full implementation with ethers.js
|
|
120
|
+
*/
|
|
121
|
+
export class MockChainAnchorService {
|
|
122
|
+
config;
|
|
123
|
+
batchCount = 0n;
|
|
124
|
+
batches = new Map();
|
|
125
|
+
proofToBatch = new Map();
|
|
126
|
+
constructor(config) {
|
|
127
|
+
this.config = config;
|
|
128
|
+
logger.info({ network: config.network }, 'MockChainAnchorService initialized');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Mock anchor batch - simulates blockchain anchoring
|
|
132
|
+
*/
|
|
133
|
+
async anchorBatch(proofs) {
|
|
134
|
+
if (proofs.length === 0) {
|
|
135
|
+
throw new Error('Cannot anchor empty batch');
|
|
136
|
+
}
|
|
137
|
+
const proofHashes = proofs.map((p) => p.proofHash);
|
|
138
|
+
const merkleRoot = await computeMerkleRoot(proofHashes);
|
|
139
|
+
this.batchCount += 1n;
|
|
140
|
+
const batchId = this.batchCount;
|
|
141
|
+
this.batches.set(batchId, {
|
|
142
|
+
merkleRoot,
|
|
143
|
+
proofHashes,
|
|
144
|
+
timestamp: new Date(),
|
|
145
|
+
});
|
|
146
|
+
for (const hash of proofHashes) {
|
|
147
|
+
this.proofToBatch.set(hash, batchId);
|
|
148
|
+
}
|
|
149
|
+
const networkConfig = POLYGON_NETWORKS[this.config.network];
|
|
150
|
+
const mockTxHash = `0x${Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString('hex')}`;
|
|
151
|
+
logger.info({
|
|
152
|
+
batchId: batchId.toString(),
|
|
153
|
+
proofCount: proofs.length,
|
|
154
|
+
merkleRoot,
|
|
155
|
+
}, 'Batch anchored (mock)');
|
|
156
|
+
return {
|
|
157
|
+
batchId,
|
|
158
|
+
transactionHash: mockTxHash,
|
|
159
|
+
blockNumber: Math.floor(Math.random() * 1000000) + 50000000,
|
|
160
|
+
merkleRoot,
|
|
161
|
+
proofCount: proofs.length,
|
|
162
|
+
explorerUrl: `${networkConfig.blockExplorer}/tx/${mockTxHash}`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Mock verify proof
|
|
167
|
+
*/
|
|
168
|
+
async verifyProof(proofHash, merkleProof, batchId) {
|
|
169
|
+
const batch = this.batches.get(batchId);
|
|
170
|
+
if (!batch) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return verifyMerkleProof(proofHash, merkleProof, batch.merkleRoot);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Mock get proof anchor info
|
|
177
|
+
*/
|
|
178
|
+
async getProofAnchor(proofHash) {
|
|
179
|
+
const batchId = this.proofToBatch.get(proofHash);
|
|
180
|
+
if (!batchId) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const batch = this.batches.get(batchId);
|
|
184
|
+
if (!batch) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const networkConfig = POLYGON_NETWORKS[this.config.network];
|
|
188
|
+
return {
|
|
189
|
+
valid: true,
|
|
190
|
+
batchId,
|
|
191
|
+
merkleRoot: batch.merkleRoot,
|
|
192
|
+
anchoredAt: batch.timestamp,
|
|
193
|
+
explorerUrl: `${networkConfig.blockExplorer}/address/${this.config.contractAddress}`,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get batch info
|
|
198
|
+
*/
|
|
199
|
+
getBatch(batchId) {
|
|
200
|
+
return this.batches.get(batchId);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get stats
|
|
204
|
+
*/
|
|
205
|
+
getStats() {
|
|
206
|
+
return {
|
|
207
|
+
batchCount: this.batchCount,
|
|
208
|
+
totalProofs: this.proofToBatch.size,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Create a chain anchor service
|
|
214
|
+
* Returns mock service by default; use createRealChainAnchor for production
|
|
215
|
+
*/
|
|
216
|
+
export function createChainAnchor(config) {
|
|
217
|
+
return new MockChainAnchorService(config);
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chain/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,GAAG,YAAY,CAAC,EAA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b,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5D,OAAO;YACL,KAAK,EAAE,IAAI;YACX,OAAO;YACP,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,UAAU,EAAE,KAAK,CAAC,SAAS;YAC3B,WAAW,EAAE,GAAG,aAAa,CAAC,aAAa,YAAY,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;SACrF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;SACpC,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,OAAO,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Type Adapters for Legacy to Canonical Conversion
|
|
3
3
|
*
|
|
4
4
|
* Provides adapter functions to convert between legacy atsf-core types
|
|
5
|
-
* and canonical types from @
|
|
5
|
+
* and canonical types from @vorionsys/contracts for backwards compatibility.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
import type { TrustBand, TrustDimensions, RiskProfile } from '@
|
|
9
|
+
import type { TrustBand, TrustDimensions, RiskProfile } from '@vorionsys/contracts';
|
|
10
10
|
import type { ID, Timestamp, TrustLevel, TrustComponents, IntentStatus, RiskLevel } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* Legacy intent structure used in older atsf-core code
|
|
@@ -34,7 +34,7 @@ export interface LegacySignal {
|
|
|
34
34
|
metadata?: Record<string, unknown>;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Canonical intent structure from @
|
|
37
|
+
* Canonical intent structure from @vorionsys/contracts
|
|
38
38
|
*/
|
|
39
39
|
export interface CanonicalIntent {
|
|
40
40
|
intentId: string;
|
|
@@ -51,7 +51,7 @@ export interface CanonicalIntent {
|
|
|
51
51
|
source?: string;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Canonical trust signal (TrustEvidence) from @
|
|
54
|
+
* Canonical trust signal (TrustEvidence) from @vorionsys/contracts
|
|
55
55
|
*/
|
|
56
56
|
export interface CanonicalTrustSignal {
|
|
57
57
|
evidenceId: string;
|
|
@@ -93,7 +93,7 @@ export declare function adaptScoreToTrustBand(score: number): TrustBand;
|
|
|
93
93
|
* Adapts a legacy Intent to canonical Intent structure
|
|
94
94
|
*
|
|
95
95
|
* @param intent - Legacy intent from atsf-core
|
|
96
|
-
* @returns Canonical intent compatible with @
|
|
96
|
+
* @returns Canonical intent compatible with @vorionsys/contracts
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* ```typescript
|
|
@@ -105,7 +105,7 @@ export declare function adaptLegacyIntent(intent: LegacyIntent): CanonicalIntent
|
|
|
105
105
|
/**
|
|
106
106
|
* Adapts a canonical Intent back to legacy Intent structure
|
|
107
107
|
*
|
|
108
|
-
* @param intent - Canonical intent from @
|
|
108
|
+
* @param intent - Canonical intent from @vorionsys/contracts
|
|
109
109
|
* @returns Legacy intent compatible with atsf-core
|
|
110
110
|
*/
|
|
111
111
|
export declare function adaptCanonicalIntent(intent: CanonicalIntent): LegacyIntent;
|
|
@@ -113,7 +113,7 @@ export declare function adaptCanonicalIntent(intent: CanonicalIntent): LegacyInt
|
|
|
113
113
|
* Adapts a legacy TrustSignal to canonical TrustEvidence
|
|
114
114
|
*
|
|
115
115
|
* @param signal - Legacy trust signal from atsf-core
|
|
116
|
-
* @returns Canonical TrustEvidence compatible with @
|
|
116
|
+
* @returns Canonical TrustEvidence compatible with @vorionsys/contracts
|
|
117
117
|
*
|
|
118
118
|
* @example
|
|
119
119
|
* ```typescript
|
|
@@ -125,7 +125,7 @@ export declare function adaptLegacyTrustSignal(signal: LegacySignal): CanonicalT
|
|
|
125
125
|
/**
|
|
126
126
|
* Adapts canonical TrustEvidence back to legacy TrustSignal
|
|
127
127
|
*
|
|
128
|
-
* @param evidence - Canonical TrustEvidence from @
|
|
128
|
+
* @param evidence - Canonical TrustEvidence from @vorionsys/contracts
|
|
129
129
|
* @param entityId - Entity ID to associate with the signal
|
|
130
130
|
* @returns Legacy TrustSignal compatible with atsf-core
|
|
131
131
|
*/
|
|
@@ -167,6 +167,6 @@ export declare function adaptLegacyIntents(intents: LegacyIntent[]): CanonicalIn
|
|
|
167
167
|
* Batch adapt multiple legacy signals
|
|
168
168
|
*/
|
|
169
169
|
export declare function adaptLegacyTrustSignals(signals: LegacySignal[]): CanonicalTrustSignal[];
|
|
170
|
-
export type { TrustBand, TrustDimensions, TrustEvidence, RiskProfile, } from '@
|
|
170
|
+
export type { TrustBand, TrustDimensions, TrustEvidence, RiskProfile, } from '@vorionsys/contracts';
|
|
171
171
|
export type { TrustLevel, TrustScore, TrustSignal, TrustComponents, Intent, IntentStatus, RiskLevel, } from './types.js';
|
|
172
172
|
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/common/adapters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,WAAW,EACZ,MAAM,
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/common/adapters.ts"],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AG,WAAW,CAQrE;AAMD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,eAAe,GAAG,eAAe,CAQvF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,eAAe,GAAG,eAAe,CAQ1F;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAE7E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,oBAAoB,EAAE,CAEvF;AAMD,YAAY,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,eAAe,EACf,MAAM,EACN,YAAY,EACZ,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/common/adapters.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Type Adapters for Legacy to Canonical Conversion
|
|
3
3
|
*
|
|
4
4
|
* Provides adapter functions to convert between legacy atsf-core types
|
|
5
|
-
* and canonical types from @
|
|
5
|
+
* and canonical types from @vorionsys/contracts for backwards compatibility.
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// ============================================================================
|
|
12
12
|
/**
|
|
13
13
|
* Trust band thresholds for score-to-band mapping (0-1000 scale)
|
|
14
|
-
* Aligned with canonical DEFAULT_BAND_THRESHOLDS from @
|
|
14
|
+
* Aligned with canonical DEFAULT_BAND_THRESHOLDS from @vorionsys/contracts (8-tier model)
|
|
15
15
|
*/
|
|
16
16
|
const TRUST_BAND_THRESHOLDS = {
|
|
17
17
|
T0: { min: 0, max: 199 },
|
|
@@ -82,7 +82,7 @@ export function adaptScoreToTrustBand(score) {
|
|
|
82
82
|
* Adapts a legacy Intent to canonical Intent structure
|
|
83
83
|
*
|
|
84
84
|
* @param intent - Legacy intent from atsf-core
|
|
85
|
-
* @returns Canonical intent compatible with @
|
|
85
|
+
* @returns Canonical intent compatible with @vorionsys/contracts
|
|
86
86
|
*
|
|
87
87
|
* @example
|
|
88
88
|
* ```typescript
|
|
@@ -115,7 +115,7 @@ export function adaptLegacyIntent(intent) {
|
|
|
115
115
|
/**
|
|
116
116
|
* Adapts a canonical Intent back to legacy Intent structure
|
|
117
117
|
*
|
|
118
|
-
* @param intent - Canonical intent from @
|
|
118
|
+
* @param intent - Canonical intent from @vorionsys/contracts
|
|
119
119
|
* @returns Legacy intent compatible with atsf-core
|
|
120
120
|
*/
|
|
121
121
|
export function adaptCanonicalIntent(intent) {
|
|
@@ -177,7 +177,7 @@ const SIGNAL_TYPE_TO_DIMENSION = {
|
|
|
177
177
|
* Adapts a legacy TrustSignal to canonical TrustEvidence
|
|
178
178
|
*
|
|
179
179
|
* @param signal - Legacy trust signal from atsf-core
|
|
180
|
-
* @returns Canonical TrustEvidence compatible with @
|
|
180
|
+
* @returns Canonical TrustEvidence compatible with @vorionsys/contracts
|
|
181
181
|
*
|
|
182
182
|
* @example
|
|
183
183
|
* ```typescript
|
|
@@ -219,7 +219,7 @@ export function adaptLegacyTrustSignal(signal) {
|
|
|
219
219
|
/**
|
|
220
220
|
* Adapts canonical TrustEvidence back to legacy TrustSignal
|
|
221
221
|
*
|
|
222
|
-
* @param evidence - Canonical TrustEvidence from @
|
|
222
|
+
* @param evidence - Canonical TrustEvidence from @vorionsys/contracts
|
|
223
223
|
* @param entityId - Entity ID to associate with the signal
|
|
224
224
|
* @returns Legacy TrustSignal compatible with atsf-core
|
|
225
225
|
*/
|