.. _gfpecpublickey:


GFpECPublicKey
==============


Computes a public key from the given private key of the elliptic curve
cryptosystem over GF(p).


Syntax
------


IppStatus ippsGFpECPublicKey(const IppsBigNumState\* pPrivate,
IppsGFpECPoint\* pPublic, IppsGFpECState\* pEC, Ipp8u\* pScratchBuffer);


Include Files
-------------


``ippcp.h``


Parameters
----------


.. list-table::
   :header-rows: 0

   * - pPrivate
     - Pointer to the private key ``privKey``.
   * - pPublic
     - Pointer to the public key ``pubKey``.
   * - pEC
     - Pointer to the context of the elliptic curve.
   * - pScratchBuffer
     - Pointer to the scratch buffer of size produced by *ippsGFpECScratchBufferSize*.




Description
-----------


The function computes the public key ``pubKey`` from the given private
key ``privKey`` of the elliptic cryptosystem over a finite field
GF(``p``).


The private key ``privKey`` is a number that lies in the range of [1,
``n``-1] where ``n`` is the order of the elliptic curve base point. The
public key ``pubKey`` is an elliptic curve point such that ``pubKey`` =
``privKey`` · ``G``, where ``G`` is the base point of the elliptic
curve.


The private key ``privKey`` can be generated by the function
:ref:`GFpECPrivateKey <gfpecprivatekey-gfpecpublickey-gfpectstkeypair>`.


The context of the point ``pubKey`` as an elliptic curve point must be
created by using the functions
:ref:`GFpECPointGetSize <gfpecpointgetsize>`
and :ref:`GFpECPointInit <gfpecpointinit>`.


The elliptic curve domain parameters must be defined by the functions:
:ref:`GFpECInitStd <gfpecinitstd>`,
:ref:`GFpECInit <gfpecinit>`,
:ref:`GFpECSet <gfpecset>`, or
:ref:`GFpECSetSubgroup <gfpecsetsubgroup>`.

The *ippsGFpECScratchBufferSize* function should be called with *nScalars* equal to at least 1 to get the valid *pScratchBuffer*.

.. note::
   Note: The point multiplication kernel implementation ensures all intermediate values remain in registers, avoiding memory spills to the stack.

Return Values
-------------


.. list-table::
   :header-rows: 0

   * - ippStsNoErr
     - Indicates no error. Any other value indicates an error or warning.
   * - ippStsNullPtrErr
     - Indicates an error condition if any of the specified pointers is NULL.
   * - ippStsContextMatchErr
     - Indicates an error condition if any of the contexts pointed to by pPrivate, pPublic, or pEC does not match the operation.
   * - ippStsIvalidPrivateKey
     - Indicates an error condition if the value of the private key falls outside the range of [1, ``n``-1].
   * - ippStsRangeErr
     - Indicates an error condition if pPublic does not belong to the finite field that the elliptic curve is initialized over.



