blockchain-certificates / BlockcertsFramework-iOS

An iOS wallet for viewing, validating, and sharing certs
MIT License
20 stars 15 forks source link

Implement v1.2 local hash calculation, pending JSON LD normalization library #14

Closed kimdhamilton closed 8 years ago

kimdhamilton commented 8 years ago

We need the ability to perform JSON LD normalization in order to perform the v1.2 local hash. This doesn't appear to be available for Flask yet.

bedinotti commented 8 years ago

This is mentioned in the #developers channel, but we've hit a problem the JSON-LD normalization. Our existing v1.2 certs aren't valid JSON-LD because of a design constraint where @type and type are treated as the same key. https://github.com/json-ld/json-ld.org/issues/402

As such, the javascript implementation of the JSON-LD toolset complains that v1.2 certificates have colliding keywords.

screen shot 2016-09-22 at 4 24 20 pm
bedinotti commented 8 years ago

Found the root issue. Our format currently adds an extra "@type" key to the receipt block. That's a Chainpoint v2 receipt, and their json-ld schema follows the emerging standard of aliasing "type" to "@type". Since we're trying to use that standard, the problem isn't with the JSON-LD parser or the schema, but instead with how we're creating the certificates. Indeed, v1.2 certificates we've created so far will (correctly) fail JSON-LD parsing.

On the plus side, the WKWebKit bridge I'm using to run jsonld.js totally works as a stop-gap measure until we invest time in an iOS native JSON-LD library. It's been incorporated into the validation mechanism and tested with a v1.2 certificate that has been modified to pass JSON-LD parsing. Unfortunately, that's not a fully conclusive test, since it (correctly) fails validation comparing local to signed hashes.

I'm going to leave this issue open until I can manually verify a published certificate.