|
6 | 6 |
|
7 | 7 | .globl sample_s |
8 | 8 | .globl compute_t |
| 9 | +.globl encode_t |
9 | 10 |
|
10 | 11 | .text |
11 | 12 |
|
@@ -261,3 +262,58 @@ compute_t: |
261 | 262 | /* End of loop */ |
262 | 263 |
|
263 | 264 | ret |
| 265 | + |
| 266 | +/** |
| 267 | + * Round and encode T. |
| 268 | + * |
| 269 | + * This routine unmasks the arithmetically shared vector T, rounds it to T0 and |
| 270 | + * T1 vectors which are then encoded on-the-fly. |
| 271 | + * |
| 272 | + * Two polynomial slots are required for the storage of intermediate results. |
| 273 | + * |
| 274 | + * @param[in] x2: DMEM address of the first arithmetic share of T (8192 bytes). |
| 275 | + * @param[in] x3: DMEM address of the second arithmetic share of T (8192 bytes). |
| 276 | + * @param[in] x4: DMEM address of the encoded T0 vector (3328 bytes). |
| 277 | + * @param[in] x5: DMEM address of the encoded T1 vector (2560 bytes). |
| 278 | + * @param[in] x6: DMEM address of polynomial slot 0 (1024 bytes). |
| 279 | + * @param[in] x7: DMEM address of polynomial slot 1 (1024 bytes). |
| 280 | + */ |
| 281 | +encode_t: |
| 282 | + /* Prepare DMEM address registers. */ |
| 283 | + addi x8, x2, 0 /* T (share 0) */ |
| 284 | + addi x9, x3, 0 /* T (share 1) */ |
| 285 | + addi x10, x4, 0 /* T0_enc */ |
| 286 | + addi x11, x5, 0 /* T1_enc */ |
| 287 | + |
| 288 | + /* Unmask, round and encode each T polynomial. */ |
| 289 | + loopi 8, 18 |
| 290 | + /* Securely unmask T into slot 0. */ |
| 291 | + addi x2, x8, 0 |
| 292 | + addi x3, x9, 0 |
| 293 | + addi x4, x6, 0 |
| 294 | + jal x1, sec_unmask |
| 295 | + |
| 296 | + /* Split T into T0 and T1 in slots 0 and 1. */ |
| 297 | + addi x2, x6, 0 |
| 298 | + addi x3, x6, 0 |
| 299 | + addi x4, x7, 0 |
| 300 | + jal x1, power2round |
| 301 | + |
| 302 | + /* Encode T0 into the output location. */ |
| 303 | + addi x2, x6, 0 |
| 304 | + addi x3, x10, 0 |
| 305 | + jal x1, encode_t0 |
| 306 | + |
| 307 | + /* Encode T1 into the output location. */ |
| 308 | + addi x2, x7, 0 |
| 309 | + addi x3, x11, 0 |
| 310 | + jal x1, encode_t1 |
| 311 | + |
| 312 | + /* Advance T and output pointers.*/ |
| 313 | + addi x8, x8, 1024 |
| 314 | + addi x9, x9, 1024 |
| 315 | + addi x10, x10, 416 |
| 316 | + addi x11, x11, 320 |
| 317 | + /* End of loop */ |
| 318 | + |
| 319 | + ret |
0 commit comments