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

Extend Issuing Facts Payload to Include Objects #323

Open
adriacidre opened this issue Jun 20, 2024 · 0 comments
Open

Extend Issuing Facts Payload to Include Objects #323

adriacidre opened this issue Jun 20, 2024 · 0 comments
Assignees

Comments

@adriacidre
Copy link
Contributor

Description:

The current implementation of the issuing facts payload looks like this:

{
  "typ": "identities.facts.issue",
  "iss": "@jwt.id",
  "aud": "@to",
  "sub": "@to",
  "iat": "SelfSDK::Time.now.strftime('%FT%TZ')",
  "exp": "(SelfSDK::Time.now + @exp_timeout).strftime('%FT%TZ')",
  "cid": "@id",
  "jti": "SecureRandom.uuid",
  "status": "verified",
  "attestations": [{
    "sub": "@to",
    "iss": "@origin",
    "iat": "SelfSDK::Time.now.strftime('%FT%TZ')",
    "source": "my_custom_source",
    "fact": "my_custom_fact",
    "value": "eyJpYXQiOiIyMDI0LTA0LTE3VDA3OjU5OjUwLjYxOTMxNDUwNVoiLCJpbWFnZV9oYXNoIjoiYk9qQVpWNjZEWjBpRTF1T2NiV3RVSFFMbThLa29RY05oLVFRbWl3OVJfVSIsImlzcyI6InNlbGZfdmVyaWZpY2F0aW9uIiwianRpIjoiNjIyNmJkNjQtZGYwNC00NjUwLWE2YTQtZDQ1YWQ5ZWZjYmQyIiwic291cmNlIjoicGFzc3BvcnQiLCJzdWIiOiI2MzQ1NDI3NTMyMyIsInZlcmlmaWVkIjp0cnVlfQ",
    "operator": "@operator"
  }]
}

This implementation works fine for plain attestations but needs to be extended to accommodate attestations with attached objects.

Proposed Solution:

We will extend this behavior by adding the objects field. The updated payload structure will look like this:

{
  "typ": "identities.facts.issue",
  "iss": "@jwt.id",
  "aud": "@to",
  "sub": "@to",
  "iat": "SelfSDK::Time.now.strftime('%FT%TZ')",
  "exp": "(SelfSDK::Time.now + @exp_timeout).strftime('%FT%TZ')",
  "cid": "@id",
  "jti": "SecureRandom.uuid",
  "status": "verified",
  "attestations": [{
    "sub": "@to",
    "iss": "@origin",
    "iat": "SelfSDK::Time.now.strftime('%FT%TZ')",
    "source": "my_custom_source",
    "fact": "my_custom_fact",
    "value": "eyJpYXQiOiIyMDI0LTA0LTE3VDA3OjU5OjUwLjYxOTMxNDUwNVoiLCJpbWFnZV9oYXNoIjoiYk9qQVpWNjZEWjBpRTF1T2NiV3RVSFFMbThLa29RY05oLVFRbWl3OVJfVSIsImlzcyI6InNlbGZfdmVyaWZpY2F0aW9uIiwianRpIjoiNjIyNmJkNjQtZGYwNC00NjUwLWE2YTQtZDQ1YWQ5ZWZjYmQyIiwic291cmNlIjoicGFzc3BvcnQiLCJzdWIiOiI2MzQ1NDI3NTMyMyIsInZlcmlmaWVkIjp0cnVlfQ",
    "operator": "@operator"
  }],
  "objects": [{
    "name": "title of the object",
    "object_hash": "image hash from attestation",
    "link": "https://api.joinself.com/v1/objects/365d0bb4-cceb-4169-9e64-4be0fcd0cbc9",
    "key": "Base64URL(ChaCha20Poly1305Itef-Secret-Key + Nonce)",
    "expires": 1613738969,
    "mime": "image/jpeg"
  }]
}

The SDK will internally issue an attestation replacing the original fact name my_custom_fact with an attestation for the fact name object_hash.

Querying Issued Facts:

When the developer wants to retrieve these issued facts, they will send an identities.facts.query.req for the attested fact name:

{
   "typ": "identities.facts.query.req",
   "iss": "379bb3700a922d63ff54396ad4a8ba31",
   "sub": "70824808045",
   "iat": "2020-12-15T08:39:11Z",
   "exp": "2020-12-15T08:54:11Z",
   "cid": "89023e37-ec35-4616-9564-60c63d39b898",
   "jti": "a6632d64-dc55-4435-a4e8-1fef98cd33aa",
   "facts": [{
    "fact": "my_custom_fact", 
    "sources": ["my_custom_source"]
   }],
   "auth": false
}

This will produce a response like:

{
  "typ": "identities.facts.query.resp",
  "iss": "3dfbf487-0cdb-4e56-abda-ec60882794d8",
  "sub": "19105789134",
  "aud": "3dfbf487-0cdb-4e56-abda-ec60882794d8",
  "iat": "2022-05-04T09:54:21Z",
  "exp": "2022-05-04T10:54:21Z",
  "cid": "7da2d46b-8279-4e81-8e8c-f62d07bc13ad",
  "jti": "de92575e-090b-42b8-9f0b-14ccf8c9f598",
  "status": "accepted",
  "facts": [{
    "fact": "my_custom_fact",
    "attestations": ["eyJpYXQiOiIyMDI0LTA0LTE3VDA3OjU5OjUwLjYxOTMxNDUwNVoiLCJpbWFnZV9oYXNoIjoiYk9qQVpWNjZEWjBpRTF1T2NiV3RVSFFMbThLa29RY05oLVFRbWl3OVJfVSIsImlzcyI6InNlbGZfdmVyaWZpY2F0aW9uIiwianRpIjoiNjIyNmJkNjQtZGYwNC00NjUwLWE2YTQtZDQ1YWQ5ZWZjYmQyIiwic291cmNlIjoicGFzc3BvcnQiLCJzdWIiOiI2MzQ1NDI3NTMyMyIsInZlcmlmaWVkIjp0cnVlfQ"]
  }],
  "objects": [{
    "name": "title of the object",
    "object_hash": "image hash from attestation",
    "link": "https://api.joinself.com/v1/objects/365d0bb4-cceb-4169-9e64-4be0fcd0cbc9",
    "key": "Base64URL(ChaCha20Poly1305Itef-Secret-Key + Nonce)",
    "expires": 1613738969,
    "mime": "image/jpeg"
  }],  
  "auth": false
}

The SDK will return the object_hash field value as the attestation value, and will map the objects with this hash on the object_hash as attached to the current attestation.

@adriacidre adriacidre self-assigned this Jun 20, 2024
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

1 participant