Git Product home page Git Product logo

xcn-project / cryonote-old Goto Github PK

View Code? Open in Web Editor NEW
9.0 8.0 6.0 6.75 MB

CryoNote: the secure, private, untraceable digital Cryptocurrency based on the CryptoNote technology.

Home Page: https://cryonote.cash

License: MIT License

CMake 1.17% Makefile 0.02% C++ 82.86% C 15.45% Shell 0.12% Perl 6 0.25% Perl 0.05% Python 0.06%
c-plus-plus p2p cryptocurrency cryptography cryptonote cryptonight cryptonight-dark cryonote

cryonote-old's People

Contributors

0x000090 avatar amjuarez avatar bitmonero-project avatar cmarshall108 avatar ekimmo avatar fixbitnote avatar fourschaft avatar noodledoodlenoodledoodlenoodledoodlenoo avatar quazarcoin avatar xcn-project avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryonote-old's Issues

Block 17630

Updated source, compiled, erased blockchain, started daemon...it gets stuck at block 17630 still. Also can't find a blockchain to download anymore.

Cryptonight-Dark Fix in Commit 41e2b2765cdd525983258bae2e980452ad0deb71 Accesses Uninitialised Data

Issue

The fix in commit 41e2b27 will cause incorrect behavior when invoking cryptonight-dark. This will be catastrophic for the network on block 30K.

This is due to the long_state scratchpad being initialized with 512kb but the actual iterations working on a 2mb scratchpad because the mask is improperly set.

The initialisation happens here in https://github.com/xbn-project/bitnote/blob/41e2b2765cdd525983258bae2e980452ad0deb71/src/crypto/slow-hash.c:

    if(useAes)
    {
        for(i = 0; i < (MEMORY / (dark?4:1)) / INIT_SIZE_BYTE; i++)
        {
            for(j = 0; j < INIT_SIZE_BLK; j++)
                aesni_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], expandedKey);
            memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE);
        }
    }
    else
    {
        for(i = 0; i < (MEMORY / (dark?4:1)) / INIT_SIZE_BYTE; i++)
        {
            for(j = 0; j < INIT_SIZE_BLK; j++)
                aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], expandedKey);

            memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE);
        }
    }

However, the state_index function is not restricted to working within the bounds of a 512kb scratchpad as can be seen here:

				#define TOTALBLOCKS (MEMORY / AES_BLOCK_SIZE)
				#define state_index(x) (((*((uint64_t *)x) >> 4) & (TOTALBLOCKS - 1)) << 4)

The result of this is that the algorithm will access uninitialized regions of the allocated memory and thus cause undefined behavior and outputs.

Solution

Properly iterate over the right region of memory in the state_index function and include test cases for reference hashes. (I will send a pull request with the changes in my personal repository.)

Demonstration

To demonstrate this, I created a few test cases from a personal and verified implementation on a 512kb scratchpad modification of the vanilla cryptonight algorithm. What follows a run of three attempts on the same test case file using the provided hash-tests binary in the tests build.

Notice that the generated hashes are different on every run. This is due to the uninitialized data containing essentially random bytes.

tests-slow1m.txt

98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f 63617665617420656d70746f72
04d2b27b1595ddaa6286aa2e2933f7ae9d7f41ceaf94fb3cf16e46a926f0e1ba 6465206f6d6e69627573206475626974616e64756d
1d6fcfc843cee5070b140f72278082c89e57fb2d9f050fd04b380702672e77ab 6162756e64616e732063617574656c61206e6f6e206e6f636574
98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f 63617665617420656d70746f72
63711b8f6ba33da18059d5ab808df6138f6492e1b9565042bd018dbeeac45afa 6578206e6968696c6f206e6968696c20666974

Run 1

