• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

famoser / elliptic / 16238255757

12 Jul 2025 01:00PM UTC coverage: 84.857% (-6.3%) from 91.134%
16238255757

Pull #12

github

web-flow
Merge 97611838a into 5ce1049c0
Pull Request #12: WIP: Add montgomery

270 of 376 new or added lines in 17 files covered. (71.81%)

2 existing lines in 1 file now uncovered.

947 of 1116 relevant lines covered (84.86%)

23.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/src/Math/MG_TE_Math.php
1
<?php
2

3
namespace Famoser\Elliptic\Math;
4

5
use Famoser\Elliptic\Primitives\BirationalMap;
6
use Famoser\Elliptic\Primitives\Curve;
7
use Famoser\Elliptic\Primitives\Point;
8

9
/**
10
 * Assumes a montgomery curve with a birational map to a twisted edwards curve a=-1.
11
 *
12
 * Some hardening against side-channels has been done.
13
 */
14
class MG_TE_Math extends AbstractMath implements MathInterface
15
{
16
    private readonly TE_ANeg1_Math $math;
17

NEW
18
    public function __construct(Curve $curve, private readonly BirationalMap $birationalMap, Curve $targetCurve)
×
19
    {
NEW
20
        parent::__construct($curve);
×
21

NEW
22
        $this->math = new TE_ANeg1_Math($targetCurve);
×
23
    }
24

25
    public function add(Point $a, Point $b): Point
3✔
26
    {
27
        $mappedA = $this->birationalMap->map($a);
3✔
28
        $mappedB = $this->birationalMap->map($b);
3✔
29

30
        $mappedResult = $this->math->add($mappedA, $mappedB);
3✔
31

32
        return $this->birationalMap->reverse($mappedResult);
3✔
33
    }
34

35
    public function double(Point $a): Point
3✔
36
    {
37
        $mappedA = $this->birationalMap->map($a);
3✔
38

39
        $mappedResult = $this->math->double($mappedA);
3✔
40

41
        return $this->birationalMap->reverse($mappedResult);
3✔
42
    }
43

44
    public function mul(Point $point, \GMP $factor): Point
4✔
45
    {
46
        $mapped = $this->birationalMap->map($point);
4✔
47

48
        $mappedResult = $this->math->mul($mapped, $factor);
4✔
49

50
        return $this->birationalMap->reverse($mappedResult);
4✔
51
    }
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc