@@ -112,42 +112,40 @@ static void secp256k1_ge_set_table_gej_var(size_t len, secp256k1_ge_t *r, const
112112 size_t i = len - 1 ;
113113 secp256k1_fe_t zi ;
114114
115- if (len < 1 )
116- return ;
117-
118- /* Compute the inverse of the last z coordinate, and use it to compute the last affine output. */
119- secp256k1_fe_inv (& zi , & a [i ].z );
120- secp256k1_ge_set_gej_zinv (& r [i ], & a [i ], & zi );
121-
122- /* Work out way backwards, using the z-ratios to scale the x/y values. */
123- while (i > 0 ) {
124- secp256k1_fe_mul (& zi , & zi , & zr [i ]);
125- i -- ;
115+ if (len > 0 ) {
116+ /* Compute the inverse of the last z coordinate, and use it to compute the last affine output. */
117+ secp256k1_fe_inv (& zi , & a [i ].z );
126118 secp256k1_ge_set_gej_zinv (& r [i ], & a [i ], & zi );
119+
120+ /* Work out way backwards, using the z-ratios to scale the x/y values. */
121+ while (i > 0 ) {
122+ secp256k1_fe_mul (& zi , & zi , & zr [i ]);
123+ i -- ;
124+ secp256k1_ge_set_gej_zinv (& r [i ], & a [i ], & zi );
125+ }
127126 }
128127}
129128
130129static void secp256k1_ge_globalz_set_table_gej (size_t len , secp256k1_ge_t * r , secp256k1_fe_t * globalz , const secp256k1_gej_t * a , const secp256k1_fe_t * zr ) {
131130 size_t i = len - 1 ;
132131 secp256k1_fe_t zs ;
133132
134- if (len < 1 )
135- return ;
136-
137- /* The z of the final point gives us the "global Z" for the table. */
138- r [i ].x = a [i ].x ;
139- r [i ].y = a [i ].y ;
140- * globalz = a [i ].z ;
141- r [i ].infinity = 0 ;
142- zs = zr [i ];
143-
144- /* Work our way backwards, using the z-ratios to scale the x/y values. */
145- while (i > 0 ) {
146- if (i != len - 1 ) {
147- secp256k1_fe_mul (& zs , & zs , & zr [i ]);
133+ if (len > 0 ) {
134+ /* The z of the final point gives us the "global Z" for the table. */
135+ r [i ].x = a [i ].x ;
136+ r [i ].y = a [i ].y ;
137+ * globalz = a [i ].z ;
138+ r [i ].infinity = 0 ;
139+ zs = zr [i ];
140+
141+ /* Work our way backwards, using the z-ratios to scale the x/y values. */
142+ while (i > 0 ) {
143+ if (i != len - 1 ) {
144+ secp256k1_fe_mul (& zs , & zs , & zr [i ]);
145+ }
146+ i -- ;
147+ secp256k1_ge_set_gej_zinv (& r [i ], & a [i ], & zs );
148148 }
149- i -- ;
150- secp256k1_ge_set_gej_zinv (& r [i ], & a [i ], & zs );
151149 }
152150}
153151
0 commit comments