Bitcoin Forum
September 15, 2019, 06:51:21 AM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Where is hashing algorithm code?  (Read 356 times)
wsxdrfv
Newbie
*
Offline Offline

Activity: 322
Merit: 0


View Profile WWW
February 11, 2018, 11:44:31 AM
 #1

So bitcoin uses sha256, litecoin scrypt, dash x11.

Where is revision location(source code filename, approx line position)  of this algorithm?

Is it widespread and hard to revise? or easy to change?

How change to x11 algorithm? Some site says x11 is best algorithm.

1568530281
Hero Member
*
Offline Offline

Posts: 1568530281

View Profile Personal Message (Offline)

Ignore
1568530281
Reply with quote  #2

1568530281
Report to moderator
1568530281
Hero Member
*
Offline Offline

Posts: 1568530281

View Profile Personal Message (Offline)

Ignore
1568530281
Reply with quote  #2

1568530281
Report to moderator
1568530281
Hero Member
*
Offline Offline

Posts: 1568530281

View Profile Personal Message (Offline)

Ignore
1568530281
Reply with quote  #2

1568530281
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
bob123
Legendary
*
Offline Offline

Activity: 1022
Merit: 1506



View Profile WWW
February 11, 2018, 01:35:06 PM
Merited by HeRetiK (1)
 #2

So bitcoin uses sha256, litecoin scrypt, dash x11.
Where is revision location(source code filename, approx line position)  of this algorithm?

Simply google. Those algorithms (SHA, scrypt) weren't invented for those cryptocurrencies.
They existed before.

SHA: https://en.wikipedia.org/wiki/SHA-2
scrypt: https://en.wikipedia.org/wiki/Scrypt

X11 is concatenated algorithm composed of  BLAKE, BMW, Grøstl, JH, Keccak, Skein, Luffa, CubeHash, SHAvite, SIMD and Echo.



How change to x11 algorithm? Some site says x11 is best algorithm.

