yakmesh 2.8.2 → 3.0.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/CHANGELOG.md +637 -0
- package/CONTRIBUTING.md +42 -0
- package/Caddyfile +77 -0
- package/README.md +119 -29
- package/adapters/adapter-mlv-bible/README.md +124 -0
- package/adapters/adapter-mlv-bible/index.js +400 -0
- package/adapters/chat-mod-adapter.js +532 -0
- package/adapters/content-adapter.js +273 -0
- package/content/api.js +50 -41
- package/content/index.js +2 -2
- package/content/store.js +355 -173
- package/dashboard/index.html +19 -3
- package/database/replication.js +117 -37
- package/docs/CRYPTO-AGILITY.md +204 -0
- package/docs/MTLS-RESEARCH.md +367 -0
- package/docs/NAMCHE-SPEC.md +681 -0
- package/docs/PEERQUANTA-YAKMESH-INTEGRATION.md +407 -0
- package/docs/PRECISION-DISCLOSURE.md +96 -0
- package/docs/README.md +76 -0
- package/docs/ROADMAP-2.4.0.md +447 -0
- package/docs/ROADMAP-2.5.0.md +244 -0
- package/docs/SECURITY-AUDIT-REPORT.md +306 -0
- package/docs/SST-INTEGRATION.md +712 -0
- package/docs/STEADYWATCH-IMPLEMENTATION.md +303 -0
- package/docs/TERNARY-AUDIT-REPORT.md +247 -0
- package/docs/TME-FAQ.md +221 -0
- package/docs/WHITEPAPER.md +623 -0
- package/docs/adapters.html +1001 -0
- package/docs/advanced-systems.html +1045 -0
- package/docs/annex.html +1046 -0
- package/docs/api.html +970 -0
- package/docs/business/response-templates.md +160 -0
- package/docs/c2c.html +1225 -0
- package/docs/cli.html +1332 -0
- package/docs/configuration.html +1248 -0
- package/docs/darshan.html +1085 -0
- package/docs/dharma.html +966 -0
- package/docs/docs-bundle.html +1075 -0
- package/docs/docs.css +3120 -0
- package/docs/docs.js +556 -0
- package/docs/doko.html +969 -0
- package/docs/geo-proof.html +858 -0
- package/docs/getting-started.html +840 -0
- package/docs/gumba-tutorial.html +1144 -0
- package/docs/gumba.html +1098 -0
- package/docs/index.html +914 -0
- package/docs/jhilke.html +1312 -0
- package/docs/karma.html +1100 -0
- package/docs/katha.html +1037 -0
- package/docs/lama.html +978 -0
- package/docs/mandala.html +1067 -0
- package/docs/mani.html +964 -0
- package/docs/mantra.html +967 -0
- package/docs/mesh.html +1409 -0
- package/docs/nakpak.html +869 -0
- package/docs/namche.html +928 -0
- package/docs/nav-order.json +53 -0
- package/docs/prahari.html +1043 -0
- package/docs/prism-bash.min.js +1 -0
- package/docs/prism-javascript.min.js +1 -0
- package/docs/prism-json.min.js +1 -0
- package/docs/prism-tomorrow.min.css +1 -0
- package/docs/prism.min.js +1 -0
- package/docs/privacy.html +699 -0
- package/docs/quick-reference.html +1181 -0
- package/docs/sakshi.html +1402 -0
- package/docs/sandboxing.md +386 -0
- package/docs/seva.html +911 -0
- package/docs/sherpa.html +871 -0
- package/docs/studio.html +860 -0
- package/docs/stupa.html +995 -0
- package/docs/tailwind.min.css +2 -0
- package/docs/tattva.html +1332 -0
- package/docs/terms.html +686 -0
- package/docs/time-server-deployment.md +166 -0
- package/docs/time-sources.html +1392 -0
- package/docs/tivra.html +1127 -0
- package/docs/trademark-policy.html +686 -0
- package/docs/tribhuj.html +1183 -0
- package/docs/trust-security.html +1029 -0
- package/docs/tutorials/backup-recovery.html +654 -0
- package/docs/tutorials/dashboard.html +604 -0
- package/docs/tutorials/domain-setup.html +605 -0
- package/docs/tutorials/host-website.html +456 -0
- package/docs/tutorials/mesh-network.html +505 -0
- package/docs/tutorials/mobile-access.html +445 -0
- package/docs/tutorials/privacy.html +467 -0
- package/docs/tutorials/raspberry-pi.html +600 -0
- package/docs/tutorials/security-basics.html +539 -0
- package/docs/tutorials/share-files.html +431 -0
- package/docs/tutorials/troubleshooting.html +637 -0
- package/docs/tutorials/trust-karma.html +419 -0
- package/docs/tutorials/yak-protocol.html +456 -0
- package/docs/tutorials.html +1034 -0
- package/docs/vani.html +1270 -0
- package/docs/webserver.html +809 -0
- package/docs/yak-protocol.html +940 -0
- package/docs/yak-timeserver-design.md +475 -0
- package/docs/yakapp.html +1015 -0
- package/docs/ypc27.html +1069 -0
- package/docs/yurt.html +1344 -0
- package/embedded-docs/bundle.js +334 -74
- package/gossip/protocol.js +247 -27
- package/identity/key-resolver.js +262 -0
- package/identity/machine-seed.js +632 -0
- package/identity/node-key.js +669 -368
- package/identity/tribhuj-ratchet.js +506 -0
- package/knowledge-base.js +37 -8
- package/launcher/yakmesh.bat +62 -0
- package/launcher/yakmesh.sh +70 -0
- package/mesh/annex.js +462 -108
- package/mesh/beacon-broadcast.js +113 -1
- package/mesh/darshan.js +1718 -0
- package/mesh/gumba.js +1567 -0
- package/mesh/jhilke.js +651 -0
- package/mesh/katha.js +1012 -0
- package/mesh/nakpak-routing.js +8 -5
- package/mesh/network.js +724 -34
- package/mesh/pulse-sync.js +4 -1
- package/mesh/rate-limiter.js +127 -15
- package/mesh/seva.js +526 -0
- package/mesh/sherpa-discovery.js +89 -8
- package/mesh/sybil-defense.js +19 -5
- package/mesh/temporal-encoder.js +4 -3
- package/mesh/vani.js +1364 -0
- package/mesh/yurt.js +1340 -0
- package/models/entropy-sentinel.onnx +0 -0
- package/models/karma-trust.onnx +0 -0
- package/models/manifest.json +43 -0
- package/models/sakshi-anomaly.onnx +0 -0
- package/oracle/code-proof-protocol.js +7 -6
- package/oracle/codebase-lock.js +257 -28
- package/oracle/index.js +74 -15
- package/oracle/ma902-snmp.js +678 -0
- package/oracle/module-sealer.js +5 -3
- package/oracle/network-identity.js +16 -0
- package/oracle/packet-checksum.js +201 -0
- package/oracle/sst.js +579 -0
- package/oracle/ternary-144t.js +714 -0
- package/oracle/ternary-ml.js +481 -0
- package/oracle/time-api.js +239 -0
- package/oracle/time-source.js +137 -47
- package/oracle/validation-oracle-hardened.js +1111 -1071
- package/oracle/validation-oracle.js +4 -2
- package/oracle/ypc27.js +211 -0
- package/package.json +20 -3
- package/protocol/yak-handler.js +35 -9
- package/protocol/yak-protocol.js +28 -13
- package/reference/cpp/yakmesh_mceliece_shard.cpp +168 -0
- package/reference/cpp/yakmesh_ypc27.cpp +179 -0
- package/sbom.json +87 -0
- package/scripts/security-audit.mjs +264 -0
- package/scripts/update-docs-nav.js +194 -0
- package/scripts/update-docs-sidebar.cjs +164 -0
- package/security/crypto-config.js +4 -3
- package/security/dharma-moderation.js +517 -0
- package/security/doko-identity.js +193 -143
- package/security/domain-consensus.js +86 -85
- package/security/fs-hardening.js +620 -0
- package/security/hardware-attestation.js +5 -3
- package/security/hybrid-trust.js +227 -87
- package/security/karma-rate-limiter.js +692 -0
- package/security/khata-protocol.js +22 -21
- package/security/khata-trust-integration.js +277 -150
- package/security/memory-safety.js +635 -0
- package/security/mesh-auth.js +11 -10
- package/security/mesh-revocation.js +373 -5
- package/security/namche-gateway.js +298 -69
- package/security/sakshi.js +460 -3
- package/security/sangha.js +770 -0
- package/security/secure-config.js +473 -0
- package/security/silicon-parity.js +13 -10
- package/security/steadywatch.js +1142 -0
- package/security/strike-system.js +32 -3
- package/security/temporal-signing.js +488 -0
- package/security/trit-commitment.js +464 -0
- package/server/crypto/annex.js +247 -0
- package/server/darshan-api.js +343 -0
- package/server/index.js +3259 -362
- package/server/komm-api.js +668 -0
- package/utils/accel.js +2273 -0
- package/utils/ternary-id.js +79 -0
- package/utils/verify-worker.js +57 -0
- package/webserver/index.js +95 -5
- package/assets/yakmesh-logo.png +0 -0
- package/assets/yakmesh-logo.svg +0 -80
- package/assets/yakmesh-logo2.png +0 -0
- package/assets/yakmesh-logo2sm.png +0 -0
- package/assets/ymsm.png +0 -0
- package/website/assets/silhouettes/adapters.svg +0 -107
- package/website/assets/silhouettes/api-endpoints.svg +0 -115
- package/website/assets/silhouettes/atomic-clock.svg +0 -83
- package/website/assets/silhouettes/base-camp.svg +0 -81
- package/website/assets/silhouettes/bridge.svg +0 -69
- package/website/assets/silhouettes/docs-bundle.svg +0 -113
- package/website/assets/silhouettes/doko-basket.svg +0 -70
- package/website/assets/silhouettes/fortress.svg +0 -93
- package/website/assets/silhouettes/gateway.svg +0 -54
- package/website/assets/silhouettes/gears.svg +0 -93
- package/website/assets/silhouettes/globe-satellite.svg +0 -67
- package/website/assets/silhouettes/karma-wheel.svg +0 -137
- package/website/assets/silhouettes/lama-council.svg +0 -141
- package/website/assets/silhouettes/mandala-network.svg +0 -169
- package/website/assets/silhouettes/mani-stones.svg +0 -149
- package/website/assets/silhouettes/mantra-wheel.svg +0 -116
- package/website/assets/silhouettes/mesh-nodes.svg +0 -113
- package/website/assets/silhouettes/nakpak.svg +0 -56
- package/website/assets/silhouettes/peak-lightning.svg +0 -73
- package/website/assets/silhouettes/sherpa.svg +0 -69
- package/website/assets/silhouettes/stupa-tower.svg +0 -119
- package/website/assets/silhouettes/tattva-eye.svg +0 -78
- package/website/assets/silhouettes/terminal.svg +0 -74
- package/website/assets/silhouettes/webserver.svg +0 -145
- package/website/assets/silhouettes/yak.svg +0 -78
- package/website/assets/yakmesh-logo.png +0 -0
- package/website/assets/yakmesh-logo.webp +0 -0
- package/website/assets/yakmesh-logo128x140.webp +0 -0
- package/website/assets/yakmesh-logo2.png +0 -0
- package/website/assets/yakmesh-logo2.svg +0 -51
- package/website/assets/yakmesh-logo40x44.webp +0 -0
- package/website/assets/yakmesh.gif +0 -0
- package/website/assets/yakmesh.ico +0 -0
- package/website/assets/yakmesh.jpg +0 -0
- package/website/assets/yakmesh.pdf +0 -0
- package/website/assets/yakmesh.png +0 -0
- package/website/assets/yakmesh.svg +0 -70
- package/website/assets/yakmesh128.webp +0 -0
- package/website/assets/yakmesh32.png +0 -0
- package/website/assets/yakmesh32.svg +0 -65
- package/website/assets/yakmesh32o.ico +0 -2
- package/website/assets/yakmesh32o.svg +0 -65
- package/website/assets/yakmesh32o.svgz +0 -0
|
@@ -30,9 +30,11 @@
|
|
|
30
30
|
* @deprecated Use validation-oracle-hardened.js
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import { sha3_256, sha3_512 } from '@noble/hashes/sha3.js';
|
|
33
|
+
import { sha3_256 as _nobleSha3, sha3_512 } from '@noble/hashes/sha3.js';
|
|
34
34
|
import { bytesToHex, hexToBytes, utf8ToBytes } from '@noble/hashes/utils.js';
|
|
35
35
|
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
|
|
36
|
+
// ACCEL: Hardware-accelerated crypto
|
|
37
|
+
import { sha3_256, mlDsa65Verify } from '../utils/accel.js';
|
|
36
38
|
import { readFileSync } from 'fs';
|
|
37
39
|
import { fileURLToPath } from 'url';
|
|
38
40
|
import { dirname, join } from 'path';
|
|
@@ -491,7 +493,7 @@ export class ValidationOracle {
|
|
|
491
493
|
const pubKeyBytes = hexToBytes(publicKey);
|
|
492
494
|
|
|
493
495
|
// ML-DSA65 verify order: (signature, message, publicKey)
|
|
494
|
-
const valid =
|
|
496
|
+
const valid = mlDsa65Verify(sigBytes, messageBytes, pubKeyBytes);
|
|
495
497
|
|
|
496
498
|
if (!valid) {
|
|
497
499
|
return ValidationResult.failure('SIGNATURE_INVALID');
|
package/oracle/ypc27.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { Trit, TritArray, POSITIVE, NEUTRAL, NEGATIVE } from './tribhuj.js';
|
|
22
|
+
import { FIBONACCI_CYCLE_24, getFamily, SSTFamily } from './sst.js';
|
|
22
23
|
|
|
23
24
|
// =============================================================================
|
|
24
25
|
// CONSTANTS
|
|
@@ -369,6 +370,15 @@ export class YPC27Checksum {
|
|
|
369
370
|
this.#state = Poly27.zero();
|
|
370
371
|
}
|
|
371
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Set internal state directly (for subclass SST override).
|
|
375
|
+
* @param {Poly27} newState
|
|
376
|
+
* @protected
|
|
377
|
+
*/
|
|
378
|
+
_setState(newState) {
|
|
379
|
+
this.#state = newState;
|
|
380
|
+
}
|
|
381
|
+
|
|
372
382
|
/**
|
|
373
383
|
* Compute checksum of data in one call.
|
|
374
384
|
* @param {Uint8Array | string} data
|
|
@@ -394,6 +404,207 @@ export class YPC27Checksum {
|
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
|
|
407
|
+
// =============================================================================
|
|
408
|
+
// YPC27_SST — SST-Enhanced Checksum with 24-Cycle Seed Rotation
|
|
409
|
+
// =============================================================================
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* YPC-27 with Synergy Sequence Theory (SST) 24-cycle seed rotation.
|
|
413
|
+
*
|
|
414
|
+
* The seed polynomial rotates based on the Fibonacci digital root cycle:
|
|
415
|
+
* - Family A (1,4,7): Rotate seed LEFT by fibRoot positions (negative polarity)
|
|
416
|
+
* - Family B (2,5,8): Rotate seed RIGHT by fibRoot positions (positive polarity)
|
|
417
|
+
* - Family C (3,6,9): No rotation — singularity/stable point
|
|
418
|
+
*
|
|
419
|
+
* The full hypercycle repeats every LCM(27, 24) = 216 chunks.
|
|
420
|
+
* This creates 216 unique seed configurations before repeating,
|
|
421
|
+
* dramatically increasing resistance to pattern analysis attacks.
|
|
422
|
+
*
|
|
423
|
+
* Properties:
|
|
424
|
+
* - Deterministic: all nodes compute the same rotation for the same data
|
|
425
|
+
* - Self-synchronizing: rotation state is derived from chunk index, not mutable state
|
|
426
|
+
* - Compatible: YPC27_SST.verify() can verify its own checksums
|
|
427
|
+
* - The 3-6-9 governing family acts as a stability anchor (no rotation)
|
|
428
|
+
*
|
|
429
|
+
* @extends YPC27Checksum
|
|
430
|
+
*/
|
|
431
|
+
export class YPC27_SST extends YPC27Checksum {
|
|
432
|
+
/** @type {number} Current cycle position within the 24-step Fibonacci cycle */
|
|
433
|
+
#cyclePosition;
|
|
434
|
+
|
|
435
|
+
/** @type {number[]} Original unrotated seed coefficients */
|
|
436
|
+
#baseSeed;
|
|
437
|
+
|
|
438
|
+
/** @type {number} Total chunks processed (for telemetry) */
|
|
439
|
+
#chunksProcessed;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Create an SST-enhanced checksum engine.
|
|
443
|
+
* @param {Poly27 | number[]} [seed] - Network seed, defaults to DEFAULT_SEED
|
|
444
|
+
*/
|
|
445
|
+
constructor(seed = DEFAULT_SEED) {
|
|
446
|
+
super(seed);
|
|
447
|
+
this.#baseSeed = seed instanceof Poly27 ? seed.toArray() : Array.from(seed);
|
|
448
|
+
this.#cyclePosition = 0;
|
|
449
|
+
this.#chunksProcessed = 0;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Get the rotated seed for the current cycle position.
|
|
454
|
+
* The rotation direction and magnitude are determined by the
|
|
455
|
+
* Fibonacci digital root at the current position:
|
|
456
|
+
*
|
|
457
|
+
* Position → fibRoot → Family → Rotation
|
|
458
|
+
* 0 → 1 → A → LEFT by 1
|
|
459
|
+
* 1 → 1 → A → LEFT by 1
|
|
460
|
+
* 2 → 2 → B → RIGHT by 2
|
|
461
|
+
* 3 → 3 → C → NONE (singularity)
|
|
462
|
+
* ...repeats every 24
|
|
463
|
+
*
|
|
464
|
+
* @returns {number[]} Rotated seed coefficients
|
|
465
|
+
*/
|
|
466
|
+
#getRotatedSeed() {
|
|
467
|
+
const fibRoot = FIBONACCI_CYCLE_24[this.#cyclePosition % 24];
|
|
468
|
+
const family = getFamily(fibRoot);
|
|
469
|
+
const rotateAmount = fibRoot % N; // Constrain to ring degree
|
|
470
|
+
|
|
471
|
+
switch (family) {
|
|
472
|
+
case SSTFamily.A:
|
|
473
|
+
return YPC27_SST.#rotateArray(this.#baseSeed, -rotateAmount); // LEFT
|
|
474
|
+
case SSTFamily.B:
|
|
475
|
+
return YPC27_SST.#rotateArray(this.#baseSeed, rotateAmount); // RIGHT
|
|
476
|
+
case SSTFamily.C:
|
|
477
|
+
return this.#baseSeed; // Singularity — no rotation
|
|
478
|
+
default:
|
|
479
|
+
return this.#baseSeed;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Rotate an array by n positions.
|
|
485
|
+
* Positive n = right rotation, negative n = left rotation.
|
|
486
|
+
* @param {number[]} arr
|
|
487
|
+
* @param {number} n
|
|
488
|
+
* @returns {number[]}
|
|
489
|
+
*/
|
|
490
|
+
static #rotateArray(arr, n) {
|
|
491
|
+
const len = arr.length;
|
|
492
|
+
const shift = ((n % len) + len) % len; // Normalize to [0, len)
|
|
493
|
+
if (shift === 0) return arr;
|
|
494
|
+
return [...arr.slice(len - shift), ...arr.slice(0, len - shift)];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Update checksum with data using SST-rotated seeds.
|
|
499
|
+
*
|
|
500
|
+
* Each chunk of 27 trits gets multiplied by a seed that has been
|
|
501
|
+
* rotated according to the current Fibonacci cycle position.
|
|
502
|
+
* The cycle advances per chunk, creating a 216-chunk hypercycle.
|
|
503
|
+
*
|
|
504
|
+
* @param {Uint8Array | string} data
|
|
505
|
+
*/
|
|
506
|
+
update(data) {
|
|
507
|
+
const bytes = typeof data === 'string'
|
|
508
|
+
? new TextEncoder().encode(data)
|
|
509
|
+
: data;
|
|
510
|
+
|
|
511
|
+
const trits = bytesToTrits(bytes);
|
|
512
|
+
const numChunks = Math.ceil(trits.length / N);
|
|
513
|
+
|
|
514
|
+
for (let k = 0; k < numChunks; k++) {
|
|
515
|
+
// Extract chunk
|
|
516
|
+
const chunkCoeffs = new Int8Array(N);
|
|
517
|
+
for (let i = 0; i < N; i++) {
|
|
518
|
+
const idx = k * N + i;
|
|
519
|
+
chunkCoeffs[i] = idx < trits.length ? trits[idx] : 0;
|
|
520
|
+
}
|
|
521
|
+
const chunk = new Poly27(chunkCoeffs);
|
|
522
|
+
|
|
523
|
+
// Get the SST-rotated seed for this chunk's cycle position
|
|
524
|
+
const rotatedSeed = new Poly27(this.#getRotatedSeed());
|
|
525
|
+
|
|
526
|
+
// State = (State + Chunk) * RotatedSeed
|
|
527
|
+
// Access parent state via digest/reset pattern
|
|
528
|
+
this._updateStateWith(chunk, rotatedSeed);
|
|
529
|
+
|
|
530
|
+
// Advance the cycle
|
|
531
|
+
this.#cyclePosition = (this.#cyclePosition + 1) % 24;
|
|
532
|
+
this.#chunksProcessed++;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Internal: update state with chunk and rotated seed.
|
|
538
|
+
* This replaces the parent's update logic for SST mode.
|
|
539
|
+
* @param {Poly27} chunk
|
|
540
|
+
* @param {Poly27} rotatedSeed
|
|
541
|
+
*/
|
|
542
|
+
_updateStateWith(chunk, rotatedSeed) {
|
|
543
|
+
// We need direct access to parent state — use the internal pattern
|
|
544
|
+
const currentState = this.digest();
|
|
545
|
+
const newState = currentState.add(chunk).multiply(rotatedSeed);
|
|
546
|
+
this._setState(newState);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Get current cycle position (0-23).
|
|
551
|
+
* @returns {number}
|
|
552
|
+
*/
|
|
553
|
+
get cyclePosition() {
|
|
554
|
+
return this.#cyclePosition;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Get hypercycle position (0-215).
|
|
559
|
+
* LCM(27, 24) = 216 — the full rotation repeats here.
|
|
560
|
+
* @returns {number}
|
|
561
|
+
*/
|
|
562
|
+
get hypercyclePosition() {
|
|
563
|
+
return this.#chunksProcessed % 216;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Get total chunks processed.
|
|
568
|
+
* @returns {number}
|
|
569
|
+
*/
|
|
570
|
+
get chunksProcessed() {
|
|
571
|
+
return this.#chunksProcessed;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Reset state for reuse.
|
|
576
|
+
*/
|
|
577
|
+
reset() {
|
|
578
|
+
super.reset();
|
|
579
|
+
this.#cyclePosition = 0;
|
|
580
|
+
this.#chunksProcessed = 0;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Compute SST-enhanced checksum in one call.
|
|
585
|
+
* @param {Uint8Array | string} data
|
|
586
|
+
* @param {Poly27 | number[]} [seed]
|
|
587
|
+
* @returns {Poly27}
|
|
588
|
+
*/
|
|
589
|
+
static compute(data, seed = DEFAULT_SEED) {
|
|
590
|
+
const hasher = new YPC27_SST(seed);
|
|
591
|
+
hasher.update(data);
|
|
592
|
+
return hasher.digest();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Verify data against an SST-computed checksum.
|
|
597
|
+
* @param {Uint8Array | string} data
|
|
598
|
+
* @param {Poly27} expected
|
|
599
|
+
* @param {Poly27 | number[]} [seed]
|
|
600
|
+
* @returns {boolean}
|
|
601
|
+
*/
|
|
602
|
+
static verify(data, expected, seed = DEFAULT_SEED) {
|
|
603
|
+
const computed = YPC27_SST.compute(data, seed);
|
|
604
|
+
return computed.equals(expected);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
397
608
|
// =============================================================================
|
|
398
609
|
// CONVENIENCE EXPORTS
|
|
399
610
|
// =============================================================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yakmesh",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "YAKMESH: Yielding Atomic Kernel Modular Encryption Secured Hub - Post-quantum secure P2P mesh network for the 2026 threat landscape",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "server/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"./cli": "./cli/index.js",
|
|
11
11
|
"./oracle": "./oracle/index.js",
|
|
12
12
|
"./oracle/time-source": "./oracle/time-source.js",
|
|
13
|
+
"./oracle/ma902-snmp": "./oracle/ma902-snmp.js",
|
|
13
14
|
"./oracle/phase-epoch": "./oracle/phase-epoch.js",
|
|
14
15
|
"./oracle/consensus": "./oracle/consensus-engine.js",
|
|
15
16
|
"./oracle/validation": "./oracle/validation-oracle-hardened.js",
|
|
@@ -35,6 +36,12 @@
|
|
|
35
36
|
"./security/khata-trust-integration": "./security/khata-trust-integration.js",
|
|
36
37
|
"./security/geo-proof": "./security/geo-proof.js",
|
|
37
38
|
"./security/strike-system": "./security/strike-system.js",
|
|
39
|
+
"./security/sangha": "./security/sangha.js",
|
|
40
|
+
"./security/fs-hardening": "./security/fs-hardening.js",
|
|
41
|
+
"./security/memory-safety": "./security/memory-safety.js",
|
|
42
|
+
"./security/temporal-signing": "./security/temporal-signing.js",
|
|
43
|
+
"./security/karma-rate-limiter": "./security/karma-rate-limiter.js",
|
|
44
|
+
"./security/secure-config": "./security/secure-config.js",
|
|
38
45
|
"./identity/node-key": "./identity/node-key.js",
|
|
39
46
|
"./mesh/network": "./mesh/network.js",
|
|
40
47
|
"./mesh/rate-limiter": "./mesh/rate-limiter.js",
|
|
@@ -48,6 +55,7 @@
|
|
|
48
55
|
"./mesh/sherpa-discovery": "./mesh/sherpa-discovery.js",
|
|
49
56
|
"./mesh/annex": "./mesh/annex.js",
|
|
50
57
|
"./mesh/temporal-encoder": "./mesh/temporal-encoder.js",
|
|
58
|
+
"./utils/accel": "./utils/accel.js",
|
|
51
59
|
"./protocol/yak-protocol": "./protocol/yak-protocol.js",
|
|
52
60
|
"./adapters/byond": "./adapters/adapter-byond/index.js",
|
|
53
61
|
"./adapters/byond/topic-client": "./adapters/adapter-byond/topic-client.js",
|
|
@@ -75,7 +83,12 @@
|
|
|
75
83
|
"test:multinode": "node --test tests/multi-node.test.js",
|
|
76
84
|
"test:security": "npx vitest run",
|
|
77
85
|
"test:byond": "node --test adapters/adapter-byond/tests/*.test.js",
|
|
78
|
-
"test:all": "npm run test:oracle && npm run test:protocol && npm run test:multinode && npm run test:byond && npm run test:security"
|
|
86
|
+
"test:all": "npm run test:oracle && npm run test:protocol && npm run test:multinode && npm run test:byond && npm run test:security",
|
|
87
|
+
"audit": "node scripts/security-audit.mjs",
|
|
88
|
+
"audit:fix": "node scripts/security-audit.mjs --fix",
|
|
89
|
+
"audit:sbom": "node scripts/security-audit.mjs --sbom",
|
|
90
|
+
"audit:ci": "node scripts/security-audit.mjs --json",
|
|
91
|
+
"prerelease": "npm run audit && npm run test:all"
|
|
79
92
|
},
|
|
80
93
|
"dependencies": {
|
|
81
94
|
"@noble/hashes": "^2.0.0",
|
|
@@ -85,9 +98,13 @@
|
|
|
85
98
|
"express": "^4.18.2",
|
|
86
99
|
"express-rate-limit": "^8.2.1",
|
|
87
100
|
"node-forge": "^1.3.3",
|
|
101
|
+
"onnxruntime-node": "^1.24.2",
|
|
88
102
|
"sql.js": "^1.10.0",
|
|
89
103
|
"ws": "^8.16.0"
|
|
90
104
|
},
|
|
105
|
+
"optionalDependencies": {
|
|
106
|
+
"net-snmp": "^3.26.1"
|
|
107
|
+
},
|
|
91
108
|
"devDependencies": {
|
|
92
109
|
"nodemon": "^3.0.0",
|
|
93
110
|
"vitest": "^4.0.17"
|
|
@@ -127,4 +144,4 @@
|
|
|
127
144
|
"bugs": {
|
|
128
145
|
"url": "https://github.com/peerquanta/yakmesh/issues"
|
|
129
146
|
}
|
|
130
|
-
}
|
|
147
|
+
}
|
package/protocol/yak-handler.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
* Y:// Protocol Handler Executable
|
|
4
4
|
* This script is invoked by the OS when a y:// URL is clicked.
|
|
5
5
|
*
|
|
6
|
+
* SECURITY: Uses execFile (no shell) to prevent command injection.
|
|
7
|
+
* The URL is validated to only produce http://localhost:PORT/... URLs.
|
|
8
|
+
*
|
|
6
9
|
* Self-contained - no ES module imports for compatibility.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
const {
|
|
12
|
+
const { execFile } = require('child_process');
|
|
10
13
|
const { platform } = require('os');
|
|
11
14
|
|
|
12
15
|
const PORT = 3000;
|
|
@@ -78,25 +81,48 @@ if (!url || !url.match(/^(y|yak):\/\//i)) {
|
|
|
78
81
|
// Convert to HTTP URL
|
|
79
82
|
const httpUrl = yakToHttp(url, PORT);
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
// SECURITY: Validate the generated URL is actually a localhost HTTP URL.
|
|
85
|
+
// This prevents any crafted yak:// URL from generating a malicious target.
|
|
86
|
+
try {
|
|
87
|
+
const parsed = new (require('url').URL)(httpUrl);
|
|
88
|
+
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
|
89
|
+
console.error('Security: Generated URL has invalid protocol:', parsed.protocol);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
if (parsed.hostname !== 'localhost' && parsed.hostname !== '127.0.0.1') {
|
|
93
|
+
console.error('Security: Generated URL points to non-local host:', parsed.hostname);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error('Security: Generated URL is malformed:', e.message);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log(`Y Protocol: ${url}`);
|
|
102
|
+
console.log(` -> ${httpUrl}`);
|
|
83
103
|
|
|
84
|
-
// Open in default browser
|
|
104
|
+
// Open in default browser using execFile (no shell) to prevent injection.
|
|
105
|
+
// Each OS gets its opener binary called directly with the URL as an argument,
|
|
106
|
+
// never concatenated into a shell string.
|
|
85
107
|
const os = platform();
|
|
86
|
-
let
|
|
108
|
+
let opener;
|
|
109
|
+
let args;
|
|
87
110
|
|
|
88
111
|
switch (os) {
|
|
89
112
|
case 'win32':
|
|
90
|
-
|
|
113
|
+
opener = 'cmd.exe';
|
|
114
|
+
args = ['/c', 'start', '', httpUrl];
|
|
91
115
|
break;
|
|
92
116
|
case 'darwin':
|
|
93
|
-
|
|
117
|
+
opener = '/usr/bin/open';
|
|
118
|
+
args = [httpUrl];
|
|
94
119
|
break;
|
|
95
120
|
default:
|
|
96
|
-
|
|
121
|
+
opener = '/usr/bin/xdg-open';
|
|
122
|
+
args = [httpUrl];
|
|
97
123
|
}
|
|
98
124
|
|
|
99
|
-
|
|
125
|
+
execFile(opener, args, (error) => {
|
|
100
126
|
if (error) {
|
|
101
127
|
console.error('Failed to open browser:', error.message);
|
|
102
128
|
process.exit(1);
|
package/protocol/yak-protocol.js
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* Phase 1: Simple builtin routes + content addressing
|
|
8
8
|
*
|
|
9
9
|
* Examples:
|
|
10
|
-
* yak://dashboard
|
|
11
|
-
* yak://site
|
|
12
|
-
* yak://peers
|
|
13
|
-
* yak://content/<hash>
|
|
10
|
+
* yak://dashboard → Node dashboard
|
|
11
|
+
* yak://site → Hosted website
|
|
12
|
+
* yak://peers → Connected peers
|
|
13
|
+
* yak://content/<hash> → Content by hash (immutable)
|
|
14
|
+
* yak://qubit-lattice-prism → Content by iO name (human-readable)
|
|
15
|
+
* yak://qubit-lattice-prism/path → Content with path
|
|
14
16
|
*
|
|
15
17
|
* How it works:
|
|
16
18
|
* 1. Register yak:// protocol with OS (Windows Registry, macOS, Linux)
|
|
@@ -22,7 +24,7 @@
|
|
|
22
24
|
* yakmesh bookmark add alice <target>
|
|
23
25
|
*
|
|
24
26
|
* @module protocol/yak-protocol
|
|
25
|
-
* @version 2.
|
|
27
|
+
* @version 2.3.0
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
30
|
import { existsSync, writeFileSync, mkdirSync, readFileSync } from 'fs';
|
|
@@ -31,8 +33,12 @@ import { execSync, spawn } from 'child_process';
|
|
|
31
33
|
import { platform } from 'os';
|
|
32
34
|
import { fileURLToPath } from 'url';
|
|
33
35
|
|
|
36
|
+
// Import iO name validation
|
|
37
|
+
import { isValidIoName } from '../oracle/network-identity.js';
|
|
38
|
+
|
|
34
39
|
const __filename = fileURLToPath(import.meta.url);
|
|
35
40
|
const __dirname = dirname(__filename);
|
|
41
|
+
const peerTag = (id) => id?.split('-pq-').pop() || id?.slice?.(-8) || String(id);
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Default node port
|
|
@@ -349,7 +355,7 @@ export class RemoteBookmarkSync {
|
|
|
349
355
|
});
|
|
350
356
|
|
|
351
357
|
this._save();
|
|
352
|
-
console.log(`📥 Received bookmarks from ${fromNodeId
|
|
358
|
+
console.log(`📥 Received bookmarks from ${peerTag(fromNodeId)} (${Object.keys(msg.bookmarks).length} items)`);
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
/**
|
|
@@ -404,7 +410,7 @@ export class RemoteBookmarkSync {
|
|
|
404
410
|
|
|
405
411
|
this.subscriptions.add(nodeId);
|
|
406
412
|
this._save();
|
|
407
|
-
console.log(`📬 Subscribed to bookmarks from ${nodeId
|
|
413
|
+
console.log(`📬 Subscribed to bookmarks from ${peerTag(nodeId)}`);
|
|
408
414
|
return true;
|
|
409
415
|
}
|
|
410
416
|
|
|
@@ -417,7 +423,7 @@ export class RemoteBookmarkSync {
|
|
|
417
423
|
if (this.subscriptions.delete(nodeId)) {
|
|
418
424
|
this.remoteBookmarks.delete(nodeId);
|
|
419
425
|
this._save();
|
|
420
|
-
console.log(`📭 Unsubscribed from ${nodeId
|
|
426
|
+
console.log(`📭 Unsubscribed from ${peerTag(nodeId)}`);
|
|
421
427
|
return true;
|
|
422
428
|
}
|
|
423
429
|
return false;
|
|
@@ -582,13 +588,22 @@ export function parseYakUrl(url) {
|
|
|
582
588
|
};
|
|
583
589
|
}
|
|
584
590
|
|
|
591
|
+
// Check for iO name (3-word quantum wordlist pattern like "qubit-lattice-prism")
|
|
592
|
+
if (isValidIoName(host)) {
|
|
593
|
+
return {
|
|
594
|
+
type: 'io-content',
|
|
595
|
+
ioName: host,
|
|
596
|
+
path: `/content/${host}${subpath}`, // Content API resolves iO names to hashes
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
585
600
|
// Check for "content/" prefix explicitly
|
|
586
601
|
if (host === 'content' && parts.length > 1) {
|
|
587
|
-
const
|
|
602
|
+
const hashOrName = parts[1];
|
|
588
603
|
return {
|
|
589
604
|
type: 'content',
|
|
590
|
-
hash: hash
|
|
591
|
-
path: `/content/${
|
|
605
|
+
hash: hashOrName, // Could be hash or iO name - API resolves both
|
|
606
|
+
path: `/content/${hashOrName}`,
|
|
592
607
|
};
|
|
593
608
|
}
|
|
594
609
|
|
|
@@ -1186,7 +1201,7 @@ export function createProtocolEndpoints(app, handler) {
|
|
|
1186
1201
|
target: bm.target,
|
|
1187
1202
|
yakUrl: `yak://${bm.name}`,
|
|
1188
1203
|
httpUrl: `http://localhost:${handler.port}${bm.target}`,
|
|
1189
|
-
fromNode: bm.nodeId
|
|
1204
|
+
fromNode: peerTag(bm.nodeId),
|
|
1190
1205
|
listName: bm.listName,
|
|
1191
1206
|
publishedAt: bm.publishedAt,
|
|
1192
1207
|
})),
|
|
@@ -1207,7 +1222,7 @@ export function createProtocolEndpoints(app, handler) {
|
|
|
1207
1222
|
target: bm.target,
|
|
1208
1223
|
yakUrl: `yak://${req.params.name.toLowerCase()}`,
|
|
1209
1224
|
httpUrl: `http://localhost:${handler.port}${bm.target}`,
|
|
1210
|
-
fromNode: bm.nodeId
|
|
1225
|
+
fromNode: peerTag(bm.nodeId),
|
|
1211
1226
|
listName: bm.listName,
|
|
1212
1227
|
publishedAt: bm.publishedAt,
|
|
1213
1228
|
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#include <iostream>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <bitset>
|
|
5
|
+
#include <future> // For async parallel processing on Ryzen
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// YAKMESH CONCEPT: Distributed McEliece Shard ("Elder Node" Logic)
|
|
9
|
+
// Context: Post-Quantum Identity Verification via FHE
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
namespace yakmesh {
|
|
13
|
+
|
|
14
|
+
// ------------------------------------------------------------------------
|
|
15
|
+
// MOCK FHE LIBRARY (Concept Wrappers)
|
|
16
|
+
// In production, replace with TFHE, SEAL, or OpenFHE bindings.
|
|
17
|
+
// ------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
struct FHE_Ciphertext {
|
|
20
|
+
// Represents an encrypted bit (LWE sample)
|
|
21
|
+
std::vector<uint64_t> data;
|
|
22
|
+
|
|
23
|
+
// Homomorphic Addition: Enc(A) + Enc(B) = Enc(A+B)
|
|
24
|
+
FHE_Ciphertext operator+(const FHE_Ciphertext& other) const {
|
|
25
|
+
FHE_Ciphertext res = *this;
|
|
26
|
+
// Mock logic: combine vectors
|
|
27
|
+
// In reality: res.data[i] = (this->data[i] + other.data[i]) % modulus
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// ------------------------------------------------------------------------
|
|
33
|
+
// THE DISTRIBUTED SHARD CLASS
|
|
34
|
+
// ------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
class McElieceShard {
|
|
37
|
+
private:
|
|
38
|
+
uint32_t shard_id;
|
|
39
|
+
uint32_t num_cols; // The 'n' in McEliece (length of code)
|
|
40
|
+
uint32_t num_rows; // The number of rows THIS node manages
|
|
41
|
+
|
|
42
|
+
// STORAGE:
|
|
43
|
+
// We store the binary matrix rows as packed bits for cache efficiency.
|
|
44
|
+
// Each inner vector represents one row of the matrix H.
|
|
45
|
+
// Using uint64_t chunks allows for AVX-512 optimization later.
|
|
46
|
+
std::vector<std::vector<uint64_t>> matrix_rows;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
McElieceShard(uint32_t id, uint32_t cols)
|
|
50
|
+
: shard_id(id), num_cols(cols), num_rows(0) {}
|
|
51
|
+
|
|
52
|
+
// Load a row of the Parity Check Matrix H into this shard.
|
|
53
|
+
// In Yakmesh, this happens during the "Elder Election" phase.
|
|
54
|
+
void add_row(const std::vector<uint8_t>& binary_row) {
|
|
55
|
+
if (binary_row.size() != num_cols) {
|
|
56
|
+
throw std::invalid_argument("Row length mismatch");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
std::vector<uint64_t> packed_row;
|
|
60
|
+
uint64_t current_chunk = 0;
|
|
61
|
+
for (size_t i = 0; i < binary_row.size(); ++i) {
|
|
62
|
+
if (binary_row[i]) {
|
|
63
|
+
current_chunk |= (1ULL << (i % 64));
|
|
64
|
+
}
|
|
65
|
+
// Push chunk when full or at end
|
|
66
|
+
if ((i + 1) % 64 == 0 || i == binary_row.size() - 1) {
|
|
67
|
+
packed_row.push_back(current_chunk);
|
|
68
|
+
current_chunk = 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
matrix_rows.push_back(packed_row);
|
|
72
|
+
num_rows++;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// --------------------------------------------------------------------
|
|
76
|
+
// CORE FUNCTION: Blind Syndrome Computation
|
|
77
|
+
// Input: An encrypted vector 'c' (The Identity Claim)
|
|
78
|
+
// Output: Encrypted Partial Syndrome bits (S_part)
|
|
79
|
+
// --------------------------------------------------------------------
|
|
80
|
+
std::vector<FHE_Ciphertext> compute_blind_syndrome(
|
|
81
|
+
const std::vector<FHE_Ciphertext>& encrypted_vector
|
|
82
|
+
) {
|
|
83
|
+
if (encrypted_vector.size() != num_cols) {
|
|
84
|
+
throw std::invalid_argument("Input vector dimension mismatch");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
std::vector<FHE_Ciphertext> partial_syndrome;
|
|
88
|
+
partial_syndrome.resize(num_rows);
|
|
89
|
+
|
|
90
|
+
// Parallelize processing of rows using std::async (Ryzen optimization)
|
|
91
|
+
// Each row calculation is independent.
|
|
92
|
+
// In a real implementation, we would use a thread pool.
|
|
93
|
+
|
|
94
|
+
for (size_t r = 0; r < num_rows; ++r) {
|
|
95
|
+
// S[r] = DotProduct(Row[r], EncryptedVector)
|
|
96
|
+
// Since Row[r] is binary, we simply SUM the EncryptedVector elements
|
|
97
|
+
// where the Row bit is 1.
|
|
98
|
+
|
|
99
|
+
// Initialize accumulator (Encryption of 0)
|
|
100
|
+
FHE_Ciphertext accumulator;
|
|
101
|
+
|
|
102
|
+
const auto& row_bits = matrix_rows[r];
|
|
103
|
+
|
|
104
|
+
for (size_t col = 0; col < num_cols; ++col) {
|
|
105
|
+
// Check bit in packed row
|
|
106
|
+
bool bit_is_set = (row_bits[col / 64] >> (col % 64)) & 1;
|
|
107
|
+
|
|
108
|
+
if (bit_is_set) {
|
|
109
|
+
// Homomorphic Addition: Accumulator += EncryptedVector[col]
|
|
110
|
+
// No decryption happens here!
|
|
111
|
+
if (col == 0) accumulator = encrypted_vector[col]; // simplified init
|
|
112
|
+
else accumulator = accumulator + encrypted_vector[col];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
partial_syndrome[r] = accumulator;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return partial_syndrome;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void print_stats() const {
|
|
122
|
+
std::cout << "[Shard " << shard_id << "] Managing "
|
|
123
|
+
<< num_rows << " rows x " << num_cols << " cols." << std::endl;
|
|
124
|
+
std::cout << "Memory Footprint: "
|
|
125
|
+
<< (matrix_rows.size() * matrix_rows[0].size() * 8) / 1024
|
|
126
|
+
<< " KB" << std::endl;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
// EXAMPLE USAGE
|
|
133
|
+
// ----------------------------------------------------------------------------
|
|
134
|
+
int main() {
|
|
135
|
+
using namespace yakmesh;
|
|
136
|
+
|
|
137
|
+
// 1. Initialize Shard (e.g., managing 128 rows of a 4096-bit code)
|
|
138
|
+
McElieceShard elder_node(1, 1024); // n=1024 for demo
|
|
139
|
+
|
|
140
|
+
// 2. Load Dummy Matrix Data (The "Shard")
|
|
141
|
+
// In reality, this comes from the Distributed Key Gen protocol.
|
|
142
|
+
for(int i=0; i<5; ++i) {
|
|
143
|
+
std::vector<uint8_t> row(1024, 0);
|
|
144
|
+
// Create a pattern
|
|
145
|
+
for(int j=0; j<1024; ++j) if((j+i)%7 == 0) row[j] = 1;
|
|
146
|
+
elder_node.add_row(row);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
elder_node.print_stats();
|
|
150
|
+
|
|
151
|
+
// 3. Receive Encrypted Identity (Dummy Data)
|
|
152
|
+
std::cout << "Receiving FHE-Encrypted Identity Vector..." << std::endl;
|
|
153
|
+
std::vector<FHE_Ciphertext> encrypted_identity(1024);
|
|
154
|
+
|
|
155
|
+
// 4. Compute Blind Syndrome
|
|
156
|
+
// This runs entirely on the Elder Node without ever decrypting the input.
|
|
157
|
+
std::cout << "Computing Blind Syndrome (Homomorphic Dot Product)..." << std::endl;
|
|
158
|
+
auto result_enc = elder_node.compute_blind_syndrome(encrypted_identity);
|
|
159
|
+
|
|
160
|
+
std::cout << "Computation Complete. Generated " << result_enc.size()
|
|
161
|
+
<< " encrypted syndrome bits." << std::endl;
|
|
162
|
+
|
|
163
|
+
// 5. Next Step:
|
|
164
|
+
// The Elder Node broadcasts 'result_enc' to the network.
|
|
165
|
+
// Other nodes aggregate these partial syndromes to check validity.
|
|
166
|
+
|
|
167
|
+
return 0;
|
|
168
|
+
}
|