Skip to content

Commit

Permalink
Merge pull request #3 from vchik795/bugfix/AN-1592
Browse files Browse the repository at this point in the history
Verification of files notarized via /hashes entry-point supported
  • Loading branch information
Diamond16 authored Mar 22, 2019
2 parents 51e90ed + d8a696c commit 6f67493
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {

app := cli.NewApp()
app.Name = "Verifyhash"
app.Version = "2.0"
app.Version = "2.1"
app.Compiled = time.Now()
app.Copyright = "(c) 2016 Acronis International GmbH"
app.Usage = "Acronis Notary verify hash CLI utility"
Expand Down
10 changes: 8 additions & 2 deletions verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ func verifyMerkleProof(proof gomerkle.Proof, root, eTag string) error {
return errInvalidRoot
}

value := sha256.Sum256([]byte(eTag))
tree := gomerkle.NewTree(sha256.New())
valid := tree.VerifyProof(proof, rootByte, value[:])
eTagByte, _ := hex.DecodeString(eTag)
valid := tree.VerifyProof(proof, rootByte, eTagByte)
if valid {
return nil
}

value := sha256.Sum256([]byte(eTag))
valid = tree.VerifyProof(proof, rootByte, value[:])
if !valid {
return errors.New("Invalid proof or eTag")
}
Expand Down

0 comments on commit 6f67493

Please sign in to comment.