discretelog

Solve discrete logarithms g^x ≡ y (mod P) with quantum period-finding.

30|2|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-skills --skill discretelog
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: discretelog
Source: https://github.com/unitarylab/quantum-skills/tree/main/algorithms/cryptography/discretelog
Command: npx skills add https://github.com/unitarylab/quantum-skills --skill discretelog

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires unitarylab, and includes scripts (resource) components.

What problem does it solve?

Solve the discrete logarithm problem g^x ≡ y (mod P) using a quantum period-finding approach; the quantum algorithm runs in polynomial time relative to the bit-length of P.

Core Features & Use Cases

  • Two-register QPE circuit for DLP on prime modulus P.
  • Classical post-processing to recover r and x from measurements.
  • Provides automated circuit diagrams and result visualization.

Quick Start

Execute the provided example with g=3, y=6, P=7 to recover x.

Frequently Asked Questions about discretelog

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I solve the discrete logarithm problem using Shor's algorithm?

To solve the discrete logarithm problem using Shor's algorithm, this Skill constructs a two-register QPE circuit with an IQFT to find the period, then applies classical post-processing via continued fractions to recover the exponent x from measured indices.

What is a two-register QPE circuit and how does it work for modular arithmetic?

A two-register QPE circuit estimates the phase of a modular exponentation unitary. It works by applying an Inverse Quantum Fourier Transform (IQFT) to extract phase indices, which classical post-processing then maps to the discrete logarithm solution.

How do I calculate discrete logarithms for a prime modulus P in polynomial time?

You can calculate discrete logarithms for a prime modulus P in polynomial time by running a quantum period-finding simulation. The Skill automates the circuit construction and result visualization for problems formatted as g^x ≡ y (mod P).

Can I use this quantum algorithm simulation if my base and target are not coprime to P?

No, you cannot use this quantum algorithm simulation if your base g and target y are not coprime to P. The quantum period-finding approach strictly requires both g and y to be coprime to the prime modulus P to function correctly.

Does the discrete logarithm quantum simulation handle classical post-processing automatically?

Yes, the discrete logarithm quantum simulation handles classical post-processing automatically. It executes a built-in routine to recover the order r and extract the discrete logarithm x from the measured indices using continued fractions.

What are the limitations of using quantum period finding for cryptography research?

A key limitation of using quantum period finding for cryptography research here is simulation scale; while the algorithm runs in polynomial time relative to the bit-length of P, circuit simulation requires valid coprime inputs and proper two-register QPE setup.