Skip to content

Commit

Permalink
Merge pull request #20 from MartKro/graycode
Browse files Browse the repository at this point in the history
Graycode reimplementation and ecclvl cmake change
  • Loading branch information
Daniel D authored Aug 27, 2019
2 parents a596166 + d084930 commit 985354c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@ add_library(encrypto_utils
${PROJECT_NAME}/thread.cpp
${PROJECT_NAME}/timer.cpp
${PROJECT_NAME}/utils.cpp
${PROJECT_NAME}/graycode.cpp
)
add_library(ENCRYPTO_utils::encrypto_utils ALIAS encrypto_utils)

target_compile_features(encrypto_utils PUBLIC cxx_std_17)
target_compile_options(encrypto_utils PRIVATE "-Wall" "-Wextra")
#Maybe it is better to create a ecc-pk-crypti.h.in file, since the ecclvl is only needed there
target_compile_definitions(encrypto_utils PUBLIC ECCLVL=${ecclvl})

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/ENCRYPTO_utils/cmake_constants.h.in"
"${PROJECT_BINARY_DIR}/include/cmake_constants.h"
)

target_include_directories(encrypto_utils
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
)


Expand Down
2 changes: 2 additions & 0 deletions src/ENCRYPTO_utils/cmake_constants.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//the security parameter for public crypto
#define ECCLVL @ecclvl@
1 change: 1 addition & 0 deletions src/ENCRYPTO_utils/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "typedefs.h"
#include <cstdint>
#include <cmake_constants.h>

#define BATCH
//#define FIXED_KEY_AES_HASHING
Expand Down
45 changes: 45 additions & 0 deletions src/ENCRYPTO_utils/graycode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
\file graycode.cpp
\author Martin Kromm<[email protected]>
\copyright ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
Copyright (C) 2019 ENCRYPTO Group, TU Darmstadt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ABY is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
\brief Gray-Code implementation
*/

#include "./graycode.h"
#include <stdlib.h>

uint32_t* BuildGrayCode(uint32_t length) {
uint32_t* gray_code = (uint32_t*) malloc(sizeof(uint32_t) * length);
for(uint32_t i = 0; i < length; ++i) {
gray_code[i] = i ^ (i >> 1);
}
return gray_code;
}

uint32_t* BuildGrayCodeIncrement(uint32_t length) {
uint32_t* gray_code_increment = (uint32_t*) malloc(sizeof(uint32_t) * length);
for(uint32_t i = 0; i < length; ++i) {
gray_code_increment[i] = 0;
}
uint32_t length_inc = 2;
while(length_inc < length) {
uint32_t length_count = length_inc - 1;
while(length_count <= length) {
(gray_code_increment[length_count])++;
length_count += length_inc;
}
length_inc = length_inc << 1;
}
return gray_code_increment;
}
22 changes: 22 additions & 0 deletions src/ENCRYPTO_utils/graycode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
\file graycode.h
\author Martin Kromm<[email protected]>
\copyright ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
Copyright (C) 2019 ENCRYPTO Group, TU Darmstadt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ABY is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
\brief Gray-Code implementation
*/

#include <stdint.h>

uint32_t* BuildGrayCode(uint32_t length);
uint32_t* BuildGrayCodeIncrement(uint32_t length);

0 comments on commit 985354c

Please sign in to comment.