A proposed hash algorithm to use for blockchain base transaction flow system

Blockchain technology introduces a new approach to storing information, implementing tasks and functions, and building trust between participating nodes. Although blockchain technology has received extensive attention in various application contexts in recent years, the issue of privacy and security remains the primary focus of discussions of the blockchain. The use of hash algorithms can provide secure blockchain integration, and many hash algorithms offer solutions to data integrity and security problems within the context of blockchain technology. However, they are also subject to problems related to time, lack of resources, and memory usage. In this research, an algorithm is proposed to generate a hash based on chaos theory (1D and 2D) logistic maps and the new Merkle-Damgård construction. Hash outputs are tested in terms of time, complexity, and collision. The proposed algorithm is evaluated according to Jaccard similarity and various coefficient measurements, and it was found that the similarity between the inputs and the outputs does not exceed 0.1932 percent. All outcomes indicated successful performance. The proposed algorithm was implemented on a blockchainbased transaction flow system, consumed fewer resources than other hash algorithms (such as SHA1, SHA2, and MD5), and requires mere milliseconds to implement.


Introduction
The blockchain was proposed for the first time in 2009 in a research paper presented by Satoshi Nakamoto to invent the fiat currency Bitcoin. Blockchain transactions are carried out among the users of the technology without any intermediary, making it a decentralized technology (that is, no one controls the operations that take place through it). No governmental bodies control the course of its affairs, nor do the companies that manage and regulate its functioning [1]. Even though the Bitcoin is the most popular application of block-chain technology, the blockchain may be applied to many contexts beyond digital currencies. It can be used in various financial services and transfers because it permeates a wide variety of the applications over numerous industries, including transformation, governance, and manufacturing. E-governance is a powerful and important tool, especially in developing countries that face challenges like weak public services, growing crime rates, and poor education [2][3][4]. The blockchain provides hash functions for each transaction which convert a random-length file into a fixed-length hash value, known as the message fingerprint. Any modification of the input data will cause a radical variation in the hash values. As a result, cryptographic hashes are frequently utilized in the security protocols and applications [5][6][7]. Cryptographic hash functions ensure the integrity of Authentication files in a connection. This research focuses on blockchain cryptography intended to provide database security and protect transactions against interference from outside parties. Blockchain technology enables the transfer of digital assets from peer to peer without any intermediary and with high security and is characterized by the major features of decentralization, transparency, stability, and audibility [8]. This research is divided into the following sections: (1) introduction to the blockchain, its types, and its use; (2.1) block-chain architecture; (2.2) characteristics of the block-chain; (2.3) secure hashing function (addressing the most important hash algorithms that provide high data security); (3) Merkle-Damgård construction, the most important schemes and structures adopted by modern hash algorithms; and (5) the proposed hash algorithm (Chaos Buffer Hash). The final section describes the method of generating a new algorithm that adds more protection against external attacks. Its goal is to generate high-randomness outputs that depend entirely on chaotic maps [9].

Blockchain types and theory
Blockchain is an innovative technology for building and using a ledger. Data are recorded on a decentralized node called a block. No third party is required to use this technology, which improves its reliability . While blockchain represents a database or a new way of organizing data, its method of dealing is different from central dealing; it is an electronic record system. Processing and recording transactions that allow all parties to track information through a secure network. Its features include decentralization; it does not belong to anyone entity but is rather the property of its users. It is also open-source and offers high levels of safety and protection, as penetrating the system is almost impossible . Blockchain guarantees its users a great deal of privacy and confidentiality; as people are only represented by encrypted codes in the system, no one can identify personal data about other users [10][11][12]. In general, blockchain technologies are divided into four types: public, private, consortium, and hybrid [13,14]. A public blockchain is an unrestricted distributed ledger. Without needing to obtain permission, anyone can become a certified node by logging into the blockchain platform and becoming part of this type of network. The public blockchain allows the node or user to access current and previous records, verify transactions, prove work as an incoming block, and do mining. Examples of the public block-chain networks include Bitcoin and Ethereum. The private blockchain is restricted and requires permission because it is a closed network. The private blockchain is usually used within institutions. The participants in the blockchain network are members. The controlling organization is responsible for authorizations, the level of security, permissions, and accessibility. Hence, public blockchain is the same as private. However, the private blockchain has a small and restricted connection. Voting, digital identity management, and access ownership are examples of contexts in which it is advised to deploy private networks. Hyperledger projects (e.g., Fabric, Sawtooth), MultiChain, and Corda can be considered as examples of applied private block-chains. The consortium block-chain can be briefly defined as semi-decentralized. Consortium blockchains are run by multiple organizations, unlike other classes that are run by only one institution, such as private blockchain. It is possible to circulate more than one institution as a node point in the network. The consortium blockchain is typically used for mining or exchanging information by community and government organizations and banks. Examples of consortium blockchains include Energy Web Foundation and R3 [15,16]. Hybrid blockchain is a type of private and public block-chain that allows the use of two kinds of blockchain features. Hybrid blockchains can have a private ear-based system. In addition to a permissionless system (public system). In addition, inside the network of the hybrid blockchain, users control who can access the stored data. The portion of the data or records that are allowed to spread is specific to the blockchain. The hybrid system is characterized by flexibility, security, and transparency. An example of a hybrid blockchain is Dragonchain [17]. One problem with the blockchain is the speed of performance in creating the hash function while providing high security and ensuring that input information cannot be discovered from the output of the algorithm. The algorithm must also be anti-collision-that is, it should be impossible to produce the Same output for two different inputs. At the same time, it is allowed to be used for any type of blockchain.

