|
1 | 1 | pub(crate) const MSM_ASSEMBLY: &str = " |
2 | 2 | ; We are passed three pointers and one usize. |
3 | | - ; d0 points to the points. Points are represented by (x: Field, y: Field, is_infinite: bool) |
| 3 | + ; d0 points to the points. Points are represented by (x: Field, y: Field). |
4 | 4 | ; d1 points to the scalars. Scalars are represented by (lo: Field, hi: Field) both range checked to 128 bits. |
5 | 5 | ; d2 contains the number of points. |
6 | 6 | ; d3 points to the result. The result is a point. |
7 | 7 | ADD d3, /*the reserved register 'one_usize'*/ $2, d4; Compute the pointer to the result y. |
8 | | - ADD d4, $2, d5; Compute the pointer to the result is_infinite |
9 | 8 | ; Initialize the msm result: point at infinity |
10 | 9 | SET i3, 0 ff |
11 | 10 | SET i4, 0 ff |
12 | | - SET i5, 1 u1 |
13 | 11 | ; Loop globals |
14 | 12 | SET d6, 0 u32; Initialize the outer loop variable, ranging from 0 to the number of points |
15 | 13 | SET d8, 0 ff; Initialize a 0 FF |
@@ -51,35 +49,32 @@ FIND_MSB_BODY: JUMPI i19, FIND_MSB_END; Check if the current bit is one |
51 | 49 | JUMP FIND_MSB_BODY |
52 | 50 | ; Now we have the pointer of the MSB in d19 |
53 | 51 |
|
54 | | - ; Now store the result of the scalar multiplication in d22, d23, d24 |
| 52 | + ; Now store the result of the scalar multiplication in d22, d23 |
55 | 53 | FIND_MSB_END: MOV i16, d22; x |
56 | 54 | ADD d16, $2, d25; pointer to y |
57 | 55 | MOV i25, d23; y |
58 | | - ADD d25, $2, d25; pointer to is_infinite |
59 | | - MOV i25, d24; is_infinite |
60 | | - ; Also store the original point in d25, d26, d27 |
| 56 | + ; Also store the original point in d25, d26 |
61 | 57 | MOV d22, d25; x |
62 | 58 | MOV d23, d26; y |
63 | | - MOV d24, d27; is_infinite |
64 | 59 |
|
65 | 60 | ; Now we need to do the inner loop, that will do double then add |
66 | 61 | ; We need to iterate from the pointer of the MSB + 1 to the end pointer (d21) |
67 | 62 | ADD d19, $2, d19; We start from the pointer of the MSB + 1 |
68 | 63 | INNER_HEAD: LT d19, d21, d28; Check if we are done with the loop |
69 | 64 | JUMPI d28, INNER_BODY |
70 | 65 | JUMP INNER_END |
71 | | -INNER_BODY: ECADD d22, d23, d24, d22, d23, d24, /*not indirect, so the result is stored in d22, d23, d24*/ d22; Double the current result. |
| 66 | +INNER_BODY: ECADD d22, d23, d22, d23, /*not indirect, so the result is stored in d22, d23*/ d22; Double the current result. |
72 | 67 | EQ i19, d12, d28; Check if the current bit is zero |
73 | 68 | JUMPI d28, INNER_INC; If the current bit is zero, continue |
74 | | - ECADD d25, d26, d27, d22, d23, d24, /*not indirect, so the result is stored in d22, d23, d24*/ d22; Add the original point to the result |
| 69 | + ECADD d25, d26, d22, d23, /*not indirect, so the result is stored in d22, d23*/ d22; Add the original point to the result |
75 | 70 | INNER_INC: ADD d19, $2, d19; Increment the pointer |
76 | 71 | JUMP INNER_HEAD |
77 | 72 |
|
78 | 73 | ; After the inner loop we have computed the scalar multiplication. Add it to the msm result |
79 | | -INNER_END: ECADD i3, i4, i5, d22, d23, d24, i3; Add the result to the msm result |
| 74 | +INNER_END: ECADD i3, i4, d22, d23, i3; Add the result to the msm result |
80 | 75 | OUTER_INC: ADD d6, $2, d6; Increment the outer loop variable |
81 | 76 | JUMP OUTER_HEAD |
82 | | - ; After the outer loop we have computed the msm. We can return since we wrote the result in i3, i4, i5 |
| 77 | + ; After the outer loop we have computed the msm. We can return since we wrote the result in i3, i4 |
83 | 78 | OUTER_END: INTERNALRETURN |
84 | 79 | "; |
85 | 80 |
|
|
0 commit comments