1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
13 #include "base/strings/string_piece.h"
14 #include "crypto/crypto_export.h"
18 // P224 implements an elliptic curve group, commonly known as P224 and defined
19 // in FIPS 186-3, section D.2.2.
22 // An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in
23 // little endian order.
24 typedef uint32_t FieldElement[8];
26 struct CRYPTO_EXPORT Point {
27 // SetFromString the value of the point from the 56 byte, external
28 // representation. The external point representation is an (x, y) pair of a
29 // point on the curve. Each field element is represented as a big-endian
31 bool SetFromString(base::StringPiece in);
33 // ToString returns an external representation of the Point.
34 std::string ToString() const;
36 // An Point is represented in Jacobian form (x/z², y/z³).
40 // kScalarBytes is the number of bytes needed to represent an element of the
42 static const size_t kScalarBytes = 28;
44 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian
46 void CRYPTO_EXPORT ScalarMult(const Point& in,
47 const uint8_t* scalar,
50 // ScalarBaseMult computes *out = g*scalar where g is the base point of the
51 // curve and scalar is a 28-byte, big-endian number.
52 void CRYPTO_EXPORT ScalarBaseMult(const uint8_t* scalar, Point* out);
54 // Add computes *out = a+b.
55 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out);
57 // Negate calculates out = -a;
58 void CRYPTO_EXPORT Negate(const Point& a, Point* out);
64 #endif // CRYPTO_P224_H_