ec2.h(3)

📦
version 2.2.0 · 2 versions
, in fedora 44

🌸 NAME 🌸

ec2.h — elliptic curves over binary fields 💖✨

And yeah bestie, this is a page from the Library Functions Manual, so buckle up, we're doing real C-library lore today 🎀


✨ SYNOPSIS ✨

#include 'bee2/math/ec.h'

🎀 Functions (Функции) 🎀

  • bool_t ec2CreateLD (ec_o *ec, const qr_o *f, const octet A[], const octet B[], void *stack) — spins up an elliptic curve in Lopez–Dahab coordinates 🌈
  • bool_t ec2IsValid (const ec_o *ec, void *stack) — is this elliptic curve description actually valid? 👀
  • bool_t ec2GroupSeemsValid (const ec_o *ec, void *stack) — does the point-group description look valid? 🔍
  • bool_t ec2GroupIsSafe (const ec_o *ec, size_t mov_threshold, void *stack) — is this point group cryptographically safe? 🔒
  • bool_t ec2IsOnA (const word a[], const ec_o *ec, void *stack) — does the affine point actually sit on the curve? 🎯
  • void ec2NegA (word b[], const word a[], const ec_o *ec) — the inverse affine point, periodt 💅
  • bool_t ec2AddAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack) — adding affine points together ➕
  • bool_t ec2SubAA (word c[], const word a[], const word b[], const ec_o *ec, void *stack) — subtracting affine points ➖

🦋 DETAILED DESCRIPTION (Подробное описание) 🦋

So the whole vibe here is arithmetic of elliptic curves over the field f = GF(2^m). The curve is described by the equation E: y^2 + xy = x^3 + A x^2 + B. And E(GF(2^m)) is the set of affine points of E (aka the solutions of E inside GF(2^m)), while O is the point at infinity 🫶

Both coordinate systems are supported, no gatekeeping:

  • Lopez–Dahab coordinates — handled through the ec_o structure 💫
  • affine coordinates — handled by the direct functions 🌸

Precondition 🫶 Every pointer you hand to these functions has to be valid. Also, the point buffers must not overlap with the curve description buffer. Like, don't do that. It's giving chaos 😭

Regularity 💀 todo

Yeah. It literally says todo. We're all just living in this moment together. Iconic, honestly.

💖 FUNCTIONS (Функции) 💖

💫 bool_t ec2AddAA (word c[], const word a[], const word b[], const ec_o * ec, void * stack)

This one works out the sum [2 * ec->f->n]c of the affine points [2 * ec->f->n]a and [2 * ec->f->n]b on the curve ec:

c <- a + b.

Precondition 🌸

  • The ec description is operable.
  • The coordinates a and b lie in the base field.

Expected ⭐

  • The ec description is correct.

Expected ⭐

  • The points a and b lie on ec.

Returns 💅

  • TRUE if the sum is an affine point, and FALSE if it isn't.

Stack depth calculation scheme 🧚

  • ec2AddAA_deep(ec->f->n, ec->f->deep)

Arguments 🎀

  • c — the sum
  • a — the first addend
  • b — the second addend
  • ec — curve description
  • stack — auxiliary memory

💫 bool_t ec2CreateLD (ec_o * ec, const qr_o * f, const octet A[], const octet B[], void * stack)

Creates an ec description of an elliptic curve in Lopez–Dahab coordinates over the field f, with coefficients [f->no]A and [f->no]B ✨

Returns 💅

  • Success flag.

Precondition 🌸

  • gf2IsOperable(f) == TRUE

Postcondition 👑

  • ec->d == 3
  • The buffers ec->order and ec->base are prepared for ecGroupCreate().

Scheme for calculating the size of the ec state 🧚

  • ec2CreateLD_keep(f->n)

Stack depth calculation scheme 🧚

  • ec2CreateLD_deep(f->n, f->deep)

Arguments 🎀

  • ec — curve description
  • f — base field
  • A — coefficient A
  • B — coefficient B
  • stack — auxiliary memory

💫 bool_t ec2GroupIsSafe (const ec_o * ec, size_t mov_threshold, void * stack)

