Spare some memory
diff --git a/library/ecp.c b/library/ecp.c
index 2ff8820..d7a4567 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -1353,6 +1353,14 @@
ecp_normalize_many( grp, TT, k );
+ /*
+ * Post-precessing: reclaim some memory by not storing Z (always 1)
+ */
+ for( i = 0; i < ( 1U << (w-1) ); i++ )
+ {
+ mpi_free( &T[i].Z );
+ }
+
cleanup:
return( ret );
}
@@ -1368,6 +1376,9 @@
/* Ignore the "sign" bit */
MPI_CHK( ecp_copy( R, &T[ ( i & 0x7Fu ) >> 1 ] ) );
+ /* Restore the Z coordinate */
+ MPI_CHK( mpi_lset( &R->Z, 1 ) );
+
/*
* -R = (R.X, -R.Y, R.Z), and
* -R.Y mod P = P - R.Y unless R.Y == 0