Blockchain architecture
A node registered in de-centralized block-chain begins by creating a transaction. An electronic signature with a private Encryption key is used to make that transaction. All of the transactions have been stored in a file for collecting the unconfirmed transactions and publishing them in the network with the use of a flooding algorithm that has been referred to as Gossip protocol. Peers require the validation of the transactions according to certain predefined criteria. For instance, the node attempts to authenticate the validity of transactions through the verification of whether the balance is sufficient for the initiation of a transaction, an attempt to deceive the system, or an attempt to use the same balance by entering the same transaction two or more times (double spending theory). Once the miners authenticate the transactions, they are combined in the block. A consensus mechanism is used to verify the new blocks, which helps access the decentralized network. After verification, it is included in the chain, and each copy of all peers is subject to change. The next block connects to the newly created file whenever a new block is attached to the chai [18]. The smallest task unit which is stored or saved in public records is a transaction.
A record (or block) is the smallest data structure. Every previous transaction is confirmed and not modified. During transaction initiation, mining and consensus depend heavily on the hash function [19,5,12]. A hash function algorithm can take any type of input (number, string, or text) and produce a fixed-length output, and any variation in the input leads to a change in the output, termed a one-way function [20]. Figure 1 summarizes the most important stages of creating a transaction via the blockchain: (I)Initial transaction: In the first stage, a transaction is uploaded to the blockchain (anyone registered on the network can upload a transaction). (II)Verification of transaction: In the second stage, the sender's identity is verified, meaning that transaction processing between the sender and the recipient is required by the sender and not anyone else. Digital signatures (public and private) are used [21]. In addition to the digital signature, the data (i.e. the transaction amount) are sent, and the transaction is verified by the miners based on various criteria. (III)New block: A blockchain consists of blocks that store information about all transactions. These blocks are linked so That each block has a hash reference. Each one of the block includes a block header and a block body. Metadata such as parent block hash, block version, Merkle tree root hash, time-stamp, n Bits, and nonce have been included in block header [22]. The block body includes several transactions and a transaction counter that indicates the number of the transactions that are being tracked, represented by a set of the transactions that have been recorded in the block. In the network, each participant owns a public and private key. A secret key has been utilized for encrypting and signing. The transaction, whereas public access, is distributed across network and offers a means for everyone to help decipher the code [23].

Characteristics of the blockchains
The most important properties of the block-chain technology are: -Immutability: The blockchain cannot be changed. This helps ensure that the technology remains the same: a permanent, immutable network [24]. Decentralization: The blockchain has no one governing authority or person. A group of nodes maintains the network, which makes it decentralized [25].Enhanced security: Since the blockchain removes the central authority, no individual entity can change any of the network properties to its advantage. Using cryptography guarantees another layer of security for the system through the use of complex mathematical algorithms that work with an attack firewall [26]. Distributed ledger: The ledger provides all information about the transaction and participants. Users can see what is happening in the ledger and, because the ledger is in the network, it is maintained by all other users in the system. Consensus: The core of the blockchain is consensus algorithms. To help the network make decisions, each block has a consensus, defined as the decision-making process on the network for a set of the active nodes. This feature makes it possible for nodes to proceed to an agreement more quickly [27,28].

Secure hashing blockchain
The most secure and reliable algorithms in block-chain technology are SHA-1, -2, and -256. The hash function is of unparalleled quality. It can create unique output when various inputs are given and are a unique key that is created for transaction identification. The United States Federal Information Processing Standard and the United States National Security Agency (NSA) were originally designed. The SHA. We designated these effective algorithms to verify the integrity of the files. Blockchain technology functions are reliable to use, which helps to create a suitable and robust hash code. Each proposed transaction in the blockchain is hashed. At the same time, the hash indicators connect every one of the Blocks to the next block and preserve the previous hash data. Any changes to blockchain transactions affect all the blocks involved. SHA1 and SHA2 are two versions of the same secure hash algorithm that vary in both syntaxes (how to create the resulting hash from the original data) and signature bit length. SHA2, the successor to SHA1, is considered a comprehensive improvement. Regarding bit length, SHA1 is 160 bits, whereas SHA 2 comes in various lengths but most commonly 256 bits. SHA 224, SHA 384, and SHA 512 all refer to SHA2. From 2011 to 2015, Sha1 was the primary algorithm used. However, a growing body of research has demonstrated weaknesses in SHA1 related to collision (i.e., two pieces of data originating the same hash). The algorithm used to generate the hash must have the following properties: 1-Deterministic: The hash does not change for the same message-that is, considering a certain input M, the function always calculates same output h(M). and M  M . which has been referred to as strong collision resistance as well. 6-Hashtags should be non-modifiable, not just encrypted. 7-No correlation: input bits M should not be connected to output bits h(M). 8-Random behavior: Random behavior has to be included in the hash function, making it useless to attempt to predict which output is associated with which input. Figure 2(a) visualizes blockchain technology as the combination of a block included in its structure consisting of data and the previous block hash (except for the original one, which does not contain a previous hash). Figure 2(b) shows a blockchain network that includes several blocks linked to the previous blocks via hashing [29][30][31][32]. The National Institute of Standards and Technology (NIST) was introduced in 1995 by SHA1 and was adopted for many years. Many researchers have proven after a while that it is possible under certain conditions to get conflicting messages. Thus, the safety level of SHA1 decreases. In 2001, it announced the Sha2 hash, but unfortunately, it did not meet high expectations. Therefore, hash algorithms are constantly evolving. In October 2008, the Institute announced an open discussion of a new hash function, SHA3 [33]. Therefore, researchers always seek to use hash algorithms that guarantee their first concept, which is that they are not reversible, while the second indicates that it is not easy to find 2 inputs for the same hash value [34].

Merkle-Damgard construction
Merkle-Damgård construction can be defined as the base that designers have relied on since the early days of cryptographic hash functions. Independently Discovered by Merkle-Damgård in 1989. It follows the MD iterative method and a pressure function that takes an input length value and outputs values with a constant output which is the core of this construct component. ℎ( ) = Where f represents compression function of h, represents intermediate chaining that is variable between the stages i-1 and i, and H0 represents a pre-defined starting value or an initial value IV. The diagram of iterative hash function utilizing compression function has been represented in Figure4. The calculation of the hash value has been based upon chaining variable, which has a fixed initial value at start of the hashing that has been assigned as part of the algorithm [35][36][37].

Logistic map
The hash function is similar to that of the random number generator concerning the random output. A dynamic system such as chaos has been found suitable for use as a hash function. Not all field maps are proper for the coding purposes. Logistical maps are simple, fast, sensitive to elementary conditions, unpredictable, and are a 1-way and iterative function [38,39].
∈ (0,1), ∈ Chaos theory has been used in a lot of scientific research (in the field of encryption and in the generation of hash algorithms) because it follows random behavior or defines a completely inevitable chaotic system [40].

Proposed hash algorithm (chaos buffer hash)
For various reasons, hash algorithms can experience certain problems, the most important of which are collisions. It is imperative to strengthen the power of algorithms so that they can withstand any problems they encounter. The hash algorithm was designed based on chaos theory (1D and 2D), logic, and Buffers with the adoption of a new structure based on Merkle-Damgård construction. The Chaos Buffer Hash algorithm deals with variablelength messages and converts them to fixed-length output (32 hexadecimals, 64 hexadecimals, and 128 hexadecimal). The algorithm steps are as follows: 1-The message is broken into chunks of 1,024-byte blocks. If blocks are less than 1,024 bytes, the message is padded by the sum modulus 1,024 bits. 2-A 1D logistic map is used to generate 1,000 random numbers, of which the algorithm selects only 32 random numbers and only 4 numbers after (,). The 32 numbers are converted to binary (32 × 4 × 8 = 1,024 bytes). 3-Made (XOR) between step 1 (1,024-byte message padding) and step2 (1,024 bytes from logistic map). 4-Using a 32-byte buffer, initial buffer values are generated from a 2D logistic map.
Feeds the first 16 buffer and feeds the second 16 buffer. Each buffer represents eight numbers after (,) from the 2D logistic map. Each buffer represents 64 bytes.

