15#ifndef __DECAF_POINT_448_H__
16#define __DECAF_POINT_448_H__ 1
25#define DECAF_448_SCALAR_LIMBS ((446-1)/DECAF_WORD_BITS+1)
29#define DECAF_448_SCALAR_BITS 446
32#ifndef __DECAF_448_GF_DEFINED__
33#define __DECAF_448_GF_DEFINED__ 1
37} __attribute__((aligned(32)))
gf_448_s, gf_448_t[1];
42#define DECAF_448_SER_BYTES 56
47#define DECAF_448_HASH_BYTES 56
50#define DECAF_448_SCALAR_BYTES 56
53#define DECAF_448_INVERT_ELLIGATOR_WHICH_BITS 3
56#define DECAF_448_REMOVED_COFACTOR 4
59#define DECAF_X448_ENCODE_RATIO 2
62#define DECAF_X448_PUBLIC_BYTES 56
65#define DECAF_X448_PRIVATE_BYTES 56
86 decaf_word_t limb[DECAF_448_SCALAR_LIMBS];
136decaf_error_t DECAF_API_VIS decaf_448_scalar_decode (
139) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
151 const unsigned char *ser,
153) DECAF_NONNULL DECAF_NOINLINE;
164) DECAF_NONNULL DECAF_NOINLINE DECAF_NOINLINE;
176) DECAF_NONNULL DECAF_NOINLINE;
188) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
200) DECAF_NONNULL DECAF_NOINLINE;
212) DECAF_NONNULL DECAF_NOINLINE;
222) DECAF_NONNULL DECAF_NOINLINE;
233) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
241static inline void DECAF_NONNULL decaf_448_scalar_copy (
267) DECAF_NONNULL DECAF_NOINLINE;
286 decaf_bool_t allow_identity
287) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
296static inline void DECAF_NONNULL decaf_448_point_copy (
315) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
382) DECAF_NONNULL DECAF_NOINLINE;
405 decaf_bool_t allow_identity,
406 decaf_bool_t short_circuit
407) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_NOINLINE;
425) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_NOINLINE;
473) DECAF_NONNULL DECAF_NOINLINE DECAF_DEPRECATED(
"Renamed to decaf_x448_derive_public_key");
488) DECAF_NONNULL DECAF_NOINLINE;
504) DECAF_NONNULL DECAF_NOINLINE;
521) DECAF_NONNULL DECAF_NOINLINE;
542) DECAF_NONNULL DECAF_NOINLINE;
565) DECAF_NONNULL DECAF_NOINLINE;
587) DECAF_NONNULL DECAF_NOINLINE;
603) DECAF_NONNULL DECAF_NOINLINE;
619) DECAF_NONNULL DECAF_NOINLINE;
630) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE;
642) DECAF_NONNULL DECAF_NOINLINE;
657) DECAF_NONNULL DECAF_NOINLINE;
691) DECAF_NONNULL DECAF_NOINLINE;
704) DECAF_NONNULL DECAF_NOINLINE;
739) DECAF_NONNULL DECAF_NOINLINE DECAF_WARN_UNUSED;
764) DECAF_NONNULL DECAF_NOINLINE DECAF_WARN_UNUSED;
Common utility headers for Decaf library.
#define DECAF_WORD_BITS
The number of bits in a word.
Definition common.h:76
decaf_error_t
Another boolean type used to indicate success or failure.
Definition common.h:120
void DECAF_API_VIS decaf_448_scalar_halve(decaf_448_scalar_t out, const decaf_448_scalar_t a) DECAF_NONNULL DECAF_NOINLINE
Halve a scalar.
#define DECAF_X448_PUBLIC_BYTES
Number of bytes in an x448 public key.
Definition point_448.h:62
void DECAF_API_VIS decaf_448_point_negate(decaf_448_point_t nega, const decaf_448_point_t a) DECAF_NONNULL
Negate a point to produce another point.
void DECAF_API_VIS decaf_448_point_sub(decaf_448_point_t diff, const decaf_448_point_t a, const decaf_448_point_t b) DECAF_NONNULL
Subtract two points to produce a third point.
void DECAF_API_VIS decaf_448_point_mul_by_ratio_and_encode_like_x448(uint8_t out[DECAF_X448_PUBLIC_BYTES], const decaf_448_point_t p) DECAF_NONNULL
Multiply a point by DECAF_X448_ENCODE_RATIO, then encode it like RFC 7748.
void DECAF_API_VIS decaf_448_point_encode(uint8_t ser[DECAF_448_SER_BYTES], const decaf_448_point_t pt) DECAF_NONNULL DECAF_NOINLINE
Encode a point as a sequence of bytes.
void DECAF_API_VIS decaf_448_base_double_scalarmul_non_secret(decaf_448_point_t combo, const decaf_448_scalar_t scalar1, const decaf_448_point_t base2, const decaf_448_scalar_t scalar2) DECAF_NONNULL DECAF_NOINLINE
Multiply two base points by two scalars: scaled = scalar1*decaf_448_point_base + scalar2*base2.
void DECAF_API_VIS decaf_x448_generate_key(uint8_t out[DECAF_X448_PUBLIC_BYTES], const uint8_t scalar[DECAF_X448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_NOINLINE DECAF_DEPRECATED("Renamed to decaf_x448_derive_public_key")
RFC 7748 Diffie-Hellman base point scalarmul.
decaf_error_t DECAF_API_VIS decaf_448_invert_elligator_nonuniform(unsigned char recovered_hash[DECAF_448_HASH_BYTES], const decaf_448_point_t pt, uint32_t which) DECAF_NONNULL DECAF_NOINLINE DECAF_WARN_UNUSED
Inverse of elligator-like hash to curve.
struct decaf_448_point_s decaf_448_point_t[1]
Representation of a point on the elliptic curve.
decaf_bool_t DECAF_API_VIS decaf_448_scalar_eq(const decaf_448_scalar_t a, const decaf_448_scalar_t b) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE
Compare two scalars.
decaf_bool_t DECAF_API_VIS decaf_448_point_valid(const decaf_448_point_t to_test) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE
Test that a point is valid, for debugging purposes.
void DECAF_API_VIS decaf_448_point_destroy(decaf_448_point_t point) DECAF_NONNULL
Securely erase a point by overwriting it with zeros.
decaf_error_t DECAF_API_VIS decaf_x448(uint8_t shared[DECAF_X448_PUBLIC_BYTES], const uint8_t base[DECAF_X448_PUBLIC_BYTES], const uint8_t scalar[DECAF_X448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_NOINLINE
RFC 7748 Diffie-Hellman scalarmul, used to compute shared secrets.
void DECAF_API_VIS decaf_448_point_from_hash_nonuniform(decaf_448_point_t pt, const unsigned char hashed_data[DECAF_448_HASH_BYTES]) DECAF_NONNULL DECAF_NOINLINE
Almost-Elligator-like hash to curve.
void DECAF_API_VIS decaf_448_scalar_cond_sel(decaf_448_scalar_t out, const decaf_448_scalar_t a, const decaf_448_scalar_t b, decaf_word_t pick_b) DECAF_NONNULL DECAF_NOINLINE
Constant-time decision between two scalars.
#define DECAF_448_SCALAR_BYTES
Number of bytes in a serialized scalar.
Definition point_448.h:50
void DECAF_API_VIS decaf_448_scalar_decode_long(decaf_448_scalar_t out, const unsigned char *ser, size_t ser_len) DECAF_NONNULL DECAF_NOINLINE
Read a scalar from wire format or from bytes.
void DECAF_API_VIS decaf_448_point_debugging_torque(decaf_448_point_t q, const decaf_448_point_t p) DECAF_NONNULL DECAF_NOINLINE
Torque a point, for debugging purposes.
void DECAF_API_VIS decaf_448_precomputed_destroy(decaf_448_precomputed_s *pre) DECAF_NONNULL
Securely erase a precomputed table by overwriting it with zeros.
void DECAF_API_VIS decaf_448_point_double_scalarmul(decaf_448_point_t combo, const decaf_448_point_t base1, const decaf_448_scalar_t scalar1, const decaf_448_point_t base2, const decaf_448_scalar_t scalar2) DECAF_NONNULL DECAF_NOINLINE
Multiply two base points by two scalars: scaled = scalar1*base1 + scalar2*base2.
void DECAF_API_VIS decaf_448_point_add(decaf_448_point_t sum, const decaf_448_point_t a, const decaf_448_point_t b) DECAF_NONNULL
Add two points to produce a third point.
decaf_bool_t DECAF_API_VIS decaf_448_point_eq(const decaf_448_point_t a, const decaf_448_point_t b) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE
Test whether two points are equal.
decaf_error_t DECAF_API_VIS decaf_448_direct_scalarmul(uint8_t scaled[DECAF_448_SER_BYTES], const uint8_t base[DECAF_448_SER_BYTES], const decaf_448_scalar_t scalar, decaf_bool_t allow_identity, decaf_bool_t short_circuit) DECAF_NONNULL DECAF_WARN_UNUSED DECAF_NOINLINE
Multiply a base point by a scalar: scaled = scalar*base.
void DECAF_API_VIS decaf_448_point_from_hash_uniform(decaf_448_point_t pt, const unsigned char hashed_data[2 *DECAF_448_HASH_BYTES]) DECAF_NONNULL DECAF_NOINLINE
Indifferentiable hash function encoding to curve.
void DECAF_API_VIS decaf_448_scalar_destroy(decaf_448_scalar_t scalar) DECAF_NONNULL
Securely erase a scalar.
DECAF_API_VIS const decaf_448_scalar_t decaf_448_scalar_one
The scalar 1.
void DECAF_API_VIS decaf_448_point_debugging_pscale(decaf_448_point_t q, const decaf_448_point_t p, const unsigned char factor[DECAF_448_SER_BYTES]) DECAF_NONNULL DECAF_NOINLINE
Projectively scale a point, for debugging purposes.
struct decaf_448_scalar_s decaf_448_scalar_t[1]
Representation of an element of the scalar field.
const uint8_t DECAF_API_VIS decaf_x448_base_point[DECAF_X448_PUBLIC_BYTES]
The base point for X448 Diffie-Hellman.
Definition decaf.c:66
void DECAF_API_VIS decaf_448_scalar_set_unsigned(decaf_448_scalar_t out, uint64_t a) DECAF_NONNULL
Set a scalar to an unsigned 64-bit integer.
void DECAF_API_VIS decaf_448_point_dual_scalarmul(decaf_448_point_t a1, decaf_448_point_t a2, const decaf_448_point_t base1, const decaf_448_scalar_t scalar1, const decaf_448_scalar_t scalar2) DECAF_NONNULL DECAF_NOINLINE
Multiply one base point by two scalars:
void DECAF_API_VIS decaf_448_precompute(decaf_448_precomputed_s *a, const decaf_448_point_t b) DECAF_NONNULL DECAF_NOINLINE
Precompute a table for fast scalar multiplication.
void DECAF_API_VIS decaf_448_scalar_mul(decaf_448_scalar_t out, const decaf_448_scalar_t a, const decaf_448_scalar_t b) DECAF_NONNULL DECAF_NOINLINE
Multiply two scalars.
void DECAF_API_VIS decaf_448_scalar_sub(decaf_448_scalar_t out, const decaf_448_scalar_t a, const decaf_448_scalar_t b) DECAF_NONNULL DECAF_NOINLINE
Subtract two scalars.
void DECAF_API_VIS decaf_448_point_scalarmul(decaf_448_point_t scaled, const decaf_448_point_t base, const decaf_448_scalar_t scalar) DECAF_NONNULL DECAF_NOINLINE
Multiply a base point by a scalar: scaled = scalar*base.
void DECAF_API_VIS decaf_x448_derive_public_key(uint8_t out[DECAF_X448_PUBLIC_BYTES], const uint8_t scalar[DECAF_X448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_NOINLINE
RFC 7748 Diffie-Hellman base point scalarmul.
void DECAF_API_VIS decaf_448_point_double(decaf_448_point_t two_a, const decaf_448_point_t a) DECAF_NONNULL
Double a point.
#define DECAF_448_SER_BYTES
Number of bytes in a serialized point.
Definition point_448.h:42
DECAF_API_VIS const decaf_448_point_t decaf_448_point_identity
The identity (zero) point on the curve.
DECAF_API_VIS const decaf_448_point_t decaf_448_point_base
An arbitrarily-chosen base point on the curve.
void DECAF_API_VIS decaf_448_precomputed_scalarmul(decaf_448_point_t scaled, const decaf_448_precomputed_s *base, const decaf_448_scalar_t scalar) DECAF_NONNULL DECAF_NOINLINE
Multiply a precomputed base point by a scalar: scaled = scalar*base.
void DECAF_API_VIS decaf_448_scalar_add(decaf_448_scalar_t out, const decaf_448_scalar_t a, const decaf_448_scalar_t b) DECAF_NONNULL DECAF_NOINLINE
Add two scalars.
#define DECAF_448_HASH_BYTES
Number of bytes in an elligated point.
Definition point_448.h:47
#define DECAF_X448_PRIVATE_BYTES
Number of bytes in an x448 private key.
Definition point_448.h:65
DECAF_API_VIS const struct decaf_448_precomputed_s * decaf_448_precomputed_base
Precomputed table of multiples of the base point on the curve.
DECAF_API_VIS const decaf_448_scalar_t decaf_448_scalar_zero
The scalar 0.
void DECAF_API_VIS decaf_448_point_cond_sel(decaf_448_point_t out, const decaf_448_point_t a, const decaf_448_point_t b, decaf_word_t pick_b) DECAF_NONNULL DECAF_NOINLINE
Constant-time decision between two points.
decaf_error_t DECAF_API_VIS decaf_448_point_decode(decaf_448_point_t pt, const uint8_t ser[DECAF_448_SER_BYTES], decaf_bool_t allow_identity) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE
Decode a point from a sequence of bytes.
decaf_error_t DECAF_API_VIS decaf_448_invert_elligator_uniform(unsigned char recovered_hash[2 *DECAF_448_HASH_BYTES], const decaf_448_point_t pt, uint32_t which) DECAF_NONNULL DECAF_NOINLINE DECAF_WARN_UNUSED
Inverse of elligator-like hash to curve.
void DECAF_API_VIS decaf_448_scalar_encode(unsigned char ser[DECAF_448_SCALAR_BYTES], const decaf_448_scalar_t s) DECAF_NONNULL DECAF_NOINLINE DECAF_NOINLINE
Serialize a scalar to wire format.
DECAF_API_VIS const size_t decaf_448_sizeof_precomputed_s
Size and alignment of precomputed point tables.
struct decaf_448_precomputed_s decaf_448_precomputed_s
Precomputed table based on a point.
Definition point_448.h:78
decaf_error_t DECAF_API_VIS decaf_448_scalar_invert(decaf_448_scalar_t out, const decaf_448_scalar_t a) DECAF_WARN_UNUSED DECAF_NONNULL DECAF_NOINLINE
Invert a scalar.
Representation of a point on the elliptic curve.
Definition point_448.h:68
Representation of an element of the scalar field.
Definition point_448.h:84