Code Monkey home page Code Monkey logo

fish-hash's People

Contributors

andreacorbellini avatar danield9tqh avatar mat-if avatar qustomqure avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fish-hash's Issues

FishHash algorithm fetch indices misunderstanding

In the specification of FishHash algorithm https://github.com/iron-fish/fish-hash/blob/main/FishHash.pdf section 3.2 ReadDataSet subprogram MixValue has offsets in bytes: 0, 32,64:

Algorithm 2 ReadDataSet

LoadValue[0:127] <- DataSet[MixValue[0:3] % dataSetSize]
LoadValue[128:255] <- DataSet[MixValue[32:35] % dataSetSize]
LoadValue[256:383] <- DataSet[MixValue[64:67] % dataSetSize]

But in your implementation (both C++ and Rust) they are 0, 16, 32:

fish-hash/rust/src/lib.rs

Lines 260 to 262 in dfdd747

let p0 = mix.get_as_u32(0) % FULL_DATASET_NUM_ITEMS;
let p1 = mix.get_as_u32(4) % FULL_DATASET_NUM_ITEMS;
let p2 = mix.get_as_u32(8) % FULL_DATASET_NUM_ITEMS;

fish-hash/cpp/FishHash.cpp

Lines 147 to 149 in dfdd747

const uint32_t p0 = mix.word32s[0] % index_limit;
const uint32_t p1 = mix.word32s[4] % index_limit;
const uint32_t p2 = mix.word32s[8] % index_limit;

sizeof(mix.word32s) == 4 so we read from MixValue[0:3], MixValue[16:19], MixValue[32:35]

Corresponding to Lollidieb's paper indices should be mix.word32s[0], mix.word32s[8], mix.word32s[16].

Fishhash prebuilt dataset, can it be more fast?

Hello beautiful devs,

I have a question regarding the prebuilt dataset, even with 8 threads it makes more than 4 minutes to be generated, is there anyway to improve that process? I think people who will need to generate it with on a 4 threads server will definitely have an hard time.

Desperately trying to build the C++ implementation

Hello beautiful devs,

I have been desperately trying to build the C++ implementation of fishhash. Any help would be truly appreciated:

  g++ -g -Wall -fPIC -fpermissive -O2 -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-sign-compare -std=c++11 -maes -msse2  -mssse3 -mpclmul -mavx -mavx2    -c -o ethash/progpow.o ethash/progpow.cpp
  g++ -shared -o libkawpow.so ethash/ethash.o keccak/keccak.o keccak/keccakf800.o keccak/keccakf1600.o ethash/managed.o ethash/primes.o ethash/progpow.o 
  rm -f libfishhash.so 3rdParty/blake3.o 3rdParty/blake3_dispatch.o 3rdParty/blake3_portable.o 3rdParty/keccak.o FishHash.o
  cc -g -Wall -c -fPIC -O2 -Wno-pointer-sign -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-discarded-qualifiers -Wno-unused-const-variable -maes -msse2  -mssse3 -mpclmul -mavx -mavx2     -c -o 3rdParty/blake3.o 3rdParty/blake3.c
  cc -g -Wall -c -fPIC -O2 -Wno-pointer-sign -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-discarded-qualifiers -Wno-unused-const-variable -maes -msse2  -mssse3 -mpclmul -mavx -mavx2     -c -o 3rdParty/blake3_dispatch.o 3rdParty/blake3_dispatch.c
  cc -g -Wall -c -fPIC -O2 -Wno-pointer-sign -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-discarded-qualifiers -Wno-unused-const-variable -maes -msse2  -mssse3 -mpclmul -mavx -mavx2     -c -o 3rdParty/blake3_portable.o 3rdParty/blake3_portable.c
  cc -g -Wall -c -fPIC -O2 -Wno-pointer-sign -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-discarded-qualifiers -Wno-unused-const-variable -maes -msse2  -mssse3 -mpclmul -mavx -mavx2     -c -o 3rdParty/keccak.o 3rdParty/keccak.c
  g++ -g -Wall -fPIC -fpermissive -O2 -funroll-loops -fomit-frame-pointer -Wno-char-subscripts -Wno-unused-variable -Wno-unused-function -Wno-strict-aliasing -Wno-sign-compare -std=c++11 -maes -msse2  -mssse3 -mpclmul -mavx -mavx2    -c -o FishHash.o FishHash.cpp
  In file included from 3rdParty/blake3.c:7,
                   from FishHash.cpp:6:
  3rdParty/blake3_dispatch.c: In function ‘cpu_feature get_cpu_features()’:
3rdParty/blake3_dispatch.c(95,33): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
     95 |     enum cpu_feature features = 0;
        |                                 ^
        |                                 |
        |                                 int
3rdParty/blake3_dispatch.c(100,14): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    100 |     features |= SSE2;
        |     ~~~~~~~~~^~~~~~~
        |              |
        |              int
3rdParty/blake3_dispatch.c(106,16): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    106 |       features |= SSSE3;
        |       ~~~~~~~~~^~~~~~~~
        |                |
        |                int
3rdParty/blake3_dispatch.c(108,16): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    108 |       features |= SSE41;
        |       ~~~~~~~~~^~~~~~~~
        |                |
        |                int
3rdParty/blake3_dispatch.c(114,20): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    114 |           features |= AVX;
        |           ~~~~~~~~~^~~~~~
        |                    |
        |                    int
3rdParty/blake3_dispatch.c(118,22): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    118 |             features |= AVX2;
        |             ~~~~~~~~~^~~~~~~
        |                      |
        |                      int
3rdParty/blake3_dispatch.c(121,24): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    121 |               features |= AVX512VL;
        |               ~~~~~~~~~^~~~~~~~~~~
        |                        |
        |                        int
3rdParty/blake3_dispatch.c(123,24): warning G738B250A: invalid conversion from ‘int’ to ‘cpu_feature’ [-fpermissive] [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
    123 |               features |= AVX512F;
        |               ~~~~~~~~~^~~~~~~~~~
        |                        |
        |                        int
  g++ -shared -o libfishhash.so 3rdParty/blake3.o 3rdParty/blake3_dispatch.o 3rdParty/blake3_portable.o 3rdParty/keccak.o FishHash.o 
  /usr/bin/ld: 3rdParty/blake3_dispatch.o: in function `blake3_compress_in_place':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:140: multiple definition of `blake3_compress_in_place'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:140: first defined here
  /usr/bin/ld: 3rdParty/blake3_dispatch.o: in function `blake3_compress_xof':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:169: multiple definition of `blake3_compress_xof'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:169: first defined here
  /usr/bin/ld: 3rdParty/blake3_dispatch.o: in function `blake3_hash_many':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:198: multiple definition of `blake3_hash_many'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:198: first defined here
  /usr/bin/ld: 3rdParty/blake3_dispatch.o: in function `get_cpu_features':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:88: multiple definition of `blake3_simd_degree'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_dispatch.c:88: first defined here
  /usr/bin/ld: 3rdParty/blake3_portable.o: in function `blake3_compress_in_place_portable':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:101: multiple definition of `blake3_compress_in_place_portable'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:101: first defined here
  /usr/bin/ld: 3rdParty/blake3_portable.o: in function `blake3_compress_xof_portable':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:120: multiple definition of `blake3_compress_xof_portable'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:120: first defined here
  /usr/bin/ld: 3rdParty/blake3_portable.o: in function `blake3_hash_many_portable':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:166: multiple definition of `blake3_hash_many_portable'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_portable.c:166: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_version':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:11: multiple definition of `blake3_version'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:11: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_init':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:367: multiple definition of `blake3_hasher_init'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:367: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_init_keyed':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_impl.h:152: multiple definition of `blake3_hasher_init_keyed'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3_impl.h:152: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_update':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:464: multiple definition of `blake3_hasher_update'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:464: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_finalize_seek':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:578: multiple definition of `blake3_hasher_finalize_seek'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:578: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_finalize':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:568: multiple definition of `blake3_hasher_finalize'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:568: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_init_derive_key_raw':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:382: multiple definition of `blake3_hasher_init_derive_key_raw'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:382: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_init_derive_key':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:393: multiple definition of `blake3_hasher_init_derive_key'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:393: first defined here
  /usr/bin/ld: FishHash.o: in function `blake3_hasher_reset':
  /home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:25: multiple definition of `blake3_hasher_reset'; 3rdParty/blake3.o:/home/ceedii/miningcore/src/Native/libfishhash/3rdParty/blake3.c:25: first defined here
collect2 : error : ld returned 1 exit status [/home/ceedii/miningcore/src/Miningcore/Miningcore.csproj]
  make: *** [Makefile:11: libfishhash.so] Error 1

I also has an issue with the blake3_neon.c file, i had to comment it in the blake3.c file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.