Skip to content

tykntech/indy-rest-service

Repository files navigation

Node.js CI

Tykn's REST service

This is Tykn’s alternative to communicate with Hyperledger Indy nodes. With this service it’s possible to send REST requests to the nodes without needing ZeroMQ a complex messaging system.

Currently it is already hard to onboard new developers to Indy and Self-Sovereign Identity as both require a lot of knowledge around blockchain, asynchronous cryptography, verifiable credentials, decentralised identifiers (DIDs) and digital identity. Putting another communication paradigm in just makes it harder. So, we decided to build a tool that could facilitate communication, creating this REST interface that any client can call to read and write to any Hyperledger Indy node.


How to deploy it

Pre-requirements:

  1. A node-js 10+ environment
  2. Internet access or an Hyperledger Indy node running locally

First, clone this repository:

git clone git@github.com:tykntech/indy-rest-service.git

Then go into the cloned folder:

cd indy-rest-service

As it is a NodeJS service, you need to install the dependencies:

npm i

An then start the service:

npm start // npm mon for nodemon

Open API Spec 3.0

Try our OpenAPI 3.0 spec at: http://rest-api.tykn.tech/doc


How it works?

The API expects a transaction object built following the INDY specs. Usually, the INDY-SDK builds those transactions.

A transaction-builder tool is being developed to help build transactions but, meanwhile, it needs to be done manually.

  1. Create a transaction (ATTRIB/NYM/SCHEMA/CRED_DEF/SCHEMA).
