Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDF: Serialise/parse to optionally encrypt/decrypt #4

Closed
gjwgit opened this issue Sep 23, 2022 · 7 comments
Closed

RDF: Serialise/parse to optionally encrypt/decrypt #4

gjwgit opened this issue Sep 23, 2022 · 7 comments
Assignees

Comments

@gjwgit
Copy link
Contributor

gjwgit commented Sep 23, 2022

For a Trust No ONe context, allow optional encryption key argument to parse() and serialise() to decrypt/encrypt.

Perhaps use ttc for encrypted ttl files.

@tian3rd
Copy link
Contributor

tian3rd commented Sep 23, 2022

Will first try the following two for file encryption and decryption:

  1. https://pub.dev/packages/encrypt
  2. https://pub.dev/packages/aes_crypt

@gjwgit
Copy link
Contributor Author

gjwgit commented Sep 23, 2022

Also have a look at what Anushka has done - he already has the encryption/decryption implemented in the indi and comm apps.

@tian3rd
Copy link
Contributor

tian3rd commented Sep 24, 2022

Also have a look at what Anushka has done - he already has the encryption/decryption implemented in the indi and comm apps.

Good idea! I'll check Anushka's code first!

@tian3rd
Copy link
Contributor

tian3rd commented Sep 27, 2022

After discussion with Anushka, I understand that for this package, we don't need to worry about Solid Pod side, and just focusing on encryption and decryption of the triple data, and then write/read encrypted/decrypted data to/from the file.

So it's a two-part task:

  • Optional encryption of data (AES for now) in serializing
  • Optional decryption of data in parsing

@tian3rd
Copy link
Contributor

tian3rd commented Sep 27, 2022

For encryption, Anushka suggested using a hashed key in the encrypted ttl file, which is useful when we want to check if the key is correct without the need to try decrypting the file (potentially very large thus time-consuming). So the encrypted ttl file will have the following format:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

rdf:subject rdf:type "encrypted"^^xsd:string ;
    xsd:token "936a185caaa266bb9cbe981e9e05cb78"^^xsd:string ;
    rdf:value "Fyc2DmEed6gx44lq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CcCq60qpOSumS/A/cld+emA=="^^xsd:string .

which is the encrypted version of the following ttl file:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh-data: <http://silo.net.au/data/SOLID-Health#> .
@prefix sh-onto: <http://sii.cecs.anu.edu.au/onto/SOLID-Health#> .

sh-data:AssessmentTab-p43623-20220727T120913 rdf:type owl:NamedIndividual ;
    rdf:type sh-onto:AssessmentTab ;
    sh-onto:asthmaControl "Poor Control"^^xsd:string ;
    sh-onto:diastolicBloodPressure "75"^^xsd:int ;
    sh-onto:systolicBloodPressure "125.0"^^xsd:float .

sh-data:SeeAndDoTab-p43623-20220727T120913 rdf:type owl:NamedIndividual ;
    sh-onto:hasSeeAndDoOption sh-data:SeeAndDoOption-p43623-20220727T120913-fitnessDrive .

sh-data:SeeAndDoOption-p43623-20220727T120913-fitnessDrive rdf:type owl:NamedIndividual .

We specify three triples in the encrypted ttl file:

  1. the first triple indicates this is an encrypted file (optional, can be omitted)
  2. the second triple specifies the hashed key (the key is for the AES encryption/decryption)
  3. the third triple contains the encrypted data of the whole original ttl file

The subjects and predicates of the second and third line can be modified based on our ontology in the future (e.g. CECS namespaces), here we use the RDF and XSD standard namespaces as placeholders.

@tian3rd
Copy link
Contributor

tian3rd commented Sep 27, 2022

Hi @gjwgit sorry I just noticed that you suggested using ttc for encrypted ttl file. So is there any standard format for this specific file format? Or is it similar to ttl turtle syntax?

(The current version uses .enc.ttl which is also a valid ttl file, we can modify it based on our needs)

@gjwgit
Copy link
Contributor Author

gjwgit commented Sep 27, 2022

.enc.ttl makes sense since it is a valid ttl file.

@gjwgit gjwgit closed this as completed Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants