Skip to content

ImageUploadFlow

mckingho edited this page Jun 15, 2018 · 2 revisions

Image Upload flow

  • User submit an image file and metadata (description, license, etc) via the web interface of puttyimages

  • PuttyImage put and pin the image file onto IPFS and get image file IPFS address

  • PuttyImage create a Media IPLD object (see Media IPLD object)

  • PuttyImage put and pin the Media IPLD object onto IPFS and get Media IPLD object address

  • PuttyImage get the actual address of the LikeCoin ID and ask for a signature of the data

  • Puttyimage submit signed IPLD object to Like.co, which will put the record onto blockchain

  • User is told upload completed

Phase 1 LikeChain Flow

  • User / Frontend:
  1. user selects an image
  2. user fills in the metadata
  3. frontend code computes the sha256 hash of the image
  4. frontend code calls json-stable-stringify to construct the JSON string of metadata object (note that fingerprint and ownerId are inside metadata object)
  5. frontend code requires user to sign the JSON string using web3.eth.personal.sign and get ownerSig
  6. the image, metadata and ownerSig are sent to PuttyImages
  • PuttyImages:
  1. PuttyImages receives the image, metadata and ownerSig
  2. PuttyImages extracts necessary info (e.g. fingerprint, ownerId) from metadata
  3. PuttyImages gets the owner address by querying like.co
  4. PuttyImages computes the fingerprint of the image
  5. PuttyImages validates the metadata (check fields, check fingerprint matching the one recorded in metadata, etc)
  6. PuttyImages verifies the signature by constructing the same JSON string and checking the recovered address from the signature is the same as the owner address from step 3
  7. PuttyImages puts and pins the image onto IPFS and get the IPFS adddress
  8. PuttyImages constructs an object { likeIpfs: (IPFS address), metadata }, gets its JSON string using json-stable-stringify and signs it using the private key of PuttyImages to get storageProviderSig (the meaning is that PuttyImages promises that it has verified the image hash and will pin the image on IPFS)
  9. PuttyImages submits the metadata, ownerSig, IPFS Address, storageProviderSig to LikeChain (interface: RESTful POST /upload, application/json, {likeIpfs, metadata, ownerSig, storageProvider: 'puttyimages', storageProviderSig})
  10. PuttyImages gets the returned object from LikeChain, extracts metadataIpldAddr from it, and stores necessary info into database
  • LikeChain:
  1. LikeChain receivers likeIpfs, metadata, ownerSig, storageProvider: 'puttyimages', storageProviderSig
  2. LikeChain validates the metadata
  3. LikeChain verifies ownerSig like PuttyImages
  4. LikeChain verifies storageProvider and storageProviderSig by its own record (storage providers are pre-registered)
  5. LikeChain puts and pins the { likeIpfs, metadata } object onto IPLD and gets back the IPLD address
  6. LikeChain updates its own key-value record to map fingerprint to metadata IPLD address
  7. LikeChain returns the IPLD address to PuttyImages ({ status: 'success', metadataIpldAddr }

Clone this wiki locally