def importcomm(bn, nm=None): global vc_ctr, vc_ctx if nm is None: nm = str(vc_ctr[vc_ctx]) vc_ctr[vc_ctx] += 1 fl = options.get_block_file(bn) if not os.path.isfile(fl): raise IOError("Wire file " + fl + " for imported block \"" + bn + "\" does not exist") vals = [int(ln.strip()) for ln in open(fl)] vvals = vc_declare_block(nm, [runtime.PrivVal(val) for val in vals[:-1]], vals[-1]) if qape is not None: print("[external]", vc_ctx, nm, bn, file=qape) qape.flush() return vvals
def exportcomm(vals, bn, nm=None): global vc_ctr, vc_ctx if nm is None: nm = str(vc_ctr[vc_ctx]) vc_ctr[vc_ctx] += 1 valsp = [val if isinstance(val, runtime.LinComb) else runtime.PrivVal(val) for val in vals] rnd = random.randint(0,vc_p-1) vc_declare_block(nm, valsp, rnd) runqapinput.writecomm(bn, [val.value for val in valsp], rnd) runqapgen.ensure_mkey(-1, len(vals)) runqapinput.run(bn) if qape is not None: print("[external]", vc_ctx, nm, bn, file=qape) qape.flush() return valsp
def copyandaddrev(el): ret = runtime.PrivVal(el.value) argret.append((ret, el)) return ret
def copyandadd(el): ret = runtime.PrivVal(el.value) argret.append((el, ret)) return ret
def ensure_single(x): if len(x.lc.sig)==1: return x ret = runtime.PrivVal(x.value) ret.assert_eq(x) return ret