/*
* Use is subject to license terms.
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* *********************************************************************
*
* The Original Code is the elliptic curve math library for prime field curves.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stephen Fung <fungstep@hotmail.com>, Sun Microsystems Laboratories
*
*********************************************************************** */
#include "ecp.h"
#include "ecl-priv.h"
#include "mplogic.h"
#ifndef _KERNEL
#include <stdlib.h>
#endif
/* Computes R = 2P. Elliptic curve points P and R can be identical. Uses
* Modified Jacobian coordinates.
*
* Assumes input is already field-encoded using field_enc, and returns
* output that is still field-encoded.
*
*/
{
M = &scratch[2];
S = &scratch[3];
#if MAX_SCRATCH < 4
#error "Scratch array defined too small "
#endif
/* Check for point at infinity */
/* Set r = pt at infinity by setting rz = 0 */
goto CLEANUP;
}
/* M = 3 (px^2) + a*(pz^4) */
/* rz = 2 * py * pz */
/* t0 = 2y^2 , t1 = 8y^4 */
/* S = 4 * px * py^2 = 2 * px * t0 */
/* rx = M^2 - 2S */
/* ry = M * (S - rx) - t1 */
/* ra*z^4 = 2*t1*(apz4) */
return res;
}
/* Computes R = P + Q where R is (rx, ry, rz), P is (px, py, pz) and Q is
* (qx, qy, 1). Elliptic curve points P, Q, and R can all be identical.
* Uses mixed Modified_Jacobian-affine coordinates. Assumes input is
* already field-encoded using field_enc, and returns output that is still
* field-encoded. */
{
A = &scratch[0];
B = &scratch[1];
C = &scratch[2];
D = &scratch[3];
#if MAX_SCRATCH < 6
#error "Scratch array defined too small "
#endif
/* If either P or Q is the point at infinity, then return the other
* point */
goto CLEANUP;
}
goto CLEANUP;
}
/* A = qx * pz^2, B = qy * pz^3 */
/* C = A - px, D = B - py */
/* C2 = C^2, C3 = C^3 */
/* rz = pz * C */
/* C = px * C^2 */
/* A = D^2 */
/* rx = D^2 - (C^3 + 2 * (px * C^2)) */
/* C3 = py * C^3 */
/* ry = D * (px * C^2 - rx) - py * C^3 */
/* raz4 = a * rz^4 */
return res;
}
/* Computes R = nP where R is (rx, ry) and P is the base point. Elliptic
* curve points P and R can be identical. Uses mixed Modified-Jacobian
* co-ordinates for doubling and Chudnovsky Jacobian coordinates for
* additions. Assumes input is already field-encoded using field_enc, and
* returns output that is still field-encoded. Uses 5-bit window NAF
* method (algorithm 11) for scalar-point multiplication from Brown,
* Hankerson, Lopez, Menezes. Software Implementation of the NIST Elliptic
* Curves Over Prime Fields. */
{
int i, orderBitSize;
for (i = 0; i < 16; i++) {
}
for (i = 0; i < MAX_SCRATCH; i++) {
}
/* initialize precomputation table */
for (i = 0; i < 16; i++) {
}
for (i = 0; i < MAX_SCRATCH; i++) {
}
/* Set out[8] = P */
/* Set (tpx, tpy) = 2P */
group));
/* Set 3P, 5P, ..., 15P */
for (i = 8; i < 15; i++) {
group));
}
/* Set -15P, -13P, ..., -P */
for (i = 0; i < 8; i++) {
}
/* R = inf */
/* Allocate memory for NAF */
#ifdef _KERNEL
#else
goto CLEANUP;
}
#endif
/* Compute 5NAF */
/* wNAF method */
for (i = orderBitSize; i >= 0; i--) {
/* R = 2R */
if (naf[i] != 0) {
}
}
/* convert result S to affine coordinates */
for (i = 0; i < MAX_SCRATCH; i++) {
}
for (i = 0; i < 16; i++) {
}
#ifdef _KERNEL
#else
#endif
return res;
}