Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/field.h
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | |||||
/** Sets a field element to be the (modular) inverse of another. Requires the input's magnitude to be | /** Sets a field element to be the (modular) inverse of another. Requires the input's magnitude to be | ||||
* at most 8. The output magnitude is 1 (but not guaranteed to be normalized). */ | * at most 8. The output magnitude is 1 (but not guaranteed to be normalized). */ | ||||
static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a); | static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a); | ||||
/** Potentially faster version of secp256k1_fe_inv, without constant-time guarantee. */ | /** Potentially faster version of secp256k1_fe_inv, without constant-time guarantee. */ | ||||
static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a); | static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a); | ||||
/** Calculate the (modular) inverses of a batch of field elements. Requires the inputs' magnitudes to be | |||||
* at most 8. The output magnitudes are 1 (but not guaranteed to be normalized). The inputs and | |||||
* outputs must not overlap in memory. */ | |||||
static void secp256k1_fe_inv_all_var(secp256k1_fe *r, const secp256k1_fe *a, size_t len); | |||||
/** Convert a field element to the storage type. */ | /** Convert a field element to the storage type. */ | ||||
static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a); | static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a); | ||||
/** Convert a field element back from the storage type. */ | /** Convert a field element back from the storage type. */ | ||||
static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a); | static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a); | ||||
/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/ | /** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/ | ||||
static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag); | static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag); | ||||
/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/ | /** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/ | ||||
static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag); | static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag); | ||||
#endif /* SECP256K1_FIELD_H */ | #endif /* SECP256K1_FIELD_H */ |