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

Case in which bare string notation does not work + eventType appended at unexpected position #77

Closed RalphTro closed 1 year ago

RalphTro commented 1 year ago

Dear @Echsecutor ,

I just found an interesting case (in branch bare_string_normalisation', where bare strings are not expanded to their full URI.

In addition, 'ObjectEvent' is not appended after eventType, but after the bizLocation id.

FYC, here is the jsonld file I used:

{ "@context": [ "https://ref.gs1.org/standards/epcis/2.0.0/epcis-context.jsonld", { "abc": "https://ns.abc.de/epcis/", "example": "http://ns.example.com/epcis/", "fgh": "https://ns.fgh.co.uk/epcis/", "schema": "https://schema.org/", "sdo": "https://schema.org/" } ], "type": "EPCISDocument", "schemaVersion": "2.0", "creationDate": "2005-07-11T11:30:47.0Z", "epcisBody": { "eventList": [ { "type": "ObjectEvent", "action": "OBSERVE", "bizStep": "receiving", "disposition": "in_progress", "epcList": [ "https://id.gs1.org/01/70614141123451/21/2018" ], "eventTime": "2005-04-04T20:33:31.116-06:00", "eventTimeZoneOffset": "-06:00", "readPoint": { "id": "urn:epc:id:sgln:0012345.11111.400" }, "bizLocation": { "id": "urn:epc:id:sgln:0012345.11111.0" }, "fgh:a-date": "2023-10-09", "example:myField": "Example of a vendor/user extension", "abc:a-integer": 2, "abc:z-integer": 1, "schema:award": "Order of Standards", "schema:mpn": "4711", "sdo:nsn": "4712" } ] } }

...and here the pre-hash string which was returned:

eventType= eventTime=2005-04-05T02:33:31.116Z eventTimeZoneOffset=-06:00 epcList epc=https://id.gs1.org/01/70614141123451/21/2018 action=OBSERVE bizStep=receiving disposition=in_progress readPointid=https://id.gs1.org/414/0012345111112/254/400 bizLocation id=https://id.gs1.org/414/0012345111112 type=ObjectEvent {http://ns.example.com/epcis/}myField=Example of a vendor/user extension {https://ns.abc.de/epcis/}a-integer=2 {https://ns.abc.de/epcis/}z-integer=1 {https://ns.fgh.co.uk/epcis/}a-date=2023-10-09 {https://schema.org/}award=Order of Standards {https://schema.org/}mpn=4711 {https://schema.org/}nsn=4712

Many thanks in advance for looking into this as soon as time permits.

Kind regards, Ralph

Echsecutor commented 1 year ago

tryed the examnple. works on my machine.

$ ./epcis_event_hash_generator/__main__.py -pj '\n' tests/examples/ralfsChaosExample.jsonld 

Hashes of the events contained in 'tests/examples/ralfsChaosExample.jsonld':
ni:///sha-256;4ea20fa9f095f68bdd90297f7daed5f3e164070e55081b2f0b7cd41ad03a81bf?ver=CBV2.0

Pre-hash strings:
eventType=ObjectEvent
eventTime=2005-04-05T02:33:31.116Z
eventTimeZoneOffset=-06:00
epcListepc=https://id.gs1.org/01/70614141123451/21/2018
action=OBSERVE
bizStep=https://ref.gs1.org/cbv/BizStep-receiving
disposition=https://ref.gs1.org/cbv/Disp-in_progress
readPointid=https://id.gs1.org/414/0012345111112/254/400
bizLocationid=https://id.gs1.org/414/0012345111112
{http://ns.example.com/epcis/}myField=Example of a vendor/user extension
{https://ns.abc.de/epcis/}a-integer=2
{https://ns.abc.de/epcis/}z-integer=1
{https://ns.fgh.co.uk/epcis/}a-date=2023-10-09
{https://schema.org/}award=Order of Standards
{https://schema.org/}mpn=4711
{https://schema.org/}nsn=4712
Echsecutor commented 1 year ago

added your example: https://github.com/RalphTro/epcis-event-hash-generator/pull/76/files#diff-82592051557cf103c3a670dfd4bb2b7c9059e5a07d31149f0706f9d8119725d6

RalphTro commented 1 year ago

Works now