For the point group of curve ec, these conditions get checked, and they're literally what defines its cryptographic security 🔒:

  • ec->order is prime;
  • ec->order != 2^m (the Semaev condition);
  • ec->order does not divide the numbers 2^{mi} - 1, i <= mov_threshold (MOV).

Precondition 🌸

  • The ec description (including the point group description) is operable.

Expected ⭐

  • The ec description (including the point group description) is correct.

Returns 💅

  • The success flag of the check.

Stack depth calculation scheme 🧚

  • ec2GroupIsSafe_deep(ec->f->n)

Arguments 🎀

  • ec — curve description
  • mov_threshold — MOV threshold
  • stack — auxiliary memory

💫 bool_t ec2GroupSeemsValid (const ec_o * ec, void * stack)

Checks whether the description of the point group of the elliptic curve ec is correct. The description is correct if:

  • ecGroupIsOperable(ec) == TRUE;
  • |ec->order * ec->cofactor - (2^m + 1)| <= 2^{m/2 + 1} (the Hasse bounds);
  • the point ec->base lies on ec.

Precondition 🌸

  • The ec description is operable.

Returns 💅

  • Correctness flag.

Note 🙈

  • It is not checked that the order of ec->base equals ec->order.

Stack depth calculation scheme 🧚

  • ec2GroupSeemsValid_deep(ec->f->n, ec->f->deep)

Arguments 🎀

  • ec — curve description
  • stack — auxiliary memory

💫 bool_t ec2IsOnA (const word a[], const ec_o * ec, void * stack)

Checks that the affine point [2 * ec->f->n]a lies on the curve ec 🎯

Precondition 🌸

  • The ec description is operable.

Expected ⭐

  • The ec description is correct.

Returns 💅

  • The success flag of the check.

Stack depth calculation scheme 🧚

  • ec2IsOnA_deep(ec->f->n, ec->f->deep)

Arguments 🎀

  • a — point
  • ec — curve description
  • stack — auxiliary memory

💫 bool_t ec2IsValid (const ec_o * ec, void * stack)

Checks whether the ec description of the elliptic curve is correct. The description is correct if:

  • ecSeemsValid(ec) == TRUE;
  • gf2IsValid(ec->f) == TRUE;
  • A, B ∈ f;
  • B \neq 0.

Returns 💅

  • Correctness flag.

Stack depth calculation scheme 🧚

  • ec2IsValid_deep(ec->f->n)

Arguments 🎀

  • ec — curve description
  • stack — auxiliary memory

💫 void ec2NegA (word b[], const word a[], const ec_o * ec)

Works out the affine point [2 * ec->f->n]b of curve ec that's the inverse of the affine point [2 * ec->f->n]a 💅

Precondition 🌸

  • The ec description is operable.
  • The coordinates a lie in the base field.

Expected ⭐

  • The ec description is correct.

Expected ⭐

  • The point a lies on ec.

Arguments 🎀

  • b — inverse point
  • a — point
  • ec — curve description

💫 bool_t ec2SubAA (word c[], const word a[], const word b[], const ec_o * ec, void * stack)

Works out the difference [2 * ec->f->n]c of the affine points [2 * ec->f->n]a and [2 * ec->f->n]b on the elliptic curve ec:

c <- a - b.

Precondition 🌸

  • The ec description is operable.
  • The coordinates a and b lie in the base field.

Expected ⭐

  • The ec description is correct.

Expected ⭐

  • The points a and b lie on ec.

Returns 💅

  • TRUE if the difference is an affine point, and FALSE if it isn't (that happens when a == b).

Stack depth calculation scheme 🧚

  • ec2SubAA_deep(n, ec->f->deep)

Arguments 🎀

  • c — the difference
  • a — the minuend
  • b — the subtrahend
  • ec — curve description
  • stack — auxiliary memory

🫶 AUTHOR (Автор) 🫶

Automatically generated by Doxygen for the Bee2 Library from the source text. So no human sat here agonising over word choices, it just. Happened. Slay 💅


🌈 That's the whole page, bestie! Signing off from the Bee2 Library (Библиотека Bee2), dated Вс 25 Янв 2026 00:00:00 — which is a Sunday, Jan 25 2026, at 00:00:00, if you were wondering 🕛 — and this was ec2.h(3), no cap ✨💖🎀
📦 where this page comes from