43.3.6.3 Point Addition and Subtraction
Purpose
This service is used to perform a point addition and point subtraction, based on a given elliptic curve over GF(p). Please note that:
- This service is not intended to add the same point twice. In this particular case, use the doubling service (see Fast Point Doubling).
How to Use the Service
Description
The operation performed is:
PtC = PtA ± PtB
In this computation, the following parameters need to be provided:
- A the input point is filled in projective coordinates (X,Y,Z) (pointed by {nu1PointABase,3*u2ModLength + 12}). This point can be the Infinite Point.
- B the input point is filled in projective coordinates (X,Y,Z) (pointed by {nu1PointBBase,3*u2ModLength + 12}). This point can be the Infinite Point.
- Cns the Fast Modular Constant filled (pointed by {nu1CnsBase,u2ModLength +8})
- P the modulus filled (pointed by {nu1ModBase,u2ModLength +4})
- The workspace not initialized (pointed by {nu1WorkSpace, 5*u2ModLength +32}
- The operator filled with the operation to perform (Addition or Subtraction)
The resulting C point is represented in projective coordinates (X,Y,Z) and is stored at the very same place than the input point A. This Point can be the Infinite Point.
The service name for this operation is
ZpEccAddSubFast
. This
service uses Fast mode and Fast Modular
Reduction for computations.
Parameters Definition
Parameter | Type | Direction | Location | Data Length | Before Executing the Service | After Executing the Service |
---|---|---|---|---|---|---|
nu1ModBase | nu1 | I | Crypto RAM | u2ModLength + 4 | Base of Modulus P | Base of Modulus P |
nu1CnsBase | nu1 | I | Crypto RAM | u2ModLength + 8 | Base of Cns | Base of Cns |
u2ModLength | u2 | I | – | – | Length of modulo | Length of modulo |
nu1PointABase | nu1 | I/O | Crypto RAM | 3*u2ModLength + 12 | Input point A (projective coordinates) | Resulting point C (projective coordinates) |
nu1PointBBase | nu1 | I | Crypto RAM | 3*u2ModLength + 12 | Input point B (projective coordinates) | Input point B |
u2Operator | u2 | I | - | - | Addition or Subtraction | Addition or Subtraction |
nu1Workspace | nu1 | I | Crypto RAM | 5*u2ModLength + 32 | – | Corrupted workspace |
Code Example
PUKCL_PARAM PUKCLParam;
PPUKCL_PARAM pvPUKCLParam = &PUKCLParam;
PUKCL (u2Option) = 0;
PUKCL _ZpEccAddSub(nu1ModBase) = <Base of the ram location of P>;
PUKCL _ZpEccAddSub(nu1CnsBase) = <Base of the ram location of Cns>;
PUKCL _ZpEccAddSub(u2ModLength) = <Byte length of P>;
PUKCL _ZpEccAddSub(nu1PointABase) = <Base of the ram location of the A point>;
PUKCL _ZpEccAddSub(nu1PointBBase) = <Base of the ram location of the B point>;
PUKCL _ZpEccAddSub(nu1Workspace) = <Base of the ram location of the workspace>;
PUKCL _ZpEccAddSub(u2Operator) = <Operation to perform (PUKCL_ZPECCADD or PUKCL_ZPECCSUB)>;
...
// vPUKCL_Process() is a macro command, which populates the service name
// and then calls the library...
vPUKCL_Process(ZpEccAddSubFast,&PUKCLParam);
if (PUKCL (u2Status) == PUKCL_OK)
{
...
}
else // Manage the error
Constraints
No overlapping between either input and output are allowed. The following conditions must be avoided to ensure that the service works correctly:
- nu1ModBase, nu1CnsBase, nu1PointABase, nu1PointBBase, nu1Workspace are not aligned on 32-bit boundaries
- {nu1ModBase, u2ModLength + 4}, {nu1CnsBase, u2ModLength + 8}, {nu1PointABase, 3*u2ModLength + 12}, {nu1PointBBase, 3*u2ModLength + 12}, {nu1Workspace, <WorkspaceLength>} are not in Crypto RAM
- u2ModLength is either: < 12, > 0xffc or not a 32-bit length
- All overlapping between {nu1ModBase, u2ModLength + 4}, {nu1CnsBase, u2ModLength +8},{nu1PointABase, 3*u2ModLength + 12}, {nu1PointBBase, 3*u2ModLength + 12} and {nu1Workspace, 5*u2ModLength + 32}
Status Returned Values
Returned Status | Importance | Meaning |
---|---|---|
PUKCL_OK | – | The computation passed without problem. |