Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate mixHash in the istanbul concensus? #1084

Closed
tkblack opened this issue Oct 19, 2020 · 3 comments
Closed

How to calculate mixHash in the istanbul concensus? #1084

tkblack opened this issue Oct 19, 2020 · 3 comments
Assignees

Comments

@tkblack
Copy link

tkblack commented Oct 19, 2020

I wrote a test case like this:

func TestHash(t *testing.T) {
	src := []byte("Istanbul practical byzantine fault tolerance")
	fmt.Printf("sha3 hash : %x\n", Keccak256(src))

	h := sha256.New()
	h.Write(src)
	fmt.Printf("sha256 hash : %x\n", h.Sum(nil))

}

And it print this:

sha3 hash : 01c335602a9bb4eff135d2e5a063b631bbfd1f589ae13d62ceea41a2732ca2ae
sha256 hash : 92738e249a9ed02e0b062fdc7e3d32a0fcb055a6d0a6879537c5532fad1d0632

However,it is not the same as in the code

// IstanbulDigest represents a hash of "Istanbul practical byzantine fault tolerance"
// to identify whether the block is from Istanbul consensus engine
IstanbulDigest = common.HexToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365")

So,It confused me,could you please tell me the calculation process.

@jbhurat jbhurat self-assigned this Oct 28, 2020
@jbhurat
Copy link
Contributor

jbhurat commented Oct 28, 2020

Hi @tkblack, you are right, IstanbulDigest is not Keccak256 or sha256 hash of Istanbul practical byzantine fault tolerance. From the original IBFT EIP, it is a fixed magic number for Istanbul block identification and the original EIP doesn't mention how the hash is derived.

@jbhurat
Copy link
Contributor

jbhurat commented Nov 2, 2020

Closing the issue due to inactivity. Please reopen for any follow up questions or queries.

@jbhurat jbhurat closed this as completed Nov 2, 2020
@tkblack
Copy link
Author

tkblack commented Nov 3, 2020

@jbhurat Sorry for the late reply and thanks for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants