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

famoser / elliptic / 16579587392

28 Jul 2025 08:29PM UTC coverage: 99.371% (+3.8%) from 95.58%
16579587392

push

github

famoser
fix: Ensure only zero-point converted to infinity

1 of 1 new or added line in 1 file covered. (100.0%)

7 existing lines in 2 files now uncovered.

1421 of 1430 relevant lines covered (99.37%)

10.81 hits per line

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

76.92
/src/Serializer/PointDecoder/MGPointDecoder.php
1
<?php
2

3
namespace Famoser\Elliptic\Serializer\PointDecoder;
4

5
use Famoser\Elliptic\Primitives\Curve;
6
use Famoser\Elliptic\Primitives\CurveType;
7
use Famoser\Elliptic\Serializer\PointDecoder\Traits\FromCoordinatesTrait;
8
use Famoser\Elliptic\Serializer\PointDecoder\Traits\FromXCoordinateTrait;
9
use Famoser\Elliptic\Serializer\SEC\SECPointDecoderInterface;
10

11
class MGPointDecoder implements SECPointDecoderInterface
12
{
13
    use FromCoordinatesTrait;
14
    use FromXCoordinateTrait;
15

16
    public function __construct(private readonly Curve $curve)
7✔
17
    {
18
        // check allowed to use this decoder
19
        $check = $curve->getType() === CurveType::Montgomery;
7✔
20
        if (!$check) {
7✔
21
            throw new \AssertionError('Cannot use this decoder with the chosen curve.');
1✔
22
        }
23
    }
24

25
    /**
26
     * calculate b * y^2
27
     */
28
    private function calculateLeftSide(\GMP $y): \GMP
4✔
29
    {
30
        return gmp_mul(
4✔
31
            $this->curve->getB(),
4✔
32
            gmp_pow($y, 2)
4✔
33
        );
4✔
34
    }
35

36
    /**
37
     * calculate x^3 + ax^2 + x
38
     */
39
    private function calculateRightSide(\GMP $x): \GMP
6✔
40
    {
41
        return gmp_add(
6✔
42
            gmp_add(
6✔
43
                gmp_powm($x, 3, $this->curve->getP()),
6✔
44
                gmp_mul(
6✔
45
                    $this->curve->getA(),
6✔
46
                    gmp_pow($x, 2)
6✔
47
                )
6✔
48
            ),
6✔
49
            $x
6✔
50
        );
6✔
51
    }
52

53
    /**
54
     * calculate (x^3 + ax^2 + x) / b
55
     */
UNCOV
56
    private function calculateAlpha(\GMP $x): \GMP
×
57
    {
UNCOV
58
        $right = $this->calculateRightSide($x);
×
UNCOV
59
        return gmp_mul(
×
UNCOV
60
            $right,
×
61
            /** @phpstan-ignore-next-line */
UNCOV
62
            gmp_invert($this->curve->getB(), $this->curve->getP())
×
UNCOV
63
        );
×
64
    }
65
}
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

© 2026 Coveralls, Inc