Skip to content

Conversation

@yyyyx4
Copy link
Member

@yyyyx4 yyyyx4 commented Jul 10, 2024

The points on an elliptic curve over a finite field form a group of rank up to $2$. In this patch we add support for passing two base points instead of just one to the .log() method, which will decompose the given point as a linear combination of the given points. This functionality is already available via the .abelian_group() method of the elliptic curve, but the latter is much slower since it relies only on generic-group algorithms and does not exploit the Weil pairing:

sage: F = GF((5, 60), 'a')
sage: E = EllipticCurve(F, [1, 1])
sage: A = E.abelian_group()
sage: P, Q = E.gens()[::-1]
sage: T = randrange(P.order()) * P + randrange(Q.order()) * Q
sage: %time A.discrete_log(T, [P,Q])
CPU times: user 47.4 s, sys: 74 ms, total: 47.5 s
Wall time: 47.6 s
(2474, 185989333112663415489036252299763200191)
sage: %time T.log([P, Q])
CPU times: user 1.43 s, sys: 3.34 ms, total: 1.44 s
Wall time: 1.44 s
(2474, 185989333112663415489036252299763200191)

⌛ Dependencies

@github-actions
Copy link

github-actions bot commented Jul 10, 2024

Documentation preview for this PR (built with commit 544556d; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@yyyyx4 yyyyx4 requested a review from GiacomoPope July 11, 2024 18:29
Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you, means I can stop hand-writing this function all the time myself haha.

@yyyyx4 yyyyx4 force-pushed the public/elliptic_curve_logarithms_2dim branch from 070db92 to eb6e4b3 Compare July 12, 2024 11:50
@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 12, 2024

Thanks! I applied your suggestions, added a new random test, and seem to have fixed the bugs that were caught by the random test.

@GiacomoPope
Copy link
Contributor

Cool! Thanks for making the changes.

@yyyyx4 yyyyx4 force-pushed the public/elliptic_curve_logarithms_2dim branch from 85ff4df to 1ec358a Compare August 1, 2024 06:04
@yyyyx4 yyyyx4 force-pushed the public/elliptic_curve_logarithms_2dim branch from 1ec358a to b9dbbb5 Compare August 1, 2024 23:05
@yyyyx4
Copy link
Member Author

yyyyx4 commented Aug 2, 2024

@GiacomoPope I've now simplified this following #38359 and I think it should be ready to be reviewed/merged.

Copy link
Contributor

@GiacomoPope GiacomoPope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment about comment, but this looks great.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Aug 5, 2024

The CI seems to be morally green.

@vbraun vbraun merged commit f369f65 into sagemath:develop Aug 10, 2024
@yyyyx4 yyyyx4 deleted the public/elliptic_curve_logarithms_2dim branch August 10, 2024 21:56
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 17, 2024
sagemathgh-38805: use specialized 2-dimensional .log() method in .matrix_on_subgroup()
    
This should be equivalent but faster (see sagemath#38347).

```sage
sage: E = EllipticCurve(GF((2^77-33, 2)), [1,0])
....: P, Q = E.gens()
....: pi = E.automorphisms()[-1]
....: %time pi.matrix_on_subgroup([P, Q])
```

Sage 10.5.beta7:
```
CPU times: user 13.8 s, sys: 32.5 ms, total: 13.8 s
```

This branch:
```
CPU times: user 48.1 ms, sys: 64 µs, total: 48.2 ms
```
    
URL: sagemath#38805
Reported by: Lorenz Panny
Reviewer(s): grhkm21
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 18, 2024
sagemathgh-38805: use specialized 2-dimensional .log() method in .matrix_on_subgroup()
    
This should be equivalent but faster (see sagemath#38347).

```sage
sage: E = EllipticCurve(GF((2^77-33, 2)), [1,0])
....: P, Q = E.gens()
....: pi = E.automorphisms()[-1]
....: %time pi.matrix_on_subgroup([P, Q])
```

Sage 10.5.beta7:
```
CPU times: user 13.8 s, sys: 32.5 ms, total: 13.8 s
```

This branch:
```
CPU times: user 48.1 ms, sys: 64 µs, total: 48.2 ms
```
    
URL: sagemath#38805
Reported by: Lorenz Panny
Reviewer(s): grhkm21
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 20, 2024
sagemathgh-38805: use specialized 2-dimensional .log() method in .matrix_on_subgroup()
    
This should be equivalent but faster (see sagemath#38347).

```sage
sage: E = EllipticCurve(GF((2^77-33, 2)), [1,0])
....: P, Q = E.gens()
....: pi = E.automorphisms()[-1]
....: %time pi.matrix_on_subgroup([P, Q])
```

Sage 10.5.beta7:
```
CPU times: user 13.8 s, sys: 32.5 ms, total: 13.8 s
```

This branch:
```
CPU times: user 48.1 ms, sys: 64 µs, total: 48.2 ms
```
    
URL: sagemath#38805
Reported by: Lorenz Panny
Reviewer(s): grhkm21
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 23, 2024
sagemathgh-38805: use specialized 2-dimensional .log() method in .matrix_on_subgroup()
    
This should be equivalent but faster (see sagemath#38347).

```sage
sage: E = EllipticCurve(GF((2^77-33, 2)), [1,0])
....: P, Q = E.gens()
....: pi = E.automorphisms()[-1]
....: %time pi.matrix_on_subgroup([P, Q])
```

Sage 10.5.beta7:
```
CPU times: user 13.8 s, sys: 32.5 ms, total: 13.8 s
```

This branch:
```
CPU times: user 48.1 ms, sys: 64 µs, total: 48.2 ms
```
    
URL: sagemath#38805
Reported by: Lorenz Panny
Reviewer(s): grhkm21
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 26, 2024
sagemathgh-38805: use specialized 2-dimensional .log() method in .matrix_on_subgroup()
    
This should be equivalent but faster (see sagemath#38347).

```sage
sage: E = EllipticCurve(GF((2^77-33, 2)), [1,0])
....: P, Q = E.gens()
....: pi = E.automorphisms()[-1]
....: %time pi.matrix_on_subgroup([P, Q])
```

Sage 10.5.beta7:
```
CPU times: user 13.8 s, sys: 32.5 ms, total: 13.8 s
```

This branch:
```
CPU times: user 48.1 ms, sys: 64 µs, total: 48.2 ms
```
    
URL: sagemath#38805
Reported by: Lorenz Panny
Reviewer(s): grhkm21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants