interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / evidence / QUANTUM_EFFICIENCY / 2026-10-22 / additional-pinned-source.txt

188 lines · 7886 bytes Raw Blame History
1PINNED aienos-repo 18e276590424593647cd7c39c6d16c2f9f8d6027 native/store/store_engine.c RC 0
265:
366:/* read_application_object, streamed one unit at a time through ws->unit.
467: * Like Rust, every unit is read first in order (a read failure is RE_IO
568: * whatever the bytes are), and only then is the extent judged. If out is
669: * set the semantic bytes are copied there (caller checked the size). If cmp
770: * is set, *differs reports whether the semantic bytes differ from cmp. */
871:static int read_app_object(const st_dev *d, st_workspace *ws, const sv1_entry *e, uint8_t *out,
972: const uint8_t *cmp, int *differs)
1073:{
1174: sha256_ctx ctx;
1275: int graph = 0;
1376: uint32_t units;
1477: if (sv1_unit_count(e->byte_length, &units) || units != e->unit_count)
1578: graph = 1;
1679: if (!graph && sv1_object_id_begin(&ctx, e->kind, e->version, e->byte_length))
1780: graph = 1;
1881: if (differs)
1982: *differs = 0;
2083: for (uint32_t i = 0; i < e->unit_count; i++) {
2184: if (dev_read(d, e->first_unit + i, ws->unit))
2285: return RE_IO;
2386: if (graph)
2487: continue;
2588: uint64_t start = (uint64_t)i * SV1_UNIT;
2689: uint64_t take = e->byte_length > start ? e->byte_length - start : 0;
2790: if (take > SV1_UNIT)
2891: take = SV1_UNIT;
2992: sha256_update(&ctx, ws->unit, (size_t)take);
3093: if (!sv1_all_zero(ws->unit + take, SV1_UNIT - (size_t)take)) graph = 1; /* GUARD:object-padding */
3194: if (out)
3295: sv1_copy(out + start, ws->unit, (size_t)take);
3396: if (cmp && differs && !sv1_equal(cmp + start, ws->unit, (size_t)take))
3497: *differs = 1;
3598: }
3699: if (graph)
37100: return RE_GRAPH;
38101: uint8_t id[32];
39102: sha256_final(&ctx, id);
40103: if (!sv1_equal(id, e->object_id, 32)) return RE_GRAPH; /* GUARD:object-hash */
41104: return RE_OK;
42105:}
43325: return ST_M_CORRUPT_RECOVERY_REQUIRED;
44326: }
45327: return ST_M_CORRUPT_RECOVERY_REQUIRED;
46328:}
47329:
48330:static int write_object(const st_dev *d, st_workspace *ws, uint64_t first, uint32_t units,
49331: const uint8_t *bytes, uint64_t len)
50332:{
51333: for (uint32_t i = 0; i < units; i++) {
52334: uint64_t start = (uint64_t)i * SV1_UNIT;
53335: uint64_t take = len > start ? len - start : 0;
54336: if (take > SV1_UNIT)
55337: take = SV1_UNIT;
56338: sv1_zero(ws->unit, SV1_UNIT);
57339: sv1_copy(ws->unit, bytes + start, (size_t)take);
58340: if (dev_write(d, first + i, ws->unit))
59341: return ST_E_IO;
60342: }
61343: return 0;
62344:}
63345:
64346:typedef struct {
65PINNED aienos-repo 18e276590424593647cd7c39c6d16c2f9f8d6027 native/net/x25519.c RC 0
6640:static void sub(fe o, const fe a, const fe b) { for (int i = 0; i < 16; i++) o[i] = a[i] - b[i]; }
6741:
6842:static void mul(fe o, const fe a, const fe b)
6943:{
7044: int64_t t[31];
7145: for (int i = 0; i < 31; i++) t[i] = 0;
7246: for (int i = 0; i < 16; i++)
7347: for (int j = 0; j < 16; j++) t[i + j] += a[i] * b[j];
7448: for (int i = 0; i < 15; i++) t[i] += 38 * t[i + 16];
7549: for (int i = 0; i < 16; i++) o[i] = t[i];
7650: carry(o);
7751: carry(o);
7852:}
7953:
8054:static void sqr(fe o, const fe a) { mul(o, a, a); }
8155:
8256:/* o = i^(p-2) = 1/i. The exponent is public, so its branches are too. */
8357:static void invert(fe o, const fe in)
8458:{
8559: fe c;
8660: memcpy(c, in, sizeof c);
87PINNED aienos-repo 18e276590424593647cd7c39c6d16c2f9f8d6027 native/sig/ed25519.c RC 0
88540: aienos_sha512_update(&c, pk, 32);
89541: aienos_sha512_update(&c, msg, msg_len);
90542: aienos_sha512_final(&c, kh);
91543: aienos_sig_sc_reduce(ks, kh);
92544:
93545: ge_scalarmult(&sB, &k.B, sig + 32, &k);
94546: ge_scalarmult(&kA, &A, ks, &k);
95547: ge_neg(&kA, &kA);
96548: ge_add(&chk, &sB, &kA, &k); /* [S]B - [k]A, must equal R */
97549: ge_tobytes(enc, &chk);
98550: if (!aienos_sig_ct_equal(enc, sig, 32)) return AIENOS_SIG_ERR_INVALID; /* GUARD:r-check */
99551: return AIENOS_SIG_OK;
100552:}
101PINNED omega a8ffd2b912c84197d08f963b05f9c7d8b30a3f8a src/crumbline/cl_search.c RC 0
10270: size_t npending;
10371: uint32_t pending_since;
10472: uint8_t hyps[MAX_HYP][CL_DIGEST_BYTES];
10573: size_t nhyp;
10674: uint32_t max_queries;
10775: bool stop, solved, first_submit_done;
10876:} S;
10977:
11078:static void emit(S *s, const ClEvent *ev) {
11179: if (s->sink && s->sink->emit) s->sink->emit(s->sink->ctx, ev);
11280:}
11381:
11482:static void hash_vals(const uint64_t *v, uint32_t w, uint64_t *h1, uint64_t *h2) {
11583: uint64_t a = 0x9E3779B97F4A7C15ULL, b = 0xC2B2AE3D27D4EB4FULL;
11684: for (uint32_t i = 0; i < w; ++i) {
11785: a = (a ^ v[i]) * 0x100000001B3ULL;
11886: a ^= a >> 29;
11987: b = (b + v[i]) * 0xFF51AFD7ED558CCDULL;
12088: b ^= b >> 33;
12189: }
12290: *h1 = a;
12391: *h2 = b;
12492:}
12593:
12694:/* true if an equivalent state with cost <= insns already exists */
12795:static bool equiv_seen(S *s, uint64_t h1, uint64_t h2, uint32_t insns) {
128240:
129241: const uint64_t *probes = cl_probe_inputs();
130242: Node *root = &s.nodes[0];
131243: root->id = 0;
132244: root->parent = UINT32_MAX;
133245: root->op = UINT16_MAX;
134246: for (uint32_t k = 0; k < s.n; ++k) s.vals[k] = s.inputs[k];
135247: for (uint32_t k = 0; k < W_PROBES; ++k) s.vals[s.n + k] = probes[k];
136248: uint64_t h1, h2;
137249: hash_vals(s.vals, s.w, &h1, &h2);
138250: equiv_seen(&s, h1, h2, 0);
139251: s.count = 1;
140252:
141253: uint32_t next_id = 1;
142254: size_t level_start = 0, level_end = 1;
143255: int best_matches = -1;
144256: uint32_t best_node = 0, best_parent = 0;
145257: uint16_t best_op = 0;
146258: uint32_t robust_need = cfg.robust_min_pct ? (s.n * cfg.robust_min_pct + 99) / 100 : UINT32_MAX;
147259:
148260: for (uint32_t depth = 1; depth <= cfg.max_depth && !s.stop; ++depth) {
149261: size_t level_kept = 0;
150262: for (size_t pi = level_start; pi < level_end && !s.stop; ++pi) {
151263: res->expansions++;
152264: for (size_t oi = 0; oi < bank->count && !s.stop; ++oi) {
153265: if (res->generated >= cfg.max_candidates) {
154266: s.stop = true;
155267: break;
156268: }
157269: res->generated++;
158270: const Node *parent = &s.nodes[pi];
159271: const ClOp *op = &bank->ops[oi];
160272: ClEvent ev = {CL_EV_EXPAND, CL_PRUNE_NONE, CL_VERIFY_NOT_REACHED, CL_FIT_NONE, (uint16_t)oi,
161273: parent->id, next_id++, 0, 0};
162274: uint32_t nsteps = parent->nsteps + op->steps.n;
163275: uint32_t insns = parent->insns + op_insns(op);
164276: if (nsteps > CL_MAX_STEPS) {
165277: ev.prune = CL_PRUNE_STEP_CAP;
166278: emit(&s, &ev);
167279: continue;
168280: }
169281: if (insns + 1 > cfg.max_program_insns) {
170282: ev.prune = CL_PRUNE_COST;
171283: res->pruned_cost++;
172284: emit(&s, &ev);
173285: continue;
174286: }
175287: const uint64_t *pv = &s.vals[pi * s.w];
176288: for (uint32_t k = 0; k < s.w; ++k) scratch[k] = cl_steps_eval(&op->steps, pv[k]);
177289: ev.exec_cost = s.w;
178290: hash_vals(scratch, s.w, &h1, &h2);
179291: if (equiv_seen(&s, h1, h2, insns)) {
180292: ev.prune = CL_PRUNE_EQUIV;
181293: res->pruned_equiv++;
182294: emit(&s, &ev);
183295: continue;
184296: }
185297: res->evaluated++;
186298: uint32_t mismatch = 0;
187299: for (uint32_t k = 0; k < s.n; ++k)
188300: if ((scratch[k] & s.mask) != crumb->out[k][0]) mismatch++;