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

dark-crystal HTTP API #46

Open
m4gpi opened this issue Jan 15, 2019 · 1 comment
Open

dark-crystal HTTP API #46

m4gpi opened this issue Jan 15, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@m4gpi
Copy link
Member

m4gpi commented Jan 15, 2019

This is different from #45. A Dark Crystal HTTP API would open up the a set of end-points to scuttle-dark-crystal (rather than just the secrets wrapper), enabling other applications to use Dark Crystal and Scuttlebutt via a set of end-points.

This is a larger body of work than the secrets wrapper API. It requires creating a scuttlebot server instance (or connecting to an existing instance, see scuttle-shell) and initialising scuttle-dark-crystal there, and exposing its access to and interaction with the SSB database as a HTTP API.

Includes the following end-points:

// gets the ritual and its component parts
GET /v1/rituals/:id

// performs the ritual, requires parameters
POST /v1/share

// Gets the requests applicable to a specific root / ritual
GET /v1/requests/:id
POST /v1/requests/:id

// requests have a one-to-one relationship to replies
GET /v1/requests/:id/reply
POST /v1requests/:id/reply

// returns the secret, requires parameters
POST /v1/recombine/:id

// forwards shards to a recipient, requires parameters
POST /v1/forwards

An example use-case:

var params = {
  name: 'My first Dark Crystal',
  label: 'Bitcoin Private Key',
  secret: 'KyP4ki12YcX2Fo4gw6DRdF2HcWP81tVAUXFEPTtCtsa52gAHu9bb',
  quorum: 3,
  recipients: [
    '@vEJe4hdnbHJl549200IytOeA3THbnP0oM+JQtS1u+8o=.ed25519',
    '@NeB4q4Hy9IiMxs5L08oevEhivxW+/aDu/s/0SkNayi0=.ed25519',
    '@MpDd66GPXgN1+eMNrZInHkWq1THMurWwLdMx8BZ1ncw=.ed25519'
  ]
}

request('http://localhost:8187/v2/share', params, (err, response) => {
  // Returns a JSON response object
  console.log(response)
  // Looks something like...
  // {
  //   code: 200,
  //   body: {
  //     rootId,
  //     ritualId,
  //     name,
  //     label,
  //     quorum,
  //     shards: [...]
  //   }
  // }
})
@m4gpi m4gpi added the enhancement New feature or request label Jan 15, 2019
@samparsky
Copy link

@KGibb8 this quite interesting, I will start work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants