-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyutil.cpp
56 lines (46 loc) · 1.81 KB
/
keyutil.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Created by scwang on 2023/11/12.
//
#include "keyutil.h"
#include <fstream>
namespace util {
void save_public_key(const sigma::PublicKey& publicKey, const std::string& path) {
std::ofstream pkofs(path, std::ios::binary);
publicKey.save(pkofs);
pkofs.close();
}
void save_secret_key(const sigma::SecretKey& secretKey, const std::string& path) {
std::ofstream pkofs(path, std::ios::binary);
secretKey.save(pkofs);
pkofs.close();
}
void save_galois_keys(const sigma::GaloisKeys& galoisKeys, const std::string& path) {
std::ofstream gkofs(path, std::ios::binary);
galoisKeys.save(gkofs);
gkofs.close();
}
void load_public_key(const sigma::SIGMAContext &context,
sigma::PublicKey &public_key,
const std::string &public_key_path) {
std::ifstream pkifs(public_key_path, std::ios::binary);
public_key.load(context, pkifs);
pkifs.close();
std::cout << "Public key loaded successfully." << std::endl;
}
void load_secret_key(const sigma::SIGMAContext &context,
sigma::SecretKey &secret_key,
const std::string &secret_key_path) {
std::ifstream skifs(secret_key_path, std::ios::binary);
secret_key.load(context, skifs);
skifs.close();
std::cout << "Secret key loaded successfully." << std::endl;
}
void load_galois_key(const sigma::SIGMAContext &context,
sigma::GaloisKeys &galois_keys,
const std::string &galois_keys_path) {
std::ifstream gkifs(galois_keys_path, std::ios::binary);
galois_keys.load(context, gkifs);
gkifs.close();
std::cout << "Secret key loaded successfully." << std::endl;
}
} // util