Simple merkle rfc compatibility (#2713)

* Begin simple merkle compatibility PR

* Fix query_test

* Use trillian test vectors

* Change the split point per RFC 6962

* update spec

* refactor innerhash to match spec

* Update changelog

* Address @liamsi's comments

* Write the comment requested by @liamsi
This commit is contained in:
Dev Ojha
2019-01-13 17:02:38 -06:00
committed by Ethan Buchman
parent 1f68318875
commit ec53ce359b
15 changed files with 233 additions and 112 deletions

View File

@ -66,14 +66,13 @@ func TestValidTxProof(t *testing.T) {
root := txs.Hash()
// make sure valid proof for every tx
for i := range txs {
leaf := txs[i]
leafHash := leaf.Hash()
tx := []byte(txs[i])
proof := txs.Proof(i)
assert.Equal(t, i, proof.Proof.Index, "%d: %d", h, i)
assert.Equal(t, len(txs), proof.Proof.Total, "%d: %d", h, i)
assert.EqualValues(t, root, proof.RootHash, "%d: %d", h, i)
assert.EqualValues(t, leaf, proof.Data, "%d: %d", h, i)
assert.EqualValues(t, leafHash, proof.LeafHash(), "%d: %d", h, i)
assert.EqualValues(t, tx, proof.Data, "%d: %d", h, i)
assert.EqualValues(t, txs[i].Hash(), proof.Leaf(), "%d: %d", h, i)
assert.Nil(t, proof.Validate(root), "%d: %d", h, i)
assert.NotNil(t, proof.Validate([]byte("foobar")), "%d: %d", h, i)