MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / write_bytes

Method write_bytes

Compiler/program.py:468–512  ·  view source on GitHub ↗

Write all non-empty threads and schedule to files.

(self)

Source from the content-addressed store, hash-verified

466 return max(x.req_bit_length[t] for x in self.tapes)
467
468 def write_bytes(self):
469
470 """Write all non-empty threads and schedule to files."""
471
472 nonempty_tapes = [t for t in self.tapes]
473
474 sch_filename = self.programs_dir + "/Schedules/%s.sch" % self.name
475 sch_file = open(sch_filename, "w")
476 print("Writing to", sch_filename)
477 sch_file.write(str(self.max_par_tapes()) + "\n")
478 sch_file.write(str(len(nonempty_tapes)) + "\n")
479 sch_file.write(" ".join("%s:%d" % (tape.name, len(tape))
480 for tape in nonempty_tapes) + "\n")
481 sch_file.write("1 0\n")
482 sch_file.write("0\n")
483 sch_file.write(" ".join(sys.argv) + "\n")
484 req = self.required_bit_length("p")
485 if self.options.ring:
486 sch_file.write("R:%s" % self.options.ring)
487 elif self.options.prime:
488 sch_file.write("p:%s" % self.options.prime)
489 else:
490 sch_file.write("lgp:%s" % req)
491 sch_file.write("\n")
492 sch_file.write("opts: %s\n" % " ".join(self.relevant_opts))
493 sch_file.write("sec:%d\n" % self.used_security)
494 req2 = set(x.req_bit_length["2"] for x in self.tapes)
495 req2.add(0)
496 assert len(req2) <= 2
497 if req2:
498 sch_file.write("lg2:%s" % max(req2))
499 sch_file.write("\n")
500 exp = self.expected_communication()
501 if exp:
502 sch_file.write(
503 "online:%d offline:%d n_parties:%d\n" % (
504 exp.sanitize() + (exp.n_parties,)))
505 else:
506 sch_file.write('no expections\n')
507 sch_file.close()
508 h = hashlib.sha256()
509 for tape in self.tapes:
510 tape.write_bytes()
511 h.update(tape.hash)
512 print('Hash:', h.hexdigest())
513
514 def finalize_tape(self, tape):
515 if not tape.purged:

Callers 1

finalizeMethod · 0.95

Calls 12

max_par_tapesMethod · 0.95
required_bit_lengthMethod · 0.95
printFunction · 0.85
maxFunction · 0.85
closeMethod · 0.80
writeMethod · 0.45
joinMethod · 0.45
addMethod · 0.45
sanitizeMethod · 0.45
write_bytesMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected