AGENT SKILL

number-theory-and-cryptography

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.

License 许可
MIT
最近更新
2026-10-17
Stars
★ 8
Forks
1

01 前言 Front Matter

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.

02 资源文件 2

03 SKILL.md 正文

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.

04 同仓库更多 Skills

hamzabellouch
hamzabellouch/agent-skills

security-audit

Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).

★ 8
hamzabellouch
hamzabellouch/agent-skills

malware-analysis-reversing

Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static/dynamic binary analysis, memory forensics, and YARA detection rule authoring.

★ 8
hamzabellouch
hamzabellouch/agent-skills

application-security-pentesting

Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST/DAST pipeline integration, secure code review, threat modeling, and defensive security posture.

★ 8
hamzabellouch
hamzabellouch/agent-skills

oauth2-oidc-security-flows

Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.

★ 8
hamzabellouch
hamzabellouch/agent-skills

jwt-session-management-hardening

Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256/EdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.

★ 8
hamzabellouch
hamzabellouch/agent-skills

soc2-compliance-automation

Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI/CD security gates.

★ 8