RalphTro / epcis-event-hash-generator

ALGORITHM and SOFTWARE PROTOTYPE to uniquely identify/validate the integrity of any EPCIS event through a common, syntax-agnostic approach based on hashing. Takes an EPCIS Document (formatted in either XML or JSON-LD) and returns the corresponding hash value(s).
MIT License
8 stars 4 forks source link

Should we ignore eventID field while calculating hash? #41

Closed dakbhavesh closed 3 years ago

dakbhavesh commented 3 years ago

Hi @RalphTro,

Observed that the current algorithm considers the value of eventID field while calculating the hash. I am wondering if that makes sense or not. Assume that user calculated event hash and populated it in eventID field, when user calculates the hash of the same event again it will not match with populated value inside eventID because algorithm factors in the value of eventID field. This may confuse the user.

If a user wants to match the hash with what is populated in eventID, first s/he needs to remove eventID field and then generate hash.

What do you think?

RalphTro commented 3 years ago

Dear @dakbhavesh , You are absolutely correct that considering the hashID field would not make sense. So, when calculating the hash, the value of eventID MUST be ignored. May I ask in which software module you found that? The property order does not include this field. The only field it DOES contain though is the correctiveEventIDs list, which however, IMO, should be included, should'nt they? Thanks, as always, for your continuous support.

dakbhavesh commented 3 years ago

Dear @RalphTro, Found this behavior while I was testing the fix related to ignoring comment field manually. Wasn't detected by any special tool :)

To your question regarding correctiveEventIDs, yes, it should be included for hash calculation. I will do a round of testing around it as well.

RalphTro commented 3 years ago

As of the latest PR merge, I think we can close the issue.

Echsecutor commented 3 years ago

The eventID was accidentally added as part of handling user extensions anywhere. There was some discussion of whether to include eventID into the hash if given. It could be a non-hash ID, e.g. a UUID, as per EPCIS 1.2. I think we decided eventually to not include it. Thanks for spotting this @dakbhavesh !