Experimental results
The output of the proposed hash algorithm (Chaos Buffer Hash) was tested according to several metrics, including time, complexity, collision, and resource consumption.
The algorithm takes only a few milliseconds to implement. The time was calculated using C#'s built-in Timer class. The complexity of the algorithm is a result of using the logistic map parameters. Changing the initial values of the logistical equations changes the results of the hash, so it requires all parties using the algorithm to prove the same initial values of the logistical equations used. ➢ Collision resistance: It's not possible to generate 2 different strings for the same output or to generate more than one output for one input at a time. About 8,000 hashes were generated using the proposed algorithm and did not result in any collision.

➢
Input/output size: Any size of data may be used as input, while the output length is fixed.

Statistical Analysis of Experimental Results
Statistical analysis was applied to find the percentage of similarity between the input and output of proposed algorithm. We used the Jaccard similarity coefficient, a statistical parameter that measures similarity and diversity in sample groups by finding the ratio of intersection on the union. This was used for binary data that provides an accurate solution and methods for testing hypotheses using Jaccard's modulus.
This paper improves blockchain security by presenting a major challenge to exchanging information through the blockchain network, thus providing security and trust, which is extremely important. Thus, it achieved sharing of data resources among nodes and authentication between different users. ➢

Analysis of the seven stages of the proposed algorithm
The seven stages of the Chaos Buffer Hash algorithm were applied to more than 2,000 text files, and we found that all seven phases were collision-resistant. The algorithm was hybridized using logistic maps, logic, and new Merkle-Damgård construction and refined to increase its complexity while preserving temporal efficiency. The proposed technique was implemented in C# and run several times on a machine containing a 64-bit Intel Pentium i76500U processor running at 2.50 GHz and 2.70 GHz with 8GB RAM on the Microsoft Windows 10 OS.

Blockchain applying
The proposed algorithm was applied to a blockchain-based transaction flow system. Each transaction is sent by more than one node. The transaction must be verified through the hash generated for it. Each time data are sent and received between the nodes, the transaction is verified through the generated hash, which must give the same hash every time. Node1 suggests a transaction and enters it into the Chaos Buffer Hash algorithm to give it a hash of its own (generated from the information recorded in the transaction). Node2 checks the hash value before accepting it. If the results give the same hash value as that sent from the first node, it is accepted and sent to the other nodes. Once the transaction passes through more than one node, a decision is made after the validity of the transaction has been verified every time it is sent or received. It is then placed in the blockchain. Upon any inquiry about the transaction, it will be retrieved from the blockchain. The nodes are connected through a TCP/IP protocol in the same network, representing the number of employees in a network. Nodes: -It represents the number of employees within the network. Regarding the importance of the proposed blockchain system, it does not allow for the modification of transactions and their hash values. If a change is made to the transaction through a malicious node, the hash values must be changed and altered in all the data stored at the node. The change is known because each node uses the same blockchain system and there will thus be discrepancies in the hash values for the same transaction.

Conclusion
This work provides a secure decentralized ledger of transactions that are saved and distributed among the nodes in the network using a secure blockchain-based on a hash algorithm. A new algorithm was proposed for generating a hash that works on any size of data and gives four outputs of different lengths without any impact on the speed of the algorithm. The algorithm was strengthened against possible attacks. Every transaction is proposed by a node within the network, and a decision is only made about that transaction after it is confirmed by all parties participating in the transaction system. Every sending and receiving movement is recorded in the blockchain. the algorithm's efficiency was proven through the various measures applied, and it was found to be It is not prone to manipulation from outside parties.
The proposed system has been applied to a municipality (the municipal work function) to identify whether a citizen is a beneficiary of land from the municipality. A form is opened for citizens and passed through the employees to decide it. The decision is thus a consensus between more than one party, and any sending and receiving process is recorded in the blockchain. This provides strong authentication between nodes depending on the proposed hash.