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

Date format with pre-hash string #54

Closed clementh59 closed 2 years ago

clementh59 commented 3 years ago

Hi,

In rule 8 of the algorithm, you say:

All timestamps SHALL be expressed in UTC; the zero UTC offset SHALL be expressed with the capital letter 'Z'.

which means that timestamps can have a time offset, right?

This is indeed the case of the time field of a sensorMetadata. If you look at the example epcisDocWithSensorDataObjectEvent.jsonld, the pre-hash string is:

sensorMetadatatime=2019-04-02T14:05:00.000+01:00

(It keeps the offset so everything is working as expected)

However, when you look at the pre-hash string of the last event in SensorDataExamples.xml, we have this field:

<declarationTime>2020-09-29T15:00:00.000+02:00</declarationTime>

But in the pre-hash string, it converts the date like this:

declarationTime=2020-09-29T13:00:00.000

Is it the expected output? If it is the case, do I miss something in the algorithm?

Thanks a lot.

RalphTro commented 3 years ago

Dear @clementh59 ,

Good catch! You are correct. All timestamps should be converted to zero UTC.

I hope you do not need a fix urgently? ;-)

Kind regards and thanks again; Ralph

clementh59 commented 3 years ago

Dear @RalphTro ,

I see, thanks!

No, that's ok, I just want to be sure I understand the algorithm correctly :)

Regards,

Clément

Echsecutor commented 3 years ago

Ah, I see, in e.g. https://github.com/RalphTro/epcis-event-hash-generator/blob/master/tests/examples/epcisDocWithSensorDataObjectEvent.jsonld we are missing to convert the time stamp value of sensorMetadata->time to canonical (Z) form. @RalphTro Talking about the canonical time stamp form: how about using a simpler to serialise/de serialise form such as the numeric unix time stamp?

Echsecutor commented 3 years ago

@clementh59 many thanks for spotting this bug!

RalphTro commented 3 years ago

Ah, I see, in e.g. https://github.com/RalphTro/epcis-event-hash-generator/blob/master/tests/examples/epcisDocWithSensorDataObjectEvent.jsonld we are missing to convert the time stamp value of sensorMetadata->time to canonical (Z) form. @RalphTro Talking about the canonical time stamp form: how about using a simpler to serialise/de serialise form such as the numeric unix time stamp?

Hi @Echsecutor - THANKS A LOT for addressing this bug! Turning to your comment: from a mere technical POV, I think your suggestion makes sense; I see two issues with considering a change though: first, we are already in Public Community Review :-); second, it IMHO would be quite helpful if e.g. you have two implementations which return a different hash value and you want to compare the two underlying pre-hash strings. In such a situation, I think it's easier if one only needs to compare plain text values (in this case, the actual time stamps).