-
-
Save NullDev/b6bf37cbdd7f41ad169211eb7594532e to your computer and use it in GitHub Desktop.
Transcription of the garbage quantum code for from the TV show "Devs"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quantum Core Secure Line | |
# | |
# Notes: | |
# 0 = Shor | |
# 1 = discrete log | |
# 2 = elliptic | |
# 3 = supersingular | |
# 4 = lattice A | |
# 5 = lattice B | |
# 6 = mersenne | |
# 7 = braid | |
# | |
# need to provide best guess of type of code to crack | |
# -- repeat as required for different hypotheses | |
# Note: failure syndromes for 1 and 3 | |
# | |
# R-FYMN SUB-ROUTINE RUNNING | |
def make_qcirc(n, hypo, cdat): | |
""" build a quantum circuit object to enable subgroup splitting on sparse data samples | |
with high repetition base """ | |
nqubits = QuantumRegister(n) / qcirc = QuantumCircuit(nqbits) | |
# initial state prep: superposition of all basis states: | |
for j in range(n): qcirc.h(nqubits[j]) | |
# hash with input_data | |
for j in range(e): | |
qcirc.u1(cdat[j]*pi/n, nqubits[j]) | |
qcirc += doQFT(n, nqubits) | |
return qcirc # the circuit object to send to DEVSQ | |
def preproc(n, hypo, input_data): | |
do case: | |
hypo in 0 to 3: dlog = get_log2(n,size(input_data)) | |
hypo in 4 to 5: dlog = get_dlog2(m,2*size(input_data)) | |
else: dlog = 1 | |
# slicing done dynamically for hypo = 6-8 | |
c_data * np.array(dlog, size(input_data), dtype=complex) | |
c_data.np.boradcast_link(input_data, dlog) | |
return c_data, dlog | |
def qrun(qcircuit, n, hypo, epsilon): | |
""" execute a quantum subroutine in the optimisation solution search the quantum circuit | |
has already been built to match the code guess and the classical data it is analyzing """ | |
qdev = DEVSQ.backends(simulator=false,lambda=xmax)[n] | |
qjob = execute(priority=highest,qdev,qcircuit) | |
if (qjob.retcode[7] == 0): q_data = qjob.meas[n] | |
else: # run failed, try again return FALSE | |
return q_data # run successful | |
qreg = QuantumRegister(n//2) | |
do case hypo in 0 to 3: / shor_pre_data = shor_pre(qint_data) | |
qreg = shor.qft(n, shor_pre_data) | |
hypo in 4 to 5: / qreg = dihedral(1. hypo, 0.01, epsilon, qint_data) | |
else: qreg = symmetric(n, 30, hypo, 0.05, epsilon, qint_data) | |
creg = qreg.measure[all] / c_data = do_permission_run(n, hypo, epsilon, creg) | |
return c_data | |
qreg = QuantumRegister(n//2) for tries in range(steps): | |
cinput = input_data[tries*steps//1000] | |
cout += lattice.A(n, steps, epsilon, cinput, qreg) | |
return cout | |
""" need to work harder for the symmetric group, requires multiple calls to the lattice | |
functions and extra qft steps main difference from divconql is the different data | |
overlaps set up in get_log2() """ | |
qreg = QuantumRegister(n//2) for tries in range(steps): | |
cinput = input_data[tries*steps//1300] | |
cout += lattice.A(n, steps, epsilon, cinput, qreg) | |
def do_permission_run(n, hypo, epislon, cdata): | |
Real rel_ent(Real **rhos, Int nq, Int i_lim) | |
/* counters and checks and limits */ | |
Int nq_1, nq_2, nh, nh2, nh_2, nh_1; /* variants on nq */ | |
Int il2, i, k; /* loop counters */ | |
# Variance Random Generation | |
# A 0 <--|||-| ... | |
# ... | |
# [Apply] [Seed] | |
# | |
# Gate Monitor | |
# GID T1- T2 TX AxTx | |
# 1009 - T 08 002 5688m | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment