~edwargix/tallyard

92ab9170be13e860a286efd10748dd28a6fc6f57 — David Florness 2 years ago 4f88a4a
Close files used in marshalling
1 files changed, 4 insertions(+), 0 deletions(-)

M election/marshal.go
M election/marshal.go => election/marshal.go +4 -0
@@ 30,6 30,7 @@ func NewProvingKeyFile(fileID string, pk groth16.ProvingKey) *ProvingKeyFile {
		log.Errorf("couldn't open file %s; this proving key will be discarded upon exit: %s", filePath, err)
		return &ProvingKeyFile{"", pk}
	}
	defer file.Close()
	_, err = pk.WriteTo(file)
	if err != nil {
		log.Errorf("couldn't write proving key to file %s; this proving will be discarded upon exit: %s", filePath, err)


@@ 52,6 53,7 @@ func (provingKey *ProvingKeyFile) Pk() groth16.ProvingKey {
		log.Errorf("couldn't open proving key file %s: %s", filePath, err)
		return nil
	}
	defer file.Close()
	pk := groth16.NewProvingKey(ecc.BLS12_381)
	_, err = pk.ReadFrom(file)
	if err != nil {


@@ 76,6 78,7 @@ func NewVerifyingKeyFile(vk groth16.VerifyingKey) *VerifyingKeyFile {
		log.Errorf("couldn't open file %s; this verifying key will be discarded upon exit: %s", filePath, err)
		return &VerifyingKeyFile{"", vk}
	}
	defer file.Close()
	_, err = vk.WriteTo(file)
	if err != nil {
		log.Errorf("couldn't write verifying key to file %s; this proving will be discarded upon exit: %s", filePath, err)


@@ 98,6 101,7 @@ func (verifyingKey *VerifyingKeyFile) Vk() groth16.VerifyingKey {
		log.Errorf("couldn't open verifying key file %s: %s", filePath, err)
		return nil
	}
	defer file.Close()
	vk := groth16.NewVerifyingKey(ecc.BLS12_381)
	_, err = vk.ReadFrom(file)
	if err != nil {