ecp.h(3)

📦
version 2.2.0 · 2 versions
, in fedora 44

🌸 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 coordinates
  • bool_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 point
  • bool_t ecpAddAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack) — adding affine points
  • bool_t ecpSubAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack) — subtracting affine points
  • void 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 ec description is operable. The coordinates a and b live in the base field.
  • Ожидается — the ec description is correct.
  • Ожидается — points a and b lie on ec.
  • Возвращает — TRUE if the sum is an affine point, and FALSE otherwise.
  • Схема расчета глубины stack — ecpAddAA_deep(ec->f->n, ec->f->deep).
  • Аргументы
    • c — the sum
    • a — first addend
    • b — second addend
    • ec — curve description
    • stack — 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 buffers ec->order and ec->base are prepped and ready for ecGroupCreate().
  • Схема расчета размера состояния ec — ecpCreateJ_keep(f->n).
  • Схема расчета глубины stack — ecpCreateJ_deep(f->n, f->deep).
  • Аргументы
    • ec — curve description
    • f — base field
    • A — coefficient A
    • B — coefficient B
    • stack — 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->order is prime;
  • ec->order != p (the Semaev condition);
  • ec->order does not divide the numbers p^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 description
    • mov_threshold — MOV threshold
    • stack — 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->base lies on ec.
  • Предусловие — the description ec is operable.
  • Возвращает — the correctness flag.
  • Прим. — it does not check that the order of ec->base equals ec->order. Just so you know. 🙈
  • Схема расчета глубины stack — ecpGroupSeemsValid_deep(ec->f->n, ec->f->deep).
  • Аргументы
    • ec — curve description
    • stack — 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 ec is operable.
  • Ожидается — the description ec is correct.
  • Возвращает — the success flag of the check.
  • Схема расчета глубины stack — ecpIsOnA_deep(ec->f->n, ec->f->deep).
  • Аргументы
    • a — point
    • ec — curve description
    • stack — 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^2 is not divisible by p (that's the smoothness condition).
  • Возвращает — the correctness flag.
  • Схема расчета глубины stack — ecpIsValid_deep(ec->f->n, f->deep).
  • Аргументы
    • ec — curve description
    • stack — 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 ec is operable. The coordinates a live in the base field.
  • Ожидается — the description ec is correct.
  • Ожидается — the point a lies on ec.
  • Аргументы
    • b — the inverse point
    • a — point
    • ec — 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 ec is operable. The coordinates a and b live in the base field.
  • Ожидается — the description ec is correct.
  • Ожидается — points a and b lie on ec.
  • Возвращает — TRUE if the difference is an affine point, and FALSE otherwise (that's the a == b case).
  • Схема расчета глубины stack — ecpSubAA_deep(n, ec->f->deep).
  • Аргументы
    • c — the difference
    • a — the minuend
    • b — the subtrahend
    • ec — curve description
    • stack — 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 ec is operable. a ∈ f && p \equiv 3 (\mod 4) && A != 0 && B != 0.
  • Ожидается — the description ec is correct.
  • Ожидается — B is a quadratic residue modulo p. If this condition gets broken, then the point b will not lie on ec for a ∈ {0, p - 1}.
  • Прим. — the SWU algorithm is implemented as edited in СТБ 34.101.66.
  • Схема расчета глубины stack — ecpSWU_deep(ec->f->n, ec->f->deep).
  • Аргументы
    • b — point
    • a — field element
    • ec — curve description
    • stack — 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