./tests/hash-tests slow-1m ../tests/hash/tests-slow1m.txt
Hash mismatch on test 1
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: 171a199e82a5d5dd460f57f84cb439a304c650c66c0ef112e8f68623feeed9cc
Hash mismatch on test 2
Input: 6465206f6d6e69627573206475626974616e64756d
Expected hash: 04d2b27b1595ddaa6286aa2e2933f7ae9d7f41ceaf94fb3cf16e46a926f0e1ba
Actual hash: 8224fa6739fcd97b3296ec6446cdb6002f27e00891f720e9bfd4154a23adff8b
Hash mismatch on test 3
Input: 6162756e64616e732063617574656c61206e6f6e206e6f636574
Expected hash: 1d6fcfc843cee5070b140f72278082c89e57fb2d9f050fd04b380702672e77ab
Actual hash: a9553c8a8e0a8591574a4c34a3b13911d4efe37f23911cf8035023690bfa67c3
Hash mismatch on test 4
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: e8dc8fca26e48e21602a6fc5cc000a199496a0ad1692642152a5cf0706d7b837
Hash mismatch on test 5
Input: 6578206e6968696c6f206e6968696c20666974
Expected hash: 63711b8f6ba33da18059d5ab808df6138f6492e1b9565042bd018dbeeac45afa
Actual hash: adfaeaa31c5dc9b43671e0ab780fe00538090512acafc78988f5a0d59f00bcc0

Run 2

Hash mismatch on test 1
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: 2ad47444e0003552cf85cfa905567e262f49e4073fc6f7798d21bad7da884417
Hash mismatch on test 2
Input: 6465206f6d6e69627573206475626974616e64756d
Expected hash: 04d2b27b1595ddaa6286aa2e2933f7ae9d7f41ceaf94fb3cf16e46a926f0e1ba
Actual hash: 58982d03199853f901e7daed89443108c6df2a57d405f46c705b640118c01e55
Hash mismatch on test 3
Input: 6162756e64616e732063617574656c61206e6f6e206e6f636574
Expected hash: 1d6fcfc843cee5070b140f72278082c89e57fb2d9f050fd04b380702672e77ab
Actual hash: b304b0b05b25a775687a434d0ff3eacc1a1bffb7326ae8342918290c52542da2
Hash mismatch on test 4
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: f4964bd1ed5fe50854d751b400b47732683b2bfe65299a682042ef7a000fccb3
Hash mismatch on test 5
Input: 6578206e6968696c6f206e6968696c20666974
Expected hash: 63711b8f6ba33da18059d5ab808df6138f6492e1b9565042bd018dbeeac45afa
Actual hash: db259661fc096aee922e745e231d0341ecae8c1387a70f033134db581f2a0d7e

Run 3

./tests/hash-tests slow-1m ../tests/hash/tests-slow1m.txt
Hash mismatch on test 1
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: 43d6a8175ebaf831f4ce34f87b24de31be9fc6d42b53a6b903231574f712cd25
Hash mismatch on test 2
Input: 6465206f6d6e69627573206475626974616e64756d
Expected hash: 04d2b27b1595ddaa6286aa2e2933f7ae9d7f41ceaf94fb3cf16e46a926f0e1ba
Actual hash: 6e15e555cf03337d371d461cc6503f5cc85e9d926f796773601f0568d73e0af1
Hash mismatch on test 3
Input: 6162756e64616e732063617574656c61206e6f6e206e6f636574
Expected hash: 1d6fcfc843cee5070b140f72278082c89e57fb2d9f050fd04b380702672e77ab
Actual hash: a9c95e545adbe8701f18434bc4e9cdf82fb3948003088390a1f5305c547f1d3b
Hash mismatch on test 4
Input: 63617665617420656d70746f72
Expected hash: 98c48cda9ab5d26ef2717e7375f665fc18b703aac6c059bb814685f21946647f
Actual hash: 5f56a10aa0060699d3a57032685003c7daf277dcccaf63cd74b380f34a4aa442
Hash mismatch on test 5
Input: 6578206e6968696c6f206e6968696c20666974
Expected hash: 63711b8f6ba33da18059d5ab808df6138f6492e1b9565042bd018dbeeac45afa
Actual hash: ede5bc676f3f3d08527880ca119c256ead4bbfeb132a72d515f77d3fabaca758

No peers

bitnoted says: Failed to connect to any of seed peers, continuing without seeds

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.