-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencoder.cpp
46 lines (36 loc) · 1.23 KB
/
encoder.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
#include <stdint.h>
#include <memory>
#include <seal/encoder.h>
#include <seal-c/encoder.h>
#include "small_modulus.hpp"
#include "plaintext.hpp"
#include "encoder.hpp"
void
SEAL_AbstractIntegerEncoder_destroy (SEALAbstractIntegerEncoderRef encoder)
{
delete seal_c::wrap::unwrap (encoder);
}
SEALPlaintextRef
SEAL_AbstractIntegerEncoder_encode_int64 (SEALAbstractIntegerEncoderRef encoder, int64_t i)
{
auto p = std::make_unique <seal::Plaintext> (seal_c::wrap::unwrap (encoder)->encode (i));
return seal_c::wrap::wrap (p.release ());
}
SEALPlaintextRef
SEAL_AbstractIntegerEncoder_encode_int32 (SEALAbstractIntegerEncoderRef encoder, int32_t i)
{
auto p = std::make_unique <seal::Plaintext> (seal_c::wrap::unwrap (encoder)->encode (i));
return seal_c::wrap::wrap (p.release ());
}
int64_t
SEAL_AbstractIntegerEncoder_decode_int64 (SEALAbstractIntegerEncoderRef encoder, SEALPlaintextRef plaintext)
{
using seal_c::wrap::unwrap;
return unwrap (encoder)->decode_int64 (*unwrap (plaintext));
}
SEALIntegerEncoderRef
SEAL_IntegerEncoder_construct (SEALSmallModulusRef plain_modulus, uint64_t base)
{
auto p = std::make_unique <seal::IntegerEncoder> (*seal_c::wrap::unwrap (plain_modulus), base);
return seal_c::wrap::wrap (p.release ());
}