codegen.py 926 B

12345678910111213141516171819202122232425262728293031
  1. # Functions here are called from pism.py using getattr()
  2. # and the function name as a string.
  3. def witness(line, out, point):
  4. return \
  5. r"""let %s = ecc::EdwardsPoint::witness(
  6. cs.namespace(|| "%s"),
  7. %s.map(jubjub::ExtendedPoint::from))?;""" % (out, line, point)
  8. def assert_not_small_order(line, point):
  9. return '%s.assert_not_small_order(cs.namespace(|| "%s"))?;' % (point, line)
  10. def fr_as_binary_le(line, out, fr):
  11. return \
  12. r"""let %s = boolean::field_into_boolean_vec_le(
  13. cs.namespace(|| "%s"), %s)?;""" % (out, line, fr)
  14. def ec_mul_const(line, out, fr, base):
  15. return \
  16. r"""let %s = ecc::fixed_base_multiplication(
  17. cs.namespace(|| "%s"),
  18. &%s,
  19. &%s,
  20. )?;""" % (out, line, base, fr)
  21. def ec_add(line, out, a, b):
  22. return 'let %s = %s.add(cs.namespace(|| "%s"), &%s)?;' % (out, a, line, b)
  23. def emit_ec(line, point):
  24. return '%s.inputize(cs.namespace(|| "%s"))?;' % (point, line)