Skip to content

Commit

Permalink
updated to new cryptanalysislib version
Browse files Browse the repository at this point in the history
  • Loading branch information
Floyd committed Aug 20, 2024
1 parent 62f7837 commit ffe3a36
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion deps/cryptanalysislib
Submodule cryptanalysislib updated 234 files
6 changes: 3 additions & 3 deletions src/bjmm.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DECODING_BJMM_H
#define DECODING_BJMM_H

#include "matrix/binary_matrix.h"
#include "matrix/matrix.h"
#include "container/hashmap.h"
#include "popcount/popcount.h"
#include "math/bc.h"
Expand Down Expand Up @@ -120,8 +120,8 @@ class BJMM : public ISDInstance<uint64_t, isd> {
constexpr static SimpleHashMapConfig simpleHashMapConfigD2 {
HM2_bucketsize, HM2_nrbuckets, config.threads
};
using HM1 = SimpleHashMap<keyType, V1, simpleHashMapConfig, Hash<l_type, 0, l1>>;
using HM2 = SimpleHashMap<keyType, V2, simpleHashMapConfigD2, Hash<l_type, 0, l2>>;
using HM1 = SimpleHashMap<keyType, V1, simpleHashMapConfig, Hash<l_type, 0, l1, 2>>;
using HM2 = SimpleHashMap<keyType, V2, simpleHashMapConfigD2, Hash<l_type, 0, l2, 2>>;
HM1 *hm1; HM2 *hm2;

constexpr static ConfigEnumHashMap configEnum{config};
Expand Down
6 changes: 3 additions & 3 deletions src/fq/prange.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "combination/chase.h"
#include "helper.h"
#include "container/fq_vector.h"
#include "matrix/fq_matrix.h"
#include "matrix/matrix.h"
#include "list/list.h"
#include "list/enumeration/fq.h"
#include "thread/thread.h"
Expand Down Expand Up @@ -116,8 +116,8 @@ class FqPrange : public ISDInstance<uint64_t, config> {

/// start the iterations
bool found = G.template run
<std::nullptr_t, std::nullptr_t>
(nullptr, nullptr, 0, tid, nullptr, nullptr, &predicate);
<std::nullptr_t, std::nullptr_t, decltype(predicate)>
(nullptr, nullptr, 0, 0, tid, nullptr, nullptr, &predicate);

if (unlikely(found)) {
not_found = false;
Expand Down
2 changes: 1 addition & 1 deletion src/fq/sieving.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "helper.h"
#include "container/fq_vector.h"
#include "matrix/fq_matrix.h"
#include "matrix/matrix.h"
#include "list/list.h"
#include "list/enumeration/fq.h"
#include "sort.h"
Expand Down
10 changes: 5 additions & 5 deletions src/fq/stern.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include "helper.h"
#include "container/fq_vector.h"
#include "matrix/fq_matrix.h"
#include "matrix/matrix.h"
#include "list/list.h"
#include "list/enumeration/fq.h"
#include "sort.h"
#include "popcount/popcount.h"
#include "mitm.h"
Expand Down Expand Up @@ -51,7 +50,8 @@ class FqStern : public ISDInstance<uint64_t, isd> {
constexpr static uint32_t enum_length = (k + l) >> 1u;
constexpr static uint32_t enum_offset = k + l - enum_length;
constexpr static size_t list_size = compute_combinations_fq_chase_list_size<enum_length, q, p>();
using List = Parallel_List_FullElement_T<Element>;
// using List = Parallel_List_FullElement_T<Element>;
using List = List_T<Element>;
using Generator = ListEnumerateMultiFullLength<List, enum_length, q, p>;
Generator G;
List *L1, *L2;
Expand Down Expand Up @@ -130,12 +130,12 @@ class FqStern : public ISDInstance<uint64_t, isd> {
}

///
inline void init_list(const uint32_t tid) {
inline void init_list(const uint32_t tid) noexcept {
hm->clear();

/// this call simply inits the the list
G.template run <HM, decltype(Compress), std::nullptr_t>
(L1, L2, enum_offset, tid, hm, &Compress);
(L1, L2, enum_offset, 0, tid, hm, &Compress);
}

void find_collisions(const uint32_t tid) {
Expand Down
4 changes: 1 addition & 3 deletions src/fq/stern_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

#include "helper.h"
#include "container/fq_vector.h"
#include "matrix/fq_matrix.h"
#include "matrix/matrix.h"
#include "list/list.h"
#include "list/enumeration/fq.h"
#include "sort.h"
#include "popcount/popcount.h"
#include "mitm.h"
#include "isd.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mitm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <tuple>

#include "combination/chase.h"
#include "matrix/binary_matrix.h"
#include "matrix/matrix.h"
#include "container/hashmap.h"
#include "popcount/popcount.h"
#include "math/bc.h"
Expand Down
2 changes: 1 addition & 1 deletion src/prange.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cstdint>

#include "matrix/binary_matrix.h"
#include "matrix/matrix.h"
#include "container/hashmap.h"
#include "popcount/popcount.h"
#include "math/bc.h"
Expand Down
10 changes: 6 additions & 4 deletions src/stern.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

#include <cstdint>

#include "matrix/binary_matrix.h"
#include "matrix/matrix.h"
#include "container/hashmap.h"
#include "popcount/popcount.h"
#include "math/bc.h"
#include "alloc/alloc.h"
#include "hash/simple.h"
#include "mitm.h"
#include "isd.h"
#include "random.h"

using namespace cryptanalysislib;

Expand Down Expand Up @@ -104,7 +105,7 @@ class Stern : public ISDInstance<uint64_t, isd> {
bucketsize, nrbuckets, config.threads
};

using HM = SimpleHashMap<keyType, V1, simpleHashMapConfig, Hash<l_type, 0, l>>;
using HM = SimpleHashMap<keyType, V1, simpleHashMapConfig, Hash<l_type, 0, l, 2>>;
HM *hm;

constexpr static ConfigEnumHashMap configEnum{config};
Expand Down Expand Up @@ -219,8 +220,8 @@ class Stern : public ISDInstance<uint64_t, isd> {
for (size_t cindex = 0; cindex < final_list_current_size/8; cindex++) {
ASSERT(cindex < final_list_left.size());

const uint32x8_t left = uint32x8_t::load(final_list_left256 + cindex);
const uint32x8_t right = uint32x8_t::load(final_list_right256 + cindex);
const uint32x8_t left = uint32x8_t::load((uint32_t *)(final_list_left256 + cindex));
const uint32x8_t right = uint32x8_t::load((uint32_t *)(final_list_right256 + cindex));

biject_simd<baselist_enumeration_length, p>(left, rows1);
biject_simd<baselist_enumeration_length, p>(right, rows2);
Expand Down Expand Up @@ -375,4 +376,5 @@ class Stern : public ISDInstance<uint64_t, isd> {
<< " }" << std::endl;
}
};

#endif//DECODING_STERN_H
1 change: 0 additions & 1 deletion src/stern_im.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef DECODING_STERN_IM_H
#define DECODING_STERN_IM_H

#include <cstdint>

#include "mitm.h"
Expand Down
20 changes: 10 additions & 10 deletions tests/mitm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST(EnumHashMap, alloc) {
using V = CollisionType<T, uint16_t, p>;

constexpr static SimpleHashMapConfig s{.bucketsize=10u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
HM *hm = new HM{};

static constexpr ConfigEnumHashMap config{k+l, p, l, 1};
Expand All @@ -38,7 +38,7 @@ TEST(EnumHashMap, enumeration_changelist) {
using V = CollisionType<T, uint16_t, p>;

constexpr static SimpleHashMapConfig s{.bucketsize=4u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
HM *hm = new HM{};

static constexpr ConfigEnumHashMap config{k+l, p, l, 1, epsilon, false, true};
Expand Down Expand Up @@ -83,7 +83,7 @@ TEST(EnumHashMap, enumeration) {
using V = CollisionType<T, uint16_t, p>;

constexpr static SimpleHashMapConfig s{.bucketsize=10u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
HM *hm = new HM{};

static constexpr ConfigEnumHashMap config{k+l, p, l, 1, epsilon};
Expand Down Expand Up @@ -117,7 +117,7 @@ TEST(EnumHashMap, enumeration_index) {
using V = CollisionType<T, uint32_t, 1>;

constexpr static SimpleHashMapConfig s{.bucketsize=10u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
HM *hm = new HM{};

static constexpr ConfigEnumHashMap config{k+l, p, l, 1, true};
Expand Down Expand Up @@ -149,7 +149,7 @@ TEST(EnumHashMap, multithreaded_enumeration) {
using V = CollisionType<T, uint16_t, p>;

constexpr static SimpleHashMapConfig s{.bucketsize=10u, .nrbuckets=1u<<l, .threads=threads};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
HM *hm = new HM{};
hm->print();

Expand Down Expand Up @@ -190,7 +190,7 @@ TEST(CollisionHashMap, enumeration) {
using V = CollisionType<T, uint16_t, p>;

constexpr static SimpleHashMapConfig s{.bucketsize=10u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
using HM_DataType = HM::data_type;
using HM_DataType_IndexType = HM_DataType::index_type;
HM *hm = new HM{};
Expand Down Expand Up @@ -249,7 +249,7 @@ TEST(CollisionHashMap, enumerationSIMD) {
using V = CollisionType<T, uint32_t, 1>;

constexpr static SimpleHashMapConfig s{.bucketsize=2u, .nrbuckets=1u<<l, .threads=1};
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l>>;
using HM = SimpleHashMap<T, V, s, Hash<T, 0, l, 2>>;
using HM_DataType = HM::data_type;
using HM_DataType_IndexType = HM_DataType::index_type;
HM *hm = new HM{};
Expand Down Expand Up @@ -348,9 +348,9 @@ TEST(CollisionHashMapD3, enumeration) {
constexpr static SimpleHashMapConfig s1{.bucketsize=16u, .nrbuckets=1u<<l1, .threads=threads};
constexpr static SimpleHashMapConfig s2{.bucketsize=12u, .nrbuckets=1u<<l2, .threads=threads};
constexpr static SimpleHashMapConfig s3{.bucketsize=8u, .nrbuckets=1u<<l3, .threads=threads};
using HM1 = SimpleHashMap<T, V1, s1, Hash<T, 0, l1>>;
using HM2 = SimpleHashMap<T, V2, s2, Hash<T, 0, l2>>;
using HM3 = SimpleHashMap<T, V3, s3, Hash<T, 0, l3>>;
using HM1 = SimpleHashMap<T, V1, s1, Hash<T, 0, l1, 2>>;
using HM2 = SimpleHashMap<T, V2, s2, Hash<T, 0, l2, 2>>;
using HM3 = SimpleHashMap<T, V3, s3, Hash<T, 0, l3, 2>>;
HM1 *hm1 = new HM1{};
HM2 *hm2 = new HM2{};
HM3 *hm3 = new HM3{};
Expand Down

0 comments on commit ffe3a36

Please sign in to comment.