Changing the algorithm would require a hard fork (https://en.wikipedia.org/wiki/Fork_(blockchain)#Hard_fork).
There is no "best" algorithm.
Simply because there is no definition of a "best" algorithm.

Additionally you should not believe what you read on "some site".

t1192002
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
February 11, 2018, 02:34:06 PM
 #3

So bitcoin uses sha256, litecoin scrypt, dash x11.
Where is revision location(source code filename, approx line position)  of this algorithm?

Simply google. Those algorithms (SHA, scrypt) weren't invented for those cryptocurrencies.
They existed before.

SHA: https://en.wikipedia.org/wiki/SHA-2
scrypt: https://en.wikipedia.org/wiki/Scrypt

X11 is concatenated algorithm composed of  BLAKE, BMW, Grøstl, JH, Keccak, Skein, Luffa, CubeHash, SHAvite, SIMD and Echo.



How change to x11 algorithm? Some site says x11 is best algorithm.

Changing the algorithm would require a hard fork (https://en.wikipedia.org/wiki/Fork_(blockchain)#Hard_fork).
There is no "best" algorithm.
Simply because there is no definition of a "best" algorithm.

Additionally you should not believe what you read on "some site".

Thanks for your informative explanation.
Just wonder that the work of finding a new block(mining) is it kind of decrypting these algorithm?
bob123
Legendary
*
Offline Offline

Activity: 1022
Merit: 1506



View Profile WWW
February 11, 2018, 03:21:18 PM
Merited by bones261 (3), achow101 (2), DarkStar_ (2), ETFbitcoin (1)
 #4

Just wonder that the work of finding a new block(mining) is it kind of decrypting these algorithm?

The work which has to be done to find a new block is not directly dependend on the algorithm.
Additionally you can't decrypt anything in this scenario.

Encryption != Hashing [1]

Hashing is a one-way-function.
This means: You can (relatively) easy calculate a hash of any value. But you can't get the original value out of the hash.

When you are trying to find a new block (mining) you are basically calculating hashes until you find one hash that (for example) begins with 10 zeros.
The difficulty adjusts to assure a new block every 10 minutes. You can look at the difficulty as "X zeros have to be at the beginning of the hash".

On average there has to be Y hashes calculated until a valid one is found. Thats basically a "probability-game".



[1] A more detailed explanation: https://en.wikipedia.org/wiki/Hash_function

tromp
Hero Member
*****
Offline Offline

Activity: 598
Merit: 537


View Profile
February 11, 2018, 04:13:00 PM
Merited by bones261 (2), ETFbitcoin (1), aliashraf (1)
 #5

Encryption != Hashing

And Proof-of-Work is not (necessarily) Hashing [1]

[1] http://cryptorials.io/beyond-hashcash-proof-work-theres-mining-hashing/
wsxdrfv
Newbie
*
Offline Offline

Activity: 322
Merit: 0


View Profile WWW
February 12, 2018, 03:44:04 AM
 #6

So bitcoin uses sha256, litecoin scrypt, dash x11.
Where is revision location(source code filename, approx line position)  of this algorithm?

Simply google. Those algorithms (SHA, scrypt) weren't invented for those cryptocurrencies.
They existed before.

SHA: https://en.wikipedia.org/wiki/SHA-2
scrypt: https://en.wikipedia.org/wiki/Scrypt

X11 is concatenated algorithm composed of  BLAKE, BMW, Grøstl, JH, Keccak, Skein, Luffa, CubeHash, SHAvite, SIMD and Echo.



How change to x11 algorithm? Some site says x11 is best algorithm.

Changing the algorithm would require a hard fork (https://en.wikipedia.org/wiki/Fork_(blockchain)#Hard_fork).
There is no "best" algorithm.
Simply because there is no definition of a "best" algorithm.

Additionally you should not believe what you read on "some site".

Thanks, but what I wondered is where should I revise at bitcoin source code to change its algorithm from sha256 to another?
RGBKey
Hero Member
*****
Offline Offline

Activity: 854
Merit: 629


rgbkey.github.io/pgp.txt


View Profile WWW
February 12, 2018, 04:14:20 AM
Merited by HeRetiK (1)
 #7

So bitcoin uses sha256, litecoin scrypt, dash x11.
Where is revision location(source code filename, approx line position)  of this algorithm?

Simply google. Those algorithms (SHA, scrypt) weren't invented for those cryptocurrencies.
They existed before.

SHA: https://en.wikipedia.org/wiki/SHA-2
scrypt: https://en.wikipedia.org/wiki/Scrypt

X11 is concatenated algorithm composed of  BLAKE, BMW, Grøstl, JH, Keccak, Skein, Luffa, CubeHash, SHAvite, SIMD and Echo.



How change to x11 algorithm? Some site says x11 is best algorithm.

Changing the algorithm would require a hard fork (https://en.wikipedia.org/wiki/Fork_(blockchain)#Hard_fork).
There is no "best" algorithm.
Simply because there is no definition of a "best" algorithm.

Additionally you should not believe what you read on "some site".

Thanks, but what I wondered is where should I revise at bitcoin source code to change its algorithm from sha256 to another?

It looks like you better have a good idea of what you're doing before you attempt to make your own coin, as that's what it sounds like what you want to do.
t1192002
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
February 12, 2018, 12:58:50 PM
 #8

The work which has to be done to find a new block is not directly dependend on the algorithm.
Additionally you can't decrypt anything in this scenario.

Encryption != Hashing [1]

Hashing is a one-way-function.
This means: You can (relatively) easy calculate a hash of any value. But you can't get the original value out of the hash.

When you are trying to find a new block (mining) you are basically calculating hashes until you find one hash that (for example) begins with 10 zeros.
The difficulty adjusts to assure a new block every 10 minutes. You can look at the difficulty as "X zeros have to be at the beginning of the hash".

On average there has to be Y hashes calculated until a valid one is found. Thats basically a "probability-game".
[1] A more detailed explanation: https://en.wikipedia.org/wiki/Hash_function

Thanks you so much man. You deserve a like/thumb up. Which I cant find in this forum lol.
hatshepsut93
Hero Member
*****
Offline Offline

Activity: 1274
Merit: 855


Bitcoin realist


View Profile
June 30, 2018, 01:32:20 PM
 #9

So bitcoin uses sha256, litecoin scrypt, dash x11.

Where is revision location(source code filename, approx line position)  of this algorithm?

Is it widespread and hard to revise? or easy to change?

How change to x11 algorithm? Some site says x11 is best algorithm.



I'm not a C++ developer, but I think the SHA256 implementation used by Bitcoin Core client is here: https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp

I would strongly advice against modifying anything in this or any other hashing algorithm, they were carefully tuned to be as secure as possible, and changing just a few constants can drastically reduce their security.

If you want to create a fork of Bitcoin with different algorithm, you'll have to do a lot of work. You will very likely fail if you are not an experienced programmer.

LighningCashDev
Jr. Member
*
Offline Offline

Activity: 198
Merit: 3


View Profile
February 11, 2019, 07:49:07 AM
 #10

Some answers :

First Litecoin's commits were actually a bitcoin's branch on github, NOT a github's fork of bitcoin.....

So here are the first "commits" for Litecoin :


Litecoin: Scrypt n=1024 Pow hash based upon Colin Percival's Tarnsnap…


https://github.com/bitcoin/bitcoin/commit/2acab1baf17c096ba9064f35b56d667e67a1f130

https://github.com/bitcoin/bitcoin/tree/2acab1baf17c096ba9064f35b56d667e67a1f130




Litecoin: Adapt scrypt code to C++


https://github.com/bitcoin/bitcoin/commit/d6e580d43fd6ba511db3c47eed53c64c07d3c734

https://github.com/bitcoin/bitcoin/tree/d6e580d43fd6ba511db3c47eed53c64c07d3c734


All those commits can be found here :

https://github.com/bitcoin/bitcoin/compare/master...litecoin-project:0.8

( search on the page for Commits on Jul 07, 2013 )



then, use Meld on ubuntu to compare with bitcoin's source code at this time !

LighningCashDev
Jr. Member
*
Offline Offline

Activity: 198
Merit: 3


View Profile
February 11, 2019, 07:58:43 AM
Last edit: February 11, 2019, 08:39:33 AM by LighningCashDev
 #11

1 - https://github.com/litecoin-project/litecoin/tree/40809aed657502e9de158e2cfe2c659a316f2f90       
                                       
( bitcoin )



2 - https://github.com/litecoin-project/litecoin/tree/9ab59ab97a351a814ceeea0ee2c74943698bb3ae     
             
 (Litecoin: CLIENT_VERSION_IS_RELEASE = false )



3 - https://github.com/litecoin-project/litecoin/tree/2acab1baf17c096ba9064f35b56d667e67a1f130
               
( Litecoin: Scrypt n=1024 Pow hash based upon Colin Percival's Tarnsnap… )



4 - https://github.com/litecoin-project/litecoin/tree/d6e580d43fd6ba511db3c47eed53c64c07d3c734
                     
( Litecoin: Adapt scrypt code to C++ )



5 - https://github.com/litecoin-project/litecoin/tree/9b5ca659e4ce1d56edb55acd5c51aed88bb8a4c6

(Litecoin: Default TCP ports, mainnet 9333 testnet 19333 RPC ports, ma… )


6 - https://github.com/litecoin-project/litecoin/tree/0b646aed42d44a3e7f41bff590f00395d6e390c8

( Litecoin: Protocol, genesis and parameters * 2.5 minute average between blocks * 3.5 days between diff changes * 84 million coin limit * Addresses begin with L )
ItaCraft
Member
**
Offline Offline

Activity: 136
Merit: 10

AeriumX leader Developer


View Profile
February 15, 2019, 09:01:59 PM
 #12

According to the bitcoin source code, the hash for the block header can be seen from the file src/primitives/block.cpp under
Code:
uint256 CBlockHeader::GetHash() const
{
    return SerializeHash(*this);
}

https://github.com/bitcoin/bitcoin/blob/master/src/primitives/block.cpp#L13

Which return the value of SerializeHash(*this), That is declared on the file hash.h

Code:
/** Compute the 256-bit hash of an object's serialization. */
template<typename T>
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
{
    CHashWriter ss(nType, nVersion);
    ss << obj;
    return ss.GetHash();
}

And according to the comment above it,
 /** Compute the 256-bit hash of an object's serialization. */

The SerializeHash will call CHashWriter and return the value of GetHash which is a simple sha256d hashing algorithm result


(Please, let me know if I'm wrong, I'm still studying bitcoin code)

"Talent hits a target no one else can hit; Genius hits a target no one else can see."
                                                                               --Arthur Schopenhauer
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!