Cryptography Reference
In-Depth Information
SHA-1 hash. Because you're going to be dealing with a 256-bit integer, at
least, go ahead and rewrite the elliptic-curve math functions from Chapter 3
to work with huge integers.
Rewriting the Elliptic-Curve Math Functions to Support Large
Numbers
The implementations are, obviously, not drastically different than with 32-bit
integers; a few things are shuffl ed around to reduce the number of temporary
huge objects, though, so you might want to compare this code carefully to the
ECC code in Chapter 3.
If you recall, ECC involves two operations: point addition — which works on
two distinct points in a Cartesian plane, whose X-values must be different — and
point multiplication — which works on one point and a scalar value. To imple-
ment, follow these steps:
1. Redefi ne the point , elliptic_curve , and ecc_key structures in Listing 4-35
to work with huge s instead of points.
Listing 4-35: “ecc.h” elliptic curve structure declarations
typedef struct
{
huge x;
huge y;
}
point;
typedef struct
{
huge p;
huge a;
huge b;
point G;
huge n; // n is prime and is the “order” of G
huge h; // h = #E(F_p)/n (# is the number of points on the curve)
}
elliptic_curve;
typedef struct
{
huge d; // random integer < n; this is the private key
point Q; // Q = d * G; this is the public key
}
ecc_key;
2. You need an add_points operation in Listing 4-36.
 
Search WWH ::




Custom Search