feat(enc): Encaps E6 - v = INTT(sum t_hat o y_hat) + e2 + mu
Storage choreography (per plan risk notes): - TDEC now decodes t_hat[j] into bank_a slot j*K (was bank_t). This makes V's MAC reuse E4's u_aslot=u_j*K+u_row addressing with u_row=0, no mux change. bank_t has no room for K=4 (t_hat would fill all 4 slots vs psum's UPSUM slot), hence bank_a (16 slots, A_hat dead after E4). - New ST_ENC_E2MV state relocates e2 (bank_t[0]) -> bank_a[1] so V-ADD reads psum (bank_t) and e2 (bank_a) from different banks (no port conflict). bank_se (y_hat + u) stays intact -> verify_e2/e3/e4 unaffected. - V reuses the u_* MAC/INTT/ADD machine with u_row tied to 0 (u_row_max=1). ADD computes psum + e2 + mu mod Q -> bank_t[UPSUM] in place; mu[w] = m_r[w] ? 1665 : 0 (Decompress_1). FSM: C1->TDEC->E2MV->V->DONE. Bug found+fixed during bring-up: e2 relocation was off-by-one (wrote e2[i+1] into slot i) because em_we/em_widx were registered an extra cycle past the bram read. Fixed: em_widx==em_ridx, write scheduled for the cycle bt_rd_data presents e2[em_ridx]. TB: verify_e6 compares v (bank_t dbg slot 9, K=2) to ml-kem-r golden. verify_e1 dropped (TDEC overwrites bank_a A_hat slots; A_hat transitively verified by E4). Verified: K=2 E2/E3/E4/E6 == golden, E5 c1 == KAT prefix; K=3/4 E0+E5 pass; KeyGen K=2 unregressed.
This commit is contained in:
@@ -72,7 +72,7 @@ ct_bytes_rt = c1_bytes_rt + c2_bytes_rt; // 768 / 1088 / 1568
|
||||
- **E3 — ŷ = NTT(y)**:ST_ENC_N,mode=0,就地。dbg 对 y_hat。
|
||||
- **E4 — u = INTT(Σ Â[j][i]∘ŷ[j]) + e1**:ST_ENC_U,poly_mul + 累加 + INTT(mode=1) + 加 e1。**转置寻址 slot=j·K+i**。dbg 对 u。
|
||||
- **E5 — Compress_du + byteEncode_du → c1** ✅:comp_decomp(mode0,d=du) + 通用 LSB-first 打包器(ST_ENC_C1)写 ct_bram c1 区。dbg_ct tap 比 ct[0..c1_bytes]==KAT.ct 前缀,K=2/3/4 全过(含 K=4 du=11 跨字节)。runner = `./run_enc.sh K CASE`。
|
||||
- **E6 — v = INTT(Σ t̂[j]∘ŷ[j]) + e2 + mu**:ST_ENC_V,mu 流内由 m bit 生成。dbg 对 v。
|
||||
- **E6 — v = INTT(Σ t̂[j]∘ŷ[j]) + e2 + mu** ✅:ST_ENC_C1→ST_ENC_TDEC(t̂ 解码进 **bank_a** slot j·K)→ST_ENC_E2MV(e2 从 bank_t[0] 搬到 **bank_a[1]**)→ST_ENC_V(复用 u_* MAC/INTT/ADD,u_row≡0)。mu[w]=m_r[w]?1665:0。v 落 bank_t[UPSUM],dbg slot 9(K=2)。dbg 对 v==ml-kem-r golden 全过。**踩坑:e2 搬迁曾 off-by-one(写 e2[i+1] 到 slot i),已修(em_widx==em_ridx,写延后 1 拍对齐 bram 读)。** verify_e1 已废弃(TDEC 覆盖 bank_a 的 A_hat;A_hat 由 E4 转置 MAC 间接验证)。
|
||||
- **E7 — Compress_dv + byteEncode_dv → c2 + 端到端 KAT**:写 ct c2 区。干净 TB 喂 ek/m,比 ct(全长)==KAT.ct 且 ss==KAT.ss,K=2/3/4 各 count=0..N。
|
||||
|
||||
## 验证
|
||||
|
||||
Reference in New Issue
Block a user