@totemsdk/raster-proof 0.1.0
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/LICENSE +21 -0
- package/README.md +383 -0
- package/dist/canonical.d.ts +40 -0
- package/dist/canonical.js +76 -0
- package/dist/hash.d.ts +19 -0
- package/dist/hash.js +32 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +72 -0
- package/dist/manifest.d.ts +24 -0
- package/dist/manifest.js +146 -0
- package/dist/merkle.d.ts +49 -0
- package/dist/merkle.js +171 -0
- package/dist/proof.d.ts +54 -0
- package/dist/proof.js +247 -0
- package/dist/proofgraph.d.ts +51 -0
- package/dist/proofgraph.js +120 -0
- package/dist/provenance.d.ts +29 -0
- package/dist/provenance.js +95 -0
- package/dist/spatial.d.ts +23 -0
- package/dist/spatial.js +77 -0
- package/dist/types.d.ts +189 -0
- package/dist/types.js +14 -0
- package/dist/window.d.ts +19 -0
- package/dist/window.js +59 -0
- package/package.json +69 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @totemsdk/raster-proof — Type definitions
|
|
3
|
+
*
|
|
4
|
+
* Pure schema for raster and visual evidence proofs.
|
|
5
|
+
*
|
|
6
|
+
* This package proves bytes, manifests, provenance, windows and declared
|
|
7
|
+
* relationships. It does NOT process raster bytes — no decoding, no GDAL,
|
|
8
|
+
* no cloud masking, no NDVI, no ML. It only hashes bytes and records the
|
|
9
|
+
* metadata that makes them verifiable.
|
|
10
|
+
*
|
|
11
|
+
* No network, no storage, no map rendering, no GIS engine dependency.
|
|
12
|
+
*/
|
|
13
|
+
export type RasterSourceType = 'satellite' | 'drone' | 'camera' | 'robot-camera' | 'thermal-camera' | 'lidar-derived' | 'radar' | 'map-tile' | 'derived' | 'manual-import' | 'other';
|
|
14
|
+
export type RasterAssetFormat = 'geotiff' | 'cog' | 'png' | 'jpeg' | 'webp' | 'mbtiles' | 'zarr' | 'npy' | 'raw' | 'other';
|
|
15
|
+
export type RasterLayerType = 'rgb' | 'thermal' | 'multispectral' | 'sar' | 'lidar-derived' | 'depth' | 'change-mask' | 'water-mask' | 'vegetation-mask' | 'bare-earth-mask' | 'cloud-mask' | 'uncertainty-mask' | 'custom';
|
|
16
|
+
/**
|
|
17
|
+
* Spatial context for a raster asset. Bounds are GeoJSON order:
|
|
18
|
+
* [minLon, minLat, maxLon, maxLat] (WGS84 / EPSG:4326).
|
|
19
|
+
*/
|
|
20
|
+
export interface RasterSpatialMetadata {
|
|
21
|
+
crs?: string;
|
|
22
|
+
bounds?: [number, number, number, number];
|
|
23
|
+
resolutionM?: number;
|
|
24
|
+
widthPx?: number;
|
|
25
|
+
heightPx?: number;
|
|
26
|
+
/** totem:geo:<hex> hash of the footprint geometry (via @totemsdk/spatial-proof). */
|
|
27
|
+
geometryHash?: string;
|
|
28
|
+
/** totem:spatial:<hex> spatial object ID the footprint maps to. */
|
|
29
|
+
spatialObjectId?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface RasterAssetRef {
|
|
32
|
+
uri?: string;
|
|
33
|
+
mediaType?: string;
|
|
34
|
+
format: RasterAssetFormat;
|
|
35
|
+
byteSize?: number;
|
|
36
|
+
contentHash: string;
|
|
37
|
+
hashAlgorithm: 'sha3-256';
|
|
38
|
+
merkleRoot?: string;
|
|
39
|
+
chunkSizeBytes?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface RasterProvenance {
|
|
42
|
+
derivedFrom?: string[];
|
|
43
|
+
pipelineId?: string;
|
|
44
|
+
pipelineVersion?: string;
|
|
45
|
+
parametersHash?: string;
|
|
46
|
+
operatorId?: string;
|
|
47
|
+
modelId?: string;
|
|
48
|
+
uncertainty?: string[];
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface RasterManifest {
|
|
52
|
+
rasterId: string;
|
|
53
|
+
sourceType: RasterSourceType;
|
|
54
|
+
layerType: RasterLayerType;
|
|
55
|
+
capturedAt?: number;
|
|
56
|
+
createdAt: number;
|
|
57
|
+
deviceId?: string;
|
|
58
|
+
operatorId?: string;
|
|
59
|
+
missionId?: string;
|
|
60
|
+
providerId?: string;
|
|
61
|
+
sceneId?: string;
|
|
62
|
+
asset: RasterAssetRef;
|
|
63
|
+
spatial?: RasterSpatialMetadata;
|
|
64
|
+
provenance?: RasterProvenance;
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
export interface RasterChunk {
|
|
68
|
+
index: number;
|
|
69
|
+
offset: number;
|
|
70
|
+
length: number;
|
|
71
|
+
hash: string;
|
|
72
|
+
}
|
|
73
|
+
export interface RasterMerkleProof {
|
|
74
|
+
root: string;
|
|
75
|
+
leafHash: string;
|
|
76
|
+
leafIndex: number;
|
|
77
|
+
siblings: Array<{
|
|
78
|
+
position: 'left' | 'right';
|
|
79
|
+
hash: string;
|
|
80
|
+
}>;
|
|
81
|
+
hashAlgorithm: 'sha3-256';
|
|
82
|
+
}
|
|
83
|
+
export interface RasterWindowProof {
|
|
84
|
+
windowProofId: string;
|
|
85
|
+
rasterId: string;
|
|
86
|
+
merkleRoot: string;
|
|
87
|
+
chunkIndices: number[];
|
|
88
|
+
chunkHashes: string[];
|
|
89
|
+
spatial?: RasterSpatialMetadata;
|
|
90
|
+
createdAt: number;
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
export interface RasterValidationResult {
|
|
94
|
+
valid: boolean;
|
|
95
|
+
errors: string[];
|
|
96
|
+
warnings: string[];
|
|
97
|
+
}
|
|
98
|
+
export interface RasterMerkleSummary {
|
|
99
|
+
contentHash: string;
|
|
100
|
+
merkleRoot: string;
|
|
101
|
+
chunkSizeBytes: number;
|
|
102
|
+
chunkCount: number;
|
|
103
|
+
byteSize: number;
|
|
104
|
+
}
|
|
105
|
+
export interface RasterMerkleOptions {
|
|
106
|
+
chunkSizeBytes?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface CreateRasterManifestParams {
|
|
109
|
+
sourceType: RasterSourceType;
|
|
110
|
+
layerType: RasterLayerType;
|
|
111
|
+
asset: RasterAssetRef;
|
|
112
|
+
capturedAt?: number;
|
|
113
|
+
createdAt?: number;
|
|
114
|
+
deviceId?: string;
|
|
115
|
+
operatorId?: string;
|
|
116
|
+
missionId?: string;
|
|
117
|
+
providerId?: string;
|
|
118
|
+
sceneId?: string;
|
|
119
|
+
spatial?: RasterSpatialMetadata;
|
|
120
|
+
provenance?: RasterProvenance;
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface CreateDerivedRasterManifestParams {
|
|
124
|
+
sourceManifests: RasterManifest[];
|
|
125
|
+
layerType: RasterLayerType;
|
|
126
|
+
asset: RasterAssetRef;
|
|
127
|
+
capturedAt?: number;
|
|
128
|
+
createdAt?: number;
|
|
129
|
+
deviceId?: string;
|
|
130
|
+
operatorId?: string;
|
|
131
|
+
missionId?: string;
|
|
132
|
+
providerId?: string;
|
|
133
|
+
sceneId?: string;
|
|
134
|
+
spatial?: RasterSpatialMetadata;
|
|
135
|
+
pipelineId?: string;
|
|
136
|
+
pipelineVersion?: string;
|
|
137
|
+
parametersHash?: string;
|
|
138
|
+
modelId?: string;
|
|
139
|
+
uncertainty?: string[];
|
|
140
|
+
metadata?: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
export interface CreateRasterWindowProofParams {
|
|
143
|
+
rasterId: string;
|
|
144
|
+
merkleRoot: string;
|
|
145
|
+
chunkIndices: number[];
|
|
146
|
+
chunkHashes: string[];
|
|
147
|
+
spatial?: RasterSpatialMetadata;
|
|
148
|
+
createdAt?: number;
|
|
149
|
+
metadata?: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
export interface RasterDerivationVerifyResult {
|
|
152
|
+
valid: boolean;
|
|
153
|
+
reasons?: string[];
|
|
154
|
+
sourceRasterIds?: string[];
|
|
155
|
+
missingSources?: string[];
|
|
156
|
+
uncertainty?: string[];
|
|
157
|
+
}
|
|
158
|
+
export interface CreateRasterSpatialRelationParams {
|
|
159
|
+
manifest: RasterManifest;
|
|
160
|
+
/** Spatial object from @totemsdk/spatial-proof (site boundary, zone, route, …). */
|
|
161
|
+
spatialObject: import('@totemsdk/spatial-proof').SpatialObject;
|
|
162
|
+
relation: import('@totemsdk/spatial-proof').SpatialRelationType;
|
|
163
|
+
computedAt?: number;
|
|
164
|
+
maxDistanceM?: number;
|
|
165
|
+
subjectProofId?: string;
|
|
166
|
+
metadata?: Record<string, unknown>;
|
|
167
|
+
}
|
|
168
|
+
export interface CreateRasterProofParams {
|
|
169
|
+
manifest: RasterManifest;
|
|
170
|
+
windowProof?: RasterWindowProof;
|
|
171
|
+
/** Full Merkle proofs for chunks referenced by windowProof (optional, enables leaf-level verification). */
|
|
172
|
+
merkleProofs?: RasterMerkleProof[];
|
|
173
|
+
/** Spatial object ID referenced by the raster footprint (added as evidence ref). */
|
|
174
|
+
spatialObjectId?: string;
|
|
175
|
+
issuer?: string;
|
|
176
|
+
issuedAt?: number;
|
|
177
|
+
expiresAt?: number;
|
|
178
|
+
}
|
|
179
|
+
export interface RasterProofVerifyResult {
|
|
180
|
+
valid: boolean;
|
|
181
|
+
reason?: string;
|
|
182
|
+
signerAddress?: string;
|
|
183
|
+
rasterId?: string;
|
|
184
|
+
payloadValid?: boolean;
|
|
185
|
+
rasterIdValid?: boolean;
|
|
186
|
+
manifestHashValid?: boolean;
|
|
187
|
+
windowProofValid?: boolean;
|
|
188
|
+
derivationValid?: boolean;
|
|
189
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @totemsdk/raster-proof — Type definitions
|
|
4
|
+
*
|
|
5
|
+
* Pure schema for raster and visual evidence proofs.
|
|
6
|
+
*
|
|
7
|
+
* This package proves bytes, manifests, provenance, windows and declared
|
|
8
|
+
* relationships. It does NOT process raster bytes — no decoding, no GDAL,
|
|
9
|
+
* no cloud masking, no NDVI, no ML. It only hashes bytes and records the
|
|
10
|
+
* metadata that makes them verifiable.
|
|
11
|
+
*
|
|
12
|
+
* No network, no storage, no map rendering, no GIS engine dependency.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/window.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raster window / tile proof construction for @totemsdk/raster-proof.
|
|
3
|
+
*
|
|
4
|
+
* A window proof attests that a subset of chunks (a spatial window, a tile,
|
|
5
|
+
* a scene patch) belongs to a raster whose Merkle root is known. It carries
|
|
6
|
+
* the chunk indices and their content hashes so a verifier can tie a specific
|
|
7
|
+
* set of bytes to the root without re-hashing the whole asset.
|
|
8
|
+
*/
|
|
9
|
+
import type { EvidenceRef } from '@totemsdk/proof';
|
|
10
|
+
import type { CreateRasterWindowProofParams, RasterWindowProof } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Create a deterministic RasterWindowProof. windowProofId is computed from
|
|
13
|
+
* stable fields (everything except windowProofId and metadata).
|
|
14
|
+
*/
|
|
15
|
+
export declare function createRasterWindowProof(params: CreateRasterWindowProofParams): RasterWindowProof;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a RasterWindowProof into an EvidenceRef for inclusion in a proof.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rasterWindowProofToEvidenceRef(proof: RasterWindowProof): EvidenceRef;
|
package/dist/window.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Raster window / tile proof construction for @totemsdk/raster-proof.
|
|
4
|
+
*
|
|
5
|
+
* A window proof attests that a subset of chunks (a spatial window, a tile,
|
|
6
|
+
* a scene patch) belongs to a raster whose Merkle root is known. It carries
|
|
7
|
+
* the chunk indices and their content hashes so a verifier can tie a specific
|
|
8
|
+
* set of bytes to the root without re-hashing the whole asset.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createRasterWindowProof = createRasterWindowProof;
|
|
12
|
+
exports.rasterWindowProofToEvidenceRef = rasterWindowProofToEvidenceRef;
|
|
13
|
+
const canonical_js_1 = require("./canonical.js");
|
|
14
|
+
/**
|
|
15
|
+
* Create a deterministic RasterWindowProof. windowProofId is computed from
|
|
16
|
+
* stable fields (everything except windowProofId and metadata).
|
|
17
|
+
*/
|
|
18
|
+
function createRasterWindowProof(params) {
|
|
19
|
+
const { rasterId, merkleRoot, chunkIndices, chunkHashes, spatial, createdAt = Date.now(), metadata } = params;
|
|
20
|
+
if (chunkIndices.length === 0) {
|
|
21
|
+
throw new Error('a window proof must reference at least one chunk');
|
|
22
|
+
}
|
|
23
|
+
if (chunkIndices.length !== chunkHashes.length) {
|
|
24
|
+
throw new Error('chunkIndices and chunkHashes must have equal length');
|
|
25
|
+
}
|
|
26
|
+
for (const idx of chunkIndices) {
|
|
27
|
+
if (!Number.isInteger(idx) || idx < 0) {
|
|
28
|
+
throw new Error('chunk indices must be non-negative integers');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const h of chunkHashes) {
|
|
32
|
+
if (!/^[a-f0-9]{64}$/.test(h)) {
|
|
33
|
+
throw new Error('chunk hashes must be 64-char lowercase hex (sha3-256)');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!/^[a-f0-9]{64}$/.test(merkleRoot)) {
|
|
37
|
+
throw new Error('merkleRoot must be 64-char lowercase hex (sha3-256)');
|
|
38
|
+
}
|
|
39
|
+
const body = {
|
|
40
|
+
rasterId,
|
|
41
|
+
merkleRoot,
|
|
42
|
+
chunkIndices,
|
|
43
|
+
chunkHashes,
|
|
44
|
+
...(spatial !== undefined ? { spatial } : {}),
|
|
45
|
+
createdAt,
|
|
46
|
+
...(metadata !== undefined ? { metadata } : {}),
|
|
47
|
+
};
|
|
48
|
+
return { ...body, windowProofId: (0, canonical_js_1.computeRasterWindowProofId)(body) };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Convert a RasterWindowProof into an EvidenceRef for inclusion in a proof.
|
|
52
|
+
*/
|
|
53
|
+
function rasterWindowProofToEvidenceRef(proof) {
|
|
54
|
+
return {
|
|
55
|
+
id: proof.windowProofId,
|
|
56
|
+
kind: 'raster-window-proof',
|
|
57
|
+
hash: (0, canonical_js_1.hashRasterWindowProof)(proof),
|
|
58
|
+
};
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@totemsdk/raster-proof",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Edge-capable raster and visual evidence proof primitives for Totem Edge — asset hashes, tile Merkle roots, raster manifests, derived-layer provenance, and proof envelope integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@totemsdk/core": "^1.2.7",
|
|
21
|
+
"@totemsdk/proof": "^0.1.2",
|
|
22
|
+
"@totemsdk/proofgraph": "^0.1.1",
|
|
23
|
+
"@totemsdk/spatial-proof": "^0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^30.0.0",
|
|
27
|
+
"@types/node": "^20.0.0",
|
|
28
|
+
"jest": "^30.4.2",
|
|
29
|
+
"ts-jest": "^29.0.0",
|
|
30
|
+
"typescript": "^7.0.2"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.0.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"author": "Totem SDK",
|
|
40
|
+
"homepage": "https://totem.ing",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/totem-sdk/totem-sdk/issues"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/totem-sdk/totem-sdk.git",
|
|
47
|
+
"directory": "packages/raster-proof"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"totem",
|
|
51
|
+
"totemsdk",
|
|
52
|
+
"raster",
|
|
53
|
+
"imagery",
|
|
54
|
+
"drone",
|
|
55
|
+
"satellite",
|
|
56
|
+
"geotiff",
|
|
57
|
+
"proof",
|
|
58
|
+
"merkle",
|
|
59
|
+
"edge",
|
|
60
|
+
"visual-evidence",
|
|
61
|
+
"spatial",
|
|
62
|
+
"autonomous-devices"
|
|
63
|
+
],
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsc",
|
|
66
|
+
"clean": "rm -rf dist",
|
|
67
|
+
"test": "jest"
|
|
68
|
+
}
|
|
69
|
+
}
|