-
Actions
Automate any workflow
-
Packages
Host and manage packages
-
Security
Find and fix vulnerabilities
-
Codespaces
Instant dev environments
-
Copilot
Write better code with AI
-
Code review
Manage code changes
-
Issues
Plan and track work
-
Discussions
Collaborate outside of code
- Explore
- All features
- Documentation
- GitHub Skills
- Changelog
-
- By Plan
- Enterprise
- Teams
- Compare all
- By Solution
- CI/CD & Automation
- DevOps
- DevSecOps
- Case Studies
- Customer Stories
- Resources
-
GitHub Sponsors
Fund open source developers
-
The ReadME Project
GitHub community articles
- Repositories
- Topics
- Trending
- Collections
-
- Pricing
# Basics of Elliptic Curve Cryptography implementation on Python import collections def inv[n, q]: """div on PN modulo a/b mod q as a * inv[b, q] mod q >>> assert n * inv[n, q] % q == 1 """ for i in range[q]: if [n * i] % q == 1: return i pass assert False, "unreached" pass def sqrt[n, q]: """sqrt on PN modulo: returns two numbers or exception if not exist >>> assert [sqrt[n, q][0] ** 2] % q == n >>> assert [sqrt[n, q][1] ** 2] % q == n """ assert n 1, self.add[m2, m2] pass # [ref] O[n] add #for i in range[n]: # r = self.add[r, p] # pass return r def order[self, g]: """order of point g >>> o = ec.order[g] >>> assert ec.is_valid[a] and ec.mul[a, o] == ec.zero >>> assert o