// NYM transaction --- Signatures are just an example
{
  "operation": {
    "type": "1",
    "dest": "LnXR1rPnncTPZvRdmJKhJQ",
    "role": "0",
    // 000000000000000000000000Trustee2
    "verkey": "BnSWTUQmdYCewSGFrRUhT6LmKdcCcSzRGqWXMPnEP168"
  },
  "taaAcceptance": {
    "taaDigest": "8cee5d7a573e4893b08ff53a0761a22a1607df3b3fcd7e75b98696c92879641f",
    "mechanism": "product_eula",
    "time": 1583798400
  },
  "identifier": "Th7MpTaRZVRYnPiabds81Y",
  "reqId": 1583864223,
  "protocolVersion": 2,
  "signatures": {
    // 000000000000000000000000Steward1
    "Th7MpTaRZVRYnPiabds81Y": "4z6WfmWonquBEG8SzbALJYXTVJNseiJGAxjrejrCXduGACSCY1ViEMxPp3sjHSh9rHsF7byuvXQVbUpmPCqvmfDE",
    // 000000000000000000000000Trustee1
    "V4SGRU86Z58d6TV7PBUe6f": "345W7oCrC6GupUhmKeaZ5X6fQ72so8XcCKqu12nQzMYWdZJWwRtABdwS9ZNpDVGW53f5no4HiDAz1ni4Dxe4gDmu"
  }
}
// SCHEMA transaction example
{
  "operation": {
    "type": "101",
    "data": {
      "version": "1.0",
      "name": "Degree",
      "attr_names": [
        "undergrad",
        "last_name",
        "first_name",
        "birth_date",
        "postgrad",
        "expiry_dat"
      ]
    }
  },
  "taaAcceptance": {
    "taaDigest": "8cee5d7a573e4893b08ff53a0761a22a1607df3b3fcd7e75b98696c92879641f",
    "mechanism": "product_eula",
    "time": 1583798400
  },
  "identifier": "Th7MpTaRZVRYnPiabds81Y",
  "reqId": 1583853291,
  "protocolVersion": 2,
  "signatures": {
    "Th7MpTaRZVRYnPiabds81Y": "8FQijmUrd1ML45nQD3MZ8Ugb9VMyyxWFNyypeNT8d4XKeP66d2VLNUE1SXMZB7PyhM6BU8ZDYJUPF4SAWJoiMoi"
  }
}
// AML transaction example
{
  "operation": {
    "type": "5",
    "version": "1.0",
    "aml": {
      "eula": "Included in the EULA for the product being used",
      "service_agreement": "Included in the agreement with the service provider managing the transaction",
      "click_agreement": "Agreed through the UI at the time of submission",
      "session_agreement": "Agreed at wallet instantiation or login"
    },
    "amlContext": "http://aml-context-descr"
  },
  "identifier": "Th7MpTaRZVRYnPiabds81Y",
  "reqId": 1583864614,
  "protocolVersion": 2,
  "signatures": {
    "Th7MpTaRZVRYnPiabds81Y": "3GDAqEQ5VUtEz3ytk2dUQymgmZ5UAKNPF8U4jrvXfG53ZFCyTZ2FadV9xpVtiyVuFNbujoaupSRTBkAQJ1u7nXLZ",
    "V4SGRU86Z58d6TV7PBUe6f": "3Zr2fhcWe5T2bNpUF3SY7CmaY9yN596QwPz58tyHoXLLC7gjo2b1btWkqGDs6SGX1UDpLHky6pPebJFWAcCj1CWd"
  }
}
// TAA transaction example
{
  "operation": {
    "type": "4",
    "version": "1.0",
    "text": "Here goes some acceptance text ..."
  },
  "identifier": "Th7MpTaRZVRYnPiabds81Y",
  "reqId": 1583864570,
  "protocolVersion": 2,
  "signatures": {
    "Th7MpTaRZVRYnPiabds81Y": "2TayPJ4CyWXhfLDJ7vbNXDg4ryH4oEbVeTeraGcDHXDgupaseedojiu7JsydPypWmiB8edGdtKEYasQcucnCAt4y",
    "V4SGRU86Z58d6TV7PBUe6f": "39mdgqDxzmePbJA9HnFVrVEdPNCrDW7RSARspt6aEzTvhVSdtbUnhti3D5ouCPgNox8EcP8TqhauZ8qjj2ke4Cew"
  }
}
// GET TAA data
{
  "operation": {
    "type": "6"
  },
  "identifier": "LibindyDid211111111111",
  "reqId": 1583864570,
  "protocolVersion": 2
}
// CLAIM_DEF
{
  "operation": {
    "type": "102",
    "ver": "1.0",
    "ref": 741,
    "signature_type": "CL",
    "tag": "TAG1",
    "data": {
      "primary": {
        "n": "118834095023884024284452287276628546809112422718810522756405412550056914578854162763298619881375780702602304661688886308662552291568782563268815530802914815846418531598576697548007495522039928371747074919744236866322954480041242568104844951753481010643904507176251871013428385594958726072890227480754245749895227474333144665447519075437020071135851322734753170559590861109723189780733881087598857032808659493514780202049161402201706821431457572601555461221281760477070980406973217702841779240841614684693427868660185703511969822845723703626472569983141865431467745084568082142435405504875540478964958145434910615070553",
        "s": "20558928175041710429400976776602772641660511037816468940257605219185167854489936096067699893124116321804099529665375057825331714124169555437800876004259299171546090354823919242452316320871208408188815500843689491429784432395607298409346456914942772952224165855094706686474499061999193828590949292852345130382361739045220295002106536134976006088690844048961067048475326058114159639279669165556415805361751070131201771109383710171353663808380743317757545572322574661621964685400932007505753132741202912998870396884653229738829378561769807583873275210341700335316507664328527992745638325786954089748391864456799048716270",
        "r": {
          "master_secret": "73839834489826460696934493623545202953523165300118537026294133286482378359416100624419904837726750063420510789492219812373950889194308297682551046245944321661515791521440826517385803588379221264364170341775438531353320240582846833393333191314291818374728366066648179351467908971563377294479997828751637418190947163916195932232498892995672300149773048683719028953300209242239284942687654610694922779523900942317379031989366900530344989793798612037692155277786376094390138059616761327508321749199161865567767056614876590447702420452045151907443487539763057255276191559777309312806205134198834995487886458397930045879563",
          "first_name": "70363512680958909462439305300835065823827605842192293596273082891910261093941837998817935647845359181790910999070247448157459501188303581383254137069333006615502289427152783536234748284461523065939365358497143882839053908766326955827822289019418617274067009343590228613262076514685135063835668517428330472734940294600557725262683898764762777238574546046879400265256370153056853389063911075124286922237411915173592238012543983018611256002660288724607088044346696843020585775623055424251090404910743776363339815218972936504834507674607686178802244085810294902792159724467130674413876204742550528041776930759397446454750",
          "status": "93801278405766671166925642974912138234484763244197074677259247987333751841147423550393560729282531934451497871718792519507823070743018527501134394922623669592153395364015689370995461293411744170026841572640738640649108989442187883365416896915215464465060163724913483494710625408412813277793136423086749985789107983512121387915818129634962116278777113764951858263881592114926725526954683349527757419175596706949684858873567417939769230620910361426671268485112379252073127384816579083438967417788730608168310935170816223369162314488286449373693873089168230415086489824742638060261266019079050452828110341198003046888423",
          "average": "21134051529556425094029530921851852861365235147403473604311143804286505971426476259236262968217135719532154349296759587426019900888084558458439003304354923918088677929709083462543144781247070249676687100888730556560666384079067368413508094054212914632047586180323234367637610941622359195138834487828998729469874583758564959382727540087864572394623025440387496856396481568240510737114479654463729532902985454746374865034066559591898059919390589719194612987610389360488232040189569497691102320667302600057956547232814598043879672767778824979352742800418539019211076172368943458204832188152941504417504970040613473516150",
          "ssn": "8690594708029774991783441123375055715705079336494815900236695360172057296740292706493818420049777294883995351856103856045861771822644877910408014822844634114028978757144348662604313892013593133354511419292537487898557666060292059039290784091621778564231788876875829227378693377417770107601301403648637589454406486389674855977086439278751713096425506879110907763756521633497398850107755557498551344634578184694565368570152418139732598705369320296999791122683045322597950283839107795892633578977270101249287704836816355786152904978570986967375472727386120410702068894300466688080768715651958779877674040799684099848273",
          "year": "27139640719206719128372059911117227610938517033750351731501390807514265397170923180472080914507384511596490784856103278664704991821107894323095929985998749207119380015396923009809816969113858072187054193811886116312376559541832331905484700097250650051923054240268419995059505339633995851889845657810902522949166641563227287294744142327650722332227320893666100215934772579539759890887410998275558588467008774656922080820948378007173970970905644021377170541940240201799969284103072040099307786719363486598946452738564790945086135491492863252447092821117230055198962379917771263149051812741331858413344118868463537846732",
          "last_name": "4729975662825221320713761187398466301360184382442066574118578157673253969529125660365321464562577906867039530060007716756238769766409149447560395203727968749221814898001716274388245659342324142361835520576348948622633091169018416390573586871015392798785244190461951194806578427558085791312293959850443539840757592403138279176309590131264839562621364906212928674290704887636394668498865492334362654248677103812614732115586174088239337352193537244770121911689144745217146638248579887845116159258845811268700095060898453022491700629985427962389114231625401281660555029490244078049206245880813589758307773692488419272024",
          "degree": "94592769614526088520534614072704079399586491885762014655296879081990896641016448404746225229875003990776201105695488469015362650480063562381300904893582899482444592313534439232788527909935178946879867774690495573849973510295502544430898776633206132049577036642973664563729076402918202209155966691009688802750060894161277166813687245740498476127618357681179767665963773573838076537526571116449825728171240760860498248851717835050256731616857012613696052728561528943132002373861389362787184486373901797204369081629474123061018640138573205749318803021757801240489135610333348023354044343469937878501205284578861579275931"
        },
        "rctxt": "39651243562862467195586957300907119447278606770243887665844114717902805876932839136679993965736378168100207184554804214363226202052990251124781436092441907226147421975073367535405249862287921065519114344178105925257506030240194063078404254065357462754619654726664651887905593958970124470435436635783503386065556922292399489285955081476476113403836305153467840337349159463018041146308398841895029212417933911332753856951336467749388206554721943041237744997198070166586172145184857639337249625622617118698319948331528914572707061855984071918811442182848675765768629158865163101891470003713104649114748251669628961820072",
        "z": "73086011835454030083013913371258092138848068466238369203847329362250127667737076381470243157803873675941821707898305804027299354570893251783224153101843089195330033741399384551682739070336295462313760552649178885953127201701034892942771759014648347476057601201616309657310952479419601189923773894205923572109970619022662162950480072862132003419562854774498602630042573259183207282851553426648294381142742621065977267756767039419488830186943981079333016735781404179909098894992162735160483553526682882825876862137917007908723111000837996861243407319854293475201221964815906084502465485088076160887987667113768202920740"
      }
    }
  },
  "taaAcceptance": {
    "taaDigest": "8cee5d7a573e4893b08ff53a0761a22a1607df3b3fcd7e75b98696c92879641f",
    "mechanism": "product_eula",
    "time": 1583798400
  },
  "identifier": "Th7MpTaRZVRYnPiabds81Y",
  "reqId": 1584709355,
  "protocolVersion": 2,
  "signatures": {
    "Th7MpTaRZVRYnPiabds81Y": "3XWDak8qp9gU7YFZ8E6M3GotkqWwXxLwCUqqto9c7oQVWG4iq2VsfmkhiDmPQVt9r4LvZxaQ2XGSg3pjrN1n7GGD"
  }
}
  1. Sign the transaction by the parties (you need to move the JSON around and sign it yourself)
Signing means hashing and adding a signature at the end of the JSON.
This can be achieved in many ways and we're also planning into providing a tool for that.
We can even use Hyperledger Aries to deal with this kind of communication.
  1. Send the signed transaction to the POST endpoint
It's important to notice that the transaction must be signed by the target of
the transaction as the node will accept to deploy such transaction

How to contribute?

We're still studying ways to improve this tool and we expect the community to help us with that.