It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
package main
import
(
"fmt"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"math/big"
)
func main() {
//Block:383313
//Version:2
//PrevBlockHash:9c4fc11576808cf7c139f0aff73de45e924d15f872d8c3cb541c88e3e1b0d7aa
//MerkleRoot:b15059d72023db53072feb6f1d2aec768971e9462f060830fcce0fb9c7372d35
//Time:January 31, 2014, 08:21:42
//Bits:0a6657d6
//Nonce:33557011
//Origin:511894124314277474466966190582380266982082554847978849190464099863530478638974696162270693661640
origin, err0 := base64.StdEncoding.DecodeString("511894124314277474466966190582380266982082554847978849190464099863530478638974696162270693661640")
prevBlock, err1 := base64.StdEncoding.DecodeString("9c4fc11576808cf7c139f0aff73de45e924d15f872d8c3cb541c88e3e1b0d7aa")
merkleRoot, err2 := base64.StdEncoding.DecodeString("b15059d72023db53072feb6f1d2aec768971e9462f060830fcce0fb9c7372d35")
bh := BlockHeader{2, prevBlock, merkleRoot, 1391156502, 174479318, 33557011}
fmt.Println("Header hash byte[]:")
fmt.Println(HeaderHash(bh))
fmt.Println("Decode errors:")
fmt.Println(err0)
fmt.Println(err1)
fmt.Println(err2)
s := HeaderHash(bh)
//fmt.Println(s)
//fmt.Println(new(big.Int).SetBytes(s))
//Reverse the hash
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
headerInt := new(big.Int).SetBytes(s)
originInt := new(big.Int).SetBytes(origin)
fmt.Println("Header hash reversed:")
fmt.Println(s)
fmt.Println("Header hash as Integer:")
fmt.Println(headerInt)
m:=big.NewInt(0)
t:=big.NewInt(0)
m.Mod(originInt, headerInt)
if m == t {
fmt.Println(">>>Origin is divisable by header hash.<<<")
} else {
fmt.Println(">>>Origin is NOT divisable by header hash.<<<")}
}
type BlockHeader struct {
Version uint32
HashPrevBlock []byte
HashMerkleRoot []byte
Timestamp uint32
Bits uint32
Nonce uint32
}
func HeaderHash(bh BlockHeader) []byte {
hash := sha256.New()
binary.Write(hash, binary.LittleEndian, bh.Version)
hash.Write(bh.HashPrevBlock)
hash.Write(bh.HashMerkleRoot)
binary.Write(hash, binary.LittleEndian, bh.Timestamp)
binary.Write(hash, binary.LittleEndian, bh.Bits)
binary.Write(hash, binary.LittleEndian, bh.Nonce)
data := sha256.Sum256(hash.Sum(nil))
return data[:]
}
Header hash byte[]:
[34 140 82 79 175 251 189 163 152 248 127 16 244 18 158 157 152 174 143 152 249 172 44 241 81 121 251 85 246 224 7 7]
Decode errors:
Header hash reversed:
[7 7 224 246 85 251 121 81 241 44 172 249 152 143 174 152 157 158 18 244 16 127 248 152 163 189 251 175 79 82 140 34]
Header hash as Integer:
3180110501919869770927571415789333083034902861520772082565710950573131598882
>>>Origin is NOT divisable by header hash.<<<
Program exited.
type BlockHeader struct {
// Standard Bitcoin fields.
Version uint32
HashPrevBlock []byte
HashMerkleRoot []byte
Timestamp uint32
Bits uint32
Nonce uint32
}
// HeaderHash calculates the block header hash.
// This is the fixed multiplier when searching for primes.
// NOTE: When converting to an Int the hash must be reversed.
func (bh *BlockHeader) HeaderHash() []byte {
hash := sha256.New()
binary.Write(hash, binary.LittleEndian, bh.Version)
hash.Write(bh.HashPrevBlock)
hash.Write(bh.HashMerkleRoot)
binary.Write(hash, binary.LittleEndian, bh.Timestamp)
binary.Write(hash, binary.LittleEndian, bh.Bits)
binary.Write(hash, binary.LittleEndian, bh.Nonce)
data := sha256.Sum256(hash.Sum(nil))
return data[:]
}
// hashToBig converts a hash number to an integer
func hashToBig(hash []byte) *big.Int {
tmp := make([]byte, len(hash))
copy(tmp, hash)
reverse(tmp)
return new(big.Int).SetBytes(tmp)
}