C 521 - Homomorphic Encryption With SEAL (30 Pts Extra)
C 521 - Homomorphic Encryption With SEAL (30 Pts Extra)
Purpose
To run a very basic example of homomorphic encryption: a system that performs mathematical operations on encrypted data without ever decrypting
it.
Install Git
On your Windows server, in Firefox, go to
https://git-scm.com/download/win
Save the file. Double-click it and install Git with the default options.
In the Visual Studio Installer, on the Available tab, in the Visual Studio Community 2019 section, click the Install button.
On the Workloads tab, check ".NET desktop development", "Desktop development with C++", and "Universal Windows Platform development",
as shown below.
WHen it's done, a "Visual Studio" box pops up asking you to connect to your developer services.
https://samsclass.info/141/proj/C521.htm 1/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
In the "Start with a familiar environment" page, at the lower right, click the "Start Visual Studio" button.
Run as Administrator
Close Visual Studio.
https://samsclass.info/141/proj/C521.htm 2/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Right-click "Visual Studion 2019", point to More, and click "Run as Administrator".
In the Clone a repository page, enter this Repository Location, as shown below:
https://github.com/microsoft/SEAL.git
The SEAL code appears on the right side, in the Solution Explorer, as shown below:
https://samsclass.info/141/proj/C521.htm 3/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Building SEAL
In Solution Explorer, expand native. Click SEAL to select it, as shown below.
At the top center, click the leftmost white drop-down list box containing the word "Debug" and change it to Release.
https://samsclass.info/141/proj/C521.htm 4/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
At the bottom, the Output pane shows the build progress. When it's done, it shows "Build: 1 succeeded" as shown below.
Note the path to the "seal.lib" file, outlined in red in the image below.
C:\Users\cnit_123d\source\repos\SEAL\lib\x64\Release
Open Windows Explorer and browse to that location. Notice the path to the "src" folder, inside the "native" folder, as shown below.
https://samsclass.info/141/proj/C521.htm 5/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Writing an App
In Visual Studio, at the top left, click File, "Close Solution".
In the "Create a new project" box, in the top center, select a Language of C++.
https://samsclass.info/141/proj/C521.htm 6/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
In the "Configure your new project" box, name your project SEAL1 and click Create.
https://samsclass.info/141/proj/C521.htm 7/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
On the right side, in Solution Explorer, right-click SEAL1 and click Add..., "New Item".
At the bottom, enter a name of Example.cpp, as shown below, and click the Add button.
https://samsclass.info/141/proj/C521.htm 8/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
In the SEAL1 Property Pages box, at the top, select "All Configurations" and "All Platforms", as shown below.
In the left pane, expand C/C++ and click General on the first line that appears.
In the "Additional Include Directories", enter the path to the "src" folder you noted earlier. On my machine, the path was:
C:\Users\cnit_123d\source\repos\SEAL\native\src
as shown below.
In the "Additional Library Directories", enter the path to your "lin" folder, followed by \$(Platform)\$(Configuration)
https://samsclass.info/141/proj/C521.htm 9/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
On my machine, the path was:
C:\Users\cnit_123d\source\repos\SEAL\lib\$(Platform)\$(Configuration)
as shown below.
In the left pane, expand Linker and click Input on the second line that appears.
In the "Additional Dependencies", add seal.lib; to the start of the list, as shown below.
Set the "C++ Language Standard", to "ISO C++17 Standard (std:c++17)", as shown below.
https://samsclass.info/141/proj/C521.htm 10/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
#include "seal/seal.h"
#include <iostream>
int main()
{
EncryptionParameters params(scheme_type::BFV);
return 0;
}
https://samsclass.info/141/proj/C521.htm 11/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
At the bottom, the Output pane shows the build progress. When it's done, it shows "Build: 1 succeeded".
In the "What would you like to do?" page, under the "Open recent" header, click SEAL.sln, as shown below.
https://samsclass.info/141/proj/C521.htm 12/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Building Seal_C
On the right side, in Solution Explorer, right-click SEAL_C and click Build.
Building SEALExamples
On the right side, in Solution Explorer, right-click SealExamples and click Build.
When you see the "Build: 1 succeeded" message, the build is done.
Launching SEALExamples
In Windows Explorer, navigate to the sealexamples.exe file, as shown below, and double-click it.
https://samsclass.info/141/proj/C521.htm 13/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
Now you can run the examples while reading the source code, as shown below.
Run the first example and read the comments and the output. Find the flags below as you go.
https://samsclass.info/141/proj/C521.htm 14/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
https://samsclass.info/141/proj/C521.htm 15/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
https://samsclass.info/141/proj/C521.htm 16/17
30/09/2022 18:58 C 521: Homomorphic Encryption with SEAL (30 pts extra)
References
Installing Microsoft SEAL on Windows
Podcast 3 | Homomorphic Encryption with Microsoft Open Source "SEAL" Library
Microsoft SEAL
https://samsclass.info/141/proj/C521.htm 17/17