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 the Hash id generated by XML event and respective JSON/JSON-LD event be same? #70

Closed Aravinda93 closed 1 year ago

Aravinda93 commented 2 years ago

@RalphTro @Echsecutor

Hello,

We came across a scenario where Hash-id generated for XML event and its converted JSON/JSON-LD event is different so we wanted to confirm if it needs to be the same or if this is expected behavior?

For example: We tried to generate an event hash following a simple event in XML format:

<?xml version='1.0' encoding='UTF-8'?>
<epcis:Document xmlns:epcis="urn:epcglobal:epcis:xsd:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cbvmda="urn:epcglobal:cbv:mda:" schemaVersion="1.2" creationDate="2019-10-21T14:59:02.099+02:00">
  <EPCISBody>
    <EventList>
      <ObjectEvent>
        <eventTime>2019-10-21T10:00:30Z</eventTime>
        <eventTimeZoneOffset>+01:00</eventTimeZoneOffset>
        <action>OBSERVE</action>
        <bizStep>urn:epcglobal:cbv:bizstep:shipping</bizStep>
        <disposition>urn:epcglobal:cbv:disp:in_transit</disposition>
      </ObjectEvent>
    </EventList>
  </EPCISBody>
</epcis:Document>

For the above event we received the following event hash id: ni:///sha-256;508c04775b92e088ff199ced46aa3120791f8a907430541fa64ab30c49aa6d9e?ver=CBV2.0

We converted the same event to JSON:

{
  "@context": [
    "https://gs1.github.io/EPCIS/epcis-context.jsonld"
  ],
  "type": "EPCISDocument",
  "schemaVersion": "1.2",
  "creationDate": "2019-10-21T14:59:02.099+02:00",
  "epcisBody": {
    "eventList": [
      {
        "type": "ObjectEvent",
        "eventTime": "2019-10-21T10:00:30.000Z",
        "eventTimeZoneOffset": "+01:00",
        "action": "OBSERVE",
        "bizStep": "shipping",
        "disposition": "in_transit"
      }
    ]
  }
}

For the above event we received the following event hash id: ni:///sha-256;8001402aeb8e39fb2d595ed3ac479d7cd462343acbd2eb7db9912f30ec7c6283?ver=CBV2.0

As we can see for the same event in XML and JSON/JSON-LD format we are receiving different hash ids so we would like to confirm if this is expected?

We believe this maybe be happening due to the bare string notation used in JSON/JSON-LD event format due to which we have differences in some of the fields such as bizStep and disposition.

CC: @dakbhavesh

RalphTro commented 2 years ago

Dear @Aravinda93 , Nice to hear from you and thanks for making us aware of this. You are correct that one and the same EPCIS event must result in an identical hash value irrespective if it is formatted in XML or JSON/JSON-LD. We anyway still have to make a couple of further adjustments @Echsecutor and I intend to tackle after EPCIS/CBV 2.0's ratification. Kind regards and all the best, @RalphTro

Aravinda93 commented 2 years ago

Dear @RalphTro,

Thanks a lot for the response and confirmation :) Wish you a great day ahead :)

Kind regards, Aravinda

Echsecutor commented 2 years ago

@Aravinda93 your suspicion is correct, the bare string notation is not yet properly normalised. We will fix this in https://github.com/RalphTro/epcis-event-hash-generator/pull/66

edit: to make this more explicit: https://github.com/RalphTro/epcis-event-hash-generator/issues/72

RalphTro commented 1 year ago

Dear @Aravinda93, From my POV, this can be closed from my POV; all tasks related to this issue have been addressed. Would you agree?

Aravinda93 commented 1 year ago

Dear @RalphTro

Since you have provided the confirmation that XML and JSON event hash should be same and we will be testing it during the development to ensure everything is correct, let us close this issue to avoid any confusion with actual issues.

RalphTro commented 1 year ago

Gladly!