ecp.h(3)
🌸 NAME 🌸
ecp.h — literally the header for elliptic curves over prime fields. It lives in the Library Functions Manual, bestie, and it's giving big crypto energy. 💅
✨ SYNOPSIS ✨
#include 'bee2/math/ec.h'
🎀 ФУНКЦИИ (the whole squad) 🎀
bool_t ecpCreateJ (ec_o *ec, const qr_o *f, const octet A[], const octet B[], void *stack)— makes an elliptic curve in Jacobian coordinatesbool_t ecpIsValid (const ec_o *ec, void *stack)— is this elliptic curve description actually correct?bool_t ecpGroupSeemsValid (const ec_o *ec, void *stack)— does this point group description look correct?bool_t ecpGroupIsSafe (const ec_o *ec, size_t mov_threshold, void *stack)— is this point group cryptographically safe?bool_t ecpIsOnA (const word a[], const ec_o *ec, void *stack)— does this affine point sit on the curve?void ecpNegA (word b[], const word a[], const ec_o *ec)— the inverse affine pointbool_t ecpAddAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack)— adding affine pointsbool_t ecpSubAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack)— subtracting affine pointsvoid ecpSWU (word b[], const word a[], const ec_o *ec, void *stack)— turning a field element into an affine point
💖 ПОДРОБНОЕ ОПИСАНИЕ (the deets) 💖
So here's the tea: this is full arithmetic for elliptic curves over a prime field f = GF(p). The curve is described by a Weierstrass equation E: y^2 = x^3 + Ax + B (\mod p). And E(GF(p)) — that's the set of affine points of E (aka the solutions of E in GF(p)), while O is the point at infinity. Iconic behavior honestly.
Both Jacobian coordinates (via the ec_o structure) and affine coordinates (straight-up direct functions) are supported. No cap. 🦋
Предусловие (preconditions)
- Every pointer handed to these functions has to be valid.
- Point buffers must not overlap with the curve description buffer. Like, keep them separate, bestie.
Регулярность
todo🙈
🔥 ФУНКЦИИ (deep dive) 🔥
⭐ bool_t ecpAddAA (word c[], const word a[], const word b[], const ec_o * ec, void * stack)
okay so this one figures out the sum [2 * ec->f->n]c of the affine points [2 * ec->f->n]a and [2 * ec->f->n]b of the curve ec, like so:
c <- a + b.
- Предусловие — the
ecdescription is operable. The coordinatesaandblive in the base field. - Ожидается — the
ecdescription is correct. - Ожидается — points
aandblie onec. - Возвращает —
TRUEif the sum is an affine point, andFALSEotherwise. - Схема расчета глубины
stack—ecpAddAA_deep(ec->f->n, ec->f->deep). - Аргументы
c— the suma— first addendb— second addendec— curve descriptionstack— auxiliary memory
⭐ bool_t ecpCreateJ (ec_o * ec, const qr_o * f, const octet A[], const octet B[], void * stack)
This creates the description ec of an elliptic curve in Jacobian coordinates over the field f, with coefficients [f->no]A and [f->no]B. Slay.
- Возвращает — the success flag.
- Предусловие —
gfpIsOperable(f) == TRUE. - Ожидается [FALSE] —
f->mod > 3. - Постусловие —
ec->d == 3. The buffersec->orderandec->baseare prepped and ready forecGroupCreate(). - Схема расчета размера состояния
ec—ecpCreateJ_keep(f->n). - Схема расчета глубины
stack—ecpCreateJ_deep(f->n, f->deep). - Аргументы
ec— curve descriptionf— base fieldA— coefficient AB— coefficient Bstack— auxiliary memory
⭐ bool_t ecpGroupIsSafe (const ec_o * ec, size_t mov_threshold, void * stack)
For the point group of the curve ec, it checks these conditions — and these are the ones that decide whether the group is cryptographically safe:
ec->orderis prime;ec->order != p(the Semaev condition);ec->orderdoes not divide the numbersp^i - 1,i <= mov_threshold(MOV).- Предусловие — the description
ec(point group description included) is operable. - Ожидается — the description
ec(point group description included) is correct. - Возвращает — the success flag of the check.
- Схема расчета глубины
stack—ecpGroupIsSafe_deep(ec->f->n). - Аргументы
ec— curve descriptionmov_threshold— MOV thresholdstack— auxiliary memory
⭐ bool_t ecpGroupSeemsValid (const ec_o * ec, void * stack)
This one checks whether the description of the point group of the elliptic curve ec is correct. It counts as correct when:
ecGroupIsOperable(ec) == TRUE;|ec->order * ec->cofactor - (p + 1)| <= 2 * \sqrt (p)(the Hasse bounds);- the point
ec->baselies onec. - Предусловие — the description
ecis operable. - Возвращает — the correctness flag.
- Прим. — it does not check that the order of
ec->baseequalsec->order. Just so you know. 🙈 - Схема расчета глубины
stack—ecpGroupSeemsValid_deep(ec->f->n, ec->f->deep). - Аргументы
ec— curve descriptionstack— auxiliary memory
⭐ bool_t ecpIsOnA (const word a[], const ec_o * ec, void * stack)
Checks that the affine point [2 * ec->f->n]a lies on the curve ec. Vibe check, but for points. ✨
- Предусловие — the description
ecis operable. - Ожидается — the description
ecis correct. - Возвращает — the success flag of the check.
- Схема расчета глубины
stack—ecpIsOnA_deep(ec->f->n, ec->f->deep). - Аргументы
a— pointec— curve descriptionstack— auxiliary memory
⭐ bool_t ecpIsValid (const ec_o * ec, void * stack)
Checks whether the description ec of the elliptic curve is correct. It's correct when:
ecSeemsValid(ec) == TRUE;gfpIsValid(ec->f) == TRUE;ec->f->mod > 3;A, B ∈ f;4 A^3 + 27 B^2is not divisible byp(that's the smoothness condition).- Возвращает — the correctness flag.
- Схема расчета глубины
stack—ecpIsValid_deep(ec->f->n, f->deep). - Аргументы
ec— curve descriptionstack— auxiliary memory
⭐ void ecpNegA (word b[], const word a[], const ec_o * ec)
Defines the affine point [2 * ec->f->n]b of the curve ec that is the inverse of the affine point [2 * ec->f->n]a.
- Предусловие — the description
ecis operable. The coordinatesalive in the base field. - Ожидается — the description
ecis correct. - Ожидается — the point
alies onec. - Аргументы
b— the inverse pointa— pointec— curve description
⭐ bool_t ecpSubAA (word c[], const word a[], const word b[], const ec_o * ec, void * stack)
Defines the difference [2 * ec->f->n]c of the affine points [2 * ec->f->n]a and [2 * ec->f->n]b of the elliptic curve ec:
c <- a - b.
- Предусловие — the description
ecis operable. The coordinatesaandblive in the base field. - Ожидается — the description
ecis correct. - Ожидается — points
aandblie onec. - Возвращает —
TRUEif the difference is an affine point, andFALSEotherwise (that's thea == bcase). - Схема расчета глубины
stack—ecpSubAA_deep(n, ec->f->deep). - Аргументы
c— the differencea— the minuendb— the subtrahendec— curve descriptionstack— auxiliary memory
⭐ void ecpSWU (word b[], const word a[], const ec_o * ec, void * stack)
The field element [ec->f->n]a of the field ec->f gets converted into the affine point [2 * ec->f->n]b of the elliptic curve ec.
- Предусловие — the description
ecis operable.a ∈ f && p \equiv 3 (\mod 4) && A != 0 && B != 0. - Ожидается — the description
ecis correct. - Ожидается —
Bis a quadratic residue modulop. If this condition gets broken, then the pointbwill not lie onecfora ∈ {0, p - 1}. - Прим. — the SWU algorithm is implemented as edited in СТБ 34.101.66.
- Схема расчета глубины
stack—ecpSWU_deep(ec->f->n, ec->f->deep). - Аргументы
b— pointa— field elementec— curve descriptionstack— auxiliary memory
💜 АВТОР 💜
Auto-generated by Doxygen for the Bee2 Library, straight from the source text. 🫶
and that's the whole page bestie, mwah 💅 — this was Библиотека Bee2, dated Вс 25 Янв 2026 00:00:00, and yes ecp.h(3) ate and left no crumbs 👑
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms