PHPackages                             famoser/elliptic - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. famoser/elliptic

ActiveLibrary[Security](/categories/security)

famoser/elliptic
================

PHP Elliptic Curve Cryptography library

v0.1(10mo ago)02MITPHPPHP ^8.1CI passing

Since Aug 26Pushed 3mo agoCompare

[ Source](https://github.com/famoser/elliptic)[ Packagist](https://packagist.org/packages/famoser/elliptic)[ Docs](https://github.com/famoser/elliptic)[ RSS](/packages/famoser-elliptic/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Elliptic: Low-level Elliptic Curve Library
==========================================

[](#elliptic-low-level-elliptic-curve-library)

[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE)[![Test](https://github.com/famoser/elliptic/actions/workflows/integration.yml/badge.svg)](https://github.com/famoser/elliptic/actions/workflows/integration.yml)[![Coverage Status](https://camo.githubusercontent.com/e608be61681e2ad0ac84c9f02e2504f9aebfb6439a4c44f1c23dbf899630a4f3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f66616d6f7365722f656c6c69707469632f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/famoser/elliptic)

This library provides low-level access to elliptic curve group computations. Extensively tested (100% branch coverage, 9k third-party integration tests) and hardened against side-channels.

```
// get curves from SEC, brainpool and bernstein
$repository = new CurveRepository();
$curve = $repository->findByName('secp256r1');

// hardened (against side-channels) math for most curves
$mathFactory = new MathFactory($repository);
$math = $mathFactory->createHardenedMath($curve);

// can do double, add and mul
$G2 = $math->double($curve->getG());
$G3 = $math->add($curve->getG(), $G2);
$GA = $math->mul($curve->getG(), gmp_init(3));
if ($G3->equals($GA)) { echo "success"; }
```

Functionality overview:

- Curves: Use `SEC2`, `brainpool` and the bernstein curves (`curve25519` and `curve448`).
- Math: Operate on the curves using `add`, `double` and `mul`.
- Decoders: Decode according to SEC or bernstein. Recover points given only an x or y coordinate.

Compared to the popular `paragonie/phpecc`, this library focuses on the math on the elliptic curves directly, and does not implement any cryptographic primitives. For this task, this library is around 100x \[sic!\] faster, while not performing significantly worse in terms of side-channels.

Math overview
-------------

[](#math-overview)

There are two types of math:

- Unsafe implementations (`$repository->createUnsafeMath($curve)`): Simply implement the addition and double formulas for the given curve type (`$repository->createUnsafeMath($curve)`).
- Hardened implementations (`$repository->createHardenedMath($curve)`): Follow specifications and RFCs that notably aim to reduce the effectiveness of side-channels (side-channels may allow an adversary to recover the input to the algorithms, e.g. private key material, by observing the environment, e.g. time and power usage of the CPU).

All curves, except the `secp*k1` and the `brainpool*r1` variants, have hardened implementations available. Unless you have a good reason, you should use these hardened implementations.

Hardened MathSupported CurvesCorrectnessHardenedRuntime`SW_ANeg3_Math``secp*r1`, `brainpool*t1`✅⚠️⚠️4`SW_QT_ANeg3_Math``brainpool*r1`✅⚠️⚠️4`MGXCalculator` (`mul` only)`curve25519`, `curve448`✅⚠️⚠️⚠️1`MG_TwED_ANeg1_Math``curve25519`⚠️⚠️2.5`MG_ED_Math``curve448`❌❔2`TwED_ANeg1_Math``edwards25519`⚠️❔2.5`EDMath``edwards448`, `curve448Edwards`✅❔2Correctness:

- `MG_ED_Math` passes math sanity, but performs incorrectly in relation to baselines (e.g. third party testcases).
- `MG_TwED_ANeg1_Math` and `TwED_ANeg1_Math` perform correctly based on third-party testcases, but math sanity (e.g. G\*order = 0) fails.

Hardened:

- No implementation can be shown constant-time, and other side-channels are not quantitively assessed.
- Implementations finish faster with adversarial input (0 very small points and factors) vs random input.
- Unsafe maths show 50% variance in execution time, hardened math between 3% (`MG_TwED_ANeg1_Math`) and 15% (`MGXCalculator`)

Runtime:

- Denoted is execution time of mul in some unit; hence lower is better.
- `MGXCalculator` performs best, but is no full math implementation (no `double`, no `add`).
- The unsafe variants of SW are 2x faster, the unsafe variant of MG is 1.5x faster.

Project context
---------------

[](#project-context)

This library is part of a larger effort:

- Provide low-level library that executes math on elliptic curves (this project)
- Provide elliptic-crypto library which exposes general cryptographic primitives (signatures, encryptions and zero-knowledge proofs)
- Provide more specialized libraries for more exotic cryptographic primitives (verifiable shuffle)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance70

Regular maintenance activity

Popularity2

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 53.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

312d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5077020?v=4)[Florian Moser](/maintainers/famoser)[@famoser](https://github.com/famoser)

---

Top Contributors

[![famoser](https://avatars.githubusercontent.com/u/5077020?v=4)](https://github.com/famoser "famoser (312 commits)")[![afk11](https://avatars.githubusercontent.com/u/5617245?v=4)](https://github.com/afk11 "afk11 (174 commits)")[![btcdrak](https://avatars.githubusercontent.com/u/7275704?v=4)](https://github.com/btcdrak "btcdrak (47 commits)")[![rubensayshi](https://avatars.githubusercontent.com/u/649160?v=4)](https://github.com/rubensayshi "rubensayshi (14 commits)")[![mdanter](https://avatars.githubusercontent.com/u/2213324?v=4)](https://github.com/mdanter "mdanter (8 commits)")[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (6 commits)")[![fgrosse](https://avatars.githubusercontent.com/u/733004?v=4)](https://github.com/fgrosse "fgrosse (6 commits)")[![Spomky](https://avatars.githubusercontent.com/u/1091072?v=4)](https://github.com/Spomky "Spomky (4 commits)")[![xsilen-tt](https://avatars.githubusercontent.com/u/90232688?v=4)](https://github.com/xsilen-tt "xsilen-tt (2 commits)")[![aztech-dev](https://avatars.githubusercontent.com/u/93562568?v=4)](https://github.com/aztech-dev "aztech-dev (2 commits)")[![johanderuijter](https://avatars.githubusercontent.com/u/1373219?v=4)](https://github.com/johanderuijter "johanderuijter (2 commits)")[![scintill](https://avatars.githubusercontent.com/u/848492?v=4)](https://github.com/scintill "scintill (2 commits)")[![paragonie-scott](https://avatars.githubusercontent.com/u/11591518?v=4)](https://github.com/paragonie-scott "paragonie-scott (1 commits)")[![paragonie-security](https://avatars.githubusercontent.com/u/15914520?v=4)](https://github.com/paragonie-security "paragonie-security (1 commits)")[![rgex](https://avatars.githubusercontent.com/u/3996942?v=4)](https://github.com/rgex "rgex (1 commits)")[![makuser](https://avatars.githubusercontent.com/u/1778889?v=4)](https://github.com/makuser "makuser (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![dktapps](https://avatars.githubusercontent.com/u/14214667?v=4)](https://github.com/dktapps "dktapps (1 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")

---

Tags

ellipticcurvenistbrainpoolbernsteinweierstrassmontgomeryedwards

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/famoser-elliptic/health.svg)

```
[![Health](https://phpackages.com/badges/famoser-elliptic/health.svg)](https://phpackages.com/packages/famoser-elliptic)
```

###  Alternatives

[simplito/elliptic-php

Fast elliptic curve cryptography

2302.4M272](/packages/simplito-elliptic-php)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.7M143](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24820.0k38](/packages/paragonie-ecc)[ionux/phactor

Phactor is a high-performance PHP implementation of the elliptic curve math functions required to generate &amp; verify private/public (asymmetric) EC keypairs and ECDSA signatures based on secp256k1 curve parameters. This library also includes a class to generate Service Identification Numbers (SINs) based on the published Identity Protocol v1 spec.

5287.3k30](/packages/ionux-phactor)[kornrunner/secp256k1

Pure PHP secp256k1

40609.0k117](/packages/kornrunner-secp256k1)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
