Skip to content
Back to skills

Number Theory And Cryptography

ASecurity

Solve number theory problems: divisibility, primes, gcd, modular arithmetic, congruences, CRT, Fermat/Euler theorems, quadratic residues, Diophantine equations, continued fractions, RSA and elliptic-curve cryptography basics. Includes a Python helper script. Use for integer, prime, modular and cryptography questions.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 9, 2026
ai-agentspythongosecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add hamzabellouch/agent-skills --skill number-theory-and-cryptography --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Number Theory And Cryptography?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Number Theory And Cryptography
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hamzabellouch-number-theory-and-cryptography/badge)](https://www.skillsdirectory.com/skills/hamzabellouch-number-theory-and-cryptography)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: number-theory-and-cryptography
description: "Solve number theory problems: divisibility, primes, gcd, modular arithmetic, congruences, CRT, Fermat/Euler theorems, quadratic residues, Diophantine equations, continued fractions, RSA and elliptic-curve cryptography basics. Includes a Python helper script. Use for integer, prime, modular and cryptography questions."
---

# Number Theory & Cryptography

## Basics
- Fundamental theorem of arithmetic; gcd via Euclid; Bezout ax + by = gcd (extended Euclid); lcm = ab/gcd.
- Modular arithmetic: a == b (mod n); inverse of a mod n exists iff gcd(a,n) = 1; solve ax == b via inverse.
- Chinese Remainder Theorem for pairwise coprime moduli.
- Fermat: a^(p-1) == 1 (mod p) for p prime, p not dividing a. Euler: a^phi(n) == 1 for gcd(a,n) = 1; phi(n) = n prod (1 - 1/p). Wilson: (p-1)! == -1 (mod p).
- Multiplicative functions: tau, sigma, mu, phi; Moebius inversion; Dirichlet convolution.
- Order of an element, primitive roots (exist mod 1, 2, 4, p^k, 2p^k).
- Quadratic residues: Legendre symbol, Euler's criterion, quadratic reciprocity, Jacobi symbol; sums of two squares (p == 1 mod 4), Lagrange four squares.
- Diophantine: linear ax + by = c solvable iff gcd | c; Pythagorean triples (m^2 - n^2, 2mn, m^2 + n^2); Pell x^2 - Dy^2 = 1 via continued fractions; Fermat's Last Theorem (Wiles); infinite descent; lifting-the-exponent lemma; Zsigmondy.
- Valuations: v_p(n!) = sum floor(n/p^k) (Legendre).

## Primes
- Sieve of Eratosthenes; primality tests: Miller-Rabin (probabilistic), AKS (deterministic polynomial); prime number theorem pi(x) ~ x/ln x; Dirichlet's theorem on primes in progressions; twin prime, Goldbach, Riemann hypothesis as open problems.

## Cryptography
- RSA: n = pq, e coprime to phi(n), d = e^{-1} mod phi(n); encrypt c = m^e mod n, decrypt m = c^d mod n. Security rests on factoring hardness; use OAEP padding and 2048+ bit keys in practice.
- Diffie-Hellman key exchange, discrete log problem; ElGamal; elliptic curves y^2 = x^3 + ax + b over F_p (group law), ECDH/ECDSA; post-quantum lattice-based (Kyber, Dilithium) as Shor-resistant alternatives; hash functions and signatures.
- Never implement your own crypto in production; use vetted libraries.

## Script
`scripts/number_theory.py`: egcd, modular inverse, CRT, Miller-Rabin, factorization (Pollard rho), phi, primitive root, RSA toy demo.

Files in this skill

  • SKILL.md2.3 KB
  • scripts/number_theory.py2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.