Skip to content
Snippets Groups Projects
Commit 06b2c404 authored by Dmitriy Gerasimov's avatar Dmitriy Gerasimov
Browse files

[+] Hash funcsion for Keccak, for mining and declarations for HashFusion

parent 8fa26b64
No related branches found
No related tags found
1 merge request!24Support 3689
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define _DAP_MATH_OPS_H_ #define _DAP_MATH_OPS_H_
#include <stdint.h> #include <stdint.h>
#include "monero_crypto/common/int-util.h"
#if defined(__GNUC__) ||defined (__clang__) #if defined(__GNUC__) ||defined (__clang__)
#if __SIZEOF_INT128__ == 16 #if __SIZEOF_INT128__ == 16
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project (dap_crypto) project (dap_crypto)
set(CRYPT_SRCS dap_enc.c dap_enc_aes.c dap_enc_newhope.c dap_enc_key.c ) set(CRYPTO_SRCS
dap_enc.c
dap_enc_aes.c
dap_enc_newhope.c
dap_enc_key.c
dap_hash.c
dap_hash_fusion.c
)
set(CRYPTO_HEADERS
dap_enc.h
dap_enc_aes.h
dap_enc_newhope.h
dap_enc_key.h
dap_hash.h
dap_hash_fusion.h
dap_hash_slow.h
dap_hash_keccak.h
)
add_subdirectory(monero_crypto) add_subdirectory(monero_crypto)
...@@ -9,7 +33,7 @@ include_directories("${dap_core_INCLUDE_DIRS}") ...@@ -9,7 +33,7 @@ include_directories("${dap_core_INCLUDE_DIRS}")
include_directories("${monero_crypto_INCLUDE_DIRS}") include_directories("${monero_crypto_INCLUDE_DIRS}")
add_definitions ("${dap_core_DEFINITIONS}") add_definitions ("${dap_core_DEFINITIONS}")
add_definitions ("${monero_crypto_DEFINITIONS}") add_definitions ("${monero_crypto_DEFINITIONS}")
add_library(${PROJECT_NAME} STATIC ${CRYPT_SRCS} ${crypto_sources} ) add_library(${PROJECT_NAME} STATIC ${CRYPTO_SRCS} ${CRYPTO_HEADERS} )
set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE)
set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE)
#include "dap_common.h"
#include "dap_hash.h"
#define LOG_TAG "dap_hash"
#ifndef _DAP_HASH_H_
#define _DAP_HASH_H_
#include <stddef.h>
#include "dap_hash_slow.h"
#include "dap_hash_keccak.h"
typedef enum dap_hash_type {
DAP_HASH_TYPE_KECCAK = 0,
DAP_HASH_TYPE_SLOW_0 = 1,
} dap_hash_type_t;
inline void dap_hash(void * a_data_in, size_t a_data_in_size,
void * a_data_out, size_t a_data_out_size,
dap_hash_type_t a_type ){
switch (a_type){
case DAP_HASH_TYPE_KECCAK:
dap_hash_keccak(a_data_in,a_data_in_size, a_data_out,a_data_out_size);
break;
case DAP_HASH_TYPE_SLOW_0:
if( a_data_out_size>= dap_hash_slow_size() ){
dap_hash_slow(a_data_in,a_data_in_size,(char*) a_data_out);
}
break;
}
}
#endif
#include "dap_common.h"
#include "dap_hash_fusion.h"
#define LOG_TAG "dap_hash_fusion"
#ifndef _DAP_HASH_FUSION_H_
#define _DAP_HASH_FUSION_H_
#endif
#pragma once
#include "keccak.h"
inline void dap_hash_keccak(const void * a_in, size_t a_in_size, void * a_out, size_t a_out_size)
{
keccak((const uint8_t*) a_in,a_in_size, (uint8_t *) a_out, a_out_size );
}
#ifndef _DAP_HASH_SLOW_H_
#define _DAP_HASH_SLOW_H_
#include "hash-ops.h"
#define DAP_HASH_SLOW_SIZE HASH_SIZE
/**
* @brief dap_hash_slow
* @param a_in
* @param a_in_length
* @param a_out Must be allocated with enought space
*/
inline void dap_hash_slow(const void *a_in, size_t a_in_length, char * a_out)
{
cn_slow_hash(a_in,a_in_length,a_out);
}
inline size_t dap_hash_slow_size() { return DAP_HASH_SLOW_SIZE; }
//cn_slow_hash(data, length, reinterpret_cast<char *>(&hash));
#endif
// Copyright (c) 2017-2018, The Demlabs Inc. Project
// Copyright (c) 2014-2017, The Monero Project // Copyright (c) 2014-2017, The Monero Project
// //
// All rights reserved. // All rights reserved.
...@@ -27,10 +28,10 @@ ...@@ -27,10 +28,10 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once #pragma once
#if !defined(__cplusplus)
//#if !defined(__cplusplus)
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -71,7 +72,7 @@ static_assert(sizeof(union hash_state) == 200, "Invalid structure size"); ...@@ -71,7 +72,7 @@ static_assert(sizeof(union hash_state) == 200, "Invalid structure size");
void hash_permutation(union hash_state *state); void hash_permutation(union hash_state *state);
void hash_process(union hash_state *state, const uint8_t *buf, size_t count); void hash_process(union hash_state *state, const uint8_t *buf, size_t count);
#endif //#endif
enum { enum {
HASH_SIZE = 32, HASH_SIZE = 32,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment