Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some brackets to the print statements so you can run it with Py3 #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions zksnark/code_to_r1cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def insert_var(arr, varz, var, used, reverse=False):
# Maps input, output and intermediate variables to indices
def get_var_placement(inputs, flatcode):
return ['~one'] + [x for x in inputs] + ['~out'] + [c[1] for c in flatcode if c[1] not in inputs and c[1] != '~out']


# Convert the flattened code generated above into a rank-1 constraint system
def flatcode_to_r1cs(inputs, flatcode):
Expand Down Expand Up @@ -206,19 +206,19 @@ def assign_variables(inputs, input_vars, flatcode):
elif x[0] == '/':
assignment[varz.index(x[1])] = grab_var(varz, assignment, x[2]) / grab_var(varz, assignment, x[3])
return assignment


def code_to_r1cs_with_inputs(code, input_vars):
inputs, body = extract_inputs_and_body(parse(code))
print 'Inputs'
print inputs
print 'Body'
print body
print('Inputs')
print(inputs)
print('Body')
print(body)
flatcode = flatten_body(body)
print 'Flatcode'
print flatcode
print 'Input var assignment'
print get_var_placement(inputs, flatcode)
print('Flatcode')
print(flatcode)
print('Input var assignment')
print(get_var_placement(inputs, flatcode))
A, B, C = flatcode_to_r1cs(inputs, flatcode)
r = assign_variables(inputs, input_vars, flatcode)
return r, A, B, C
Expand All @@ -228,11 +228,14 @@ def qeval(x):
y = x**3
return y + x + 5
""", [3])
print 'r'
print r
print 'A'
for x in A: print x
print 'B'
for x in B: print x
print 'C'
for x in C: print x
print('r')
print(r)
print('A')
for x in A:
print(x)
print('B')
for x in B:
print(x)
print('C')
for x in C:
print(x)