New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sovrin-did

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sovrin-did

node.js module to generate DID and Ed25519 keys to use with Sovrin

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46
increased by130%
Maintainers
1
Weekly downloads
 
Created
Source

node-sovrin-did

build status

node.js module to generate DID and Ed25519 keys to use with Sovrin

Install

$ npm i sovrin-did

Example

var sovrinDID = require("sovrin-did");

var d = sovrinDID.gen();

console.log(d);

output:

{ did: 'S7evWWTSbaXELyE9w53sFr',
  verifyKey: 'EgvhZsLKSsqsbNBfJ2wfR9FFWo9YqkpxpfXeT4ifR1Cq',
  secret:
   { seed: '36a572a7e43956784b517c57b26720a8ef838d114c0619f1d8c7801c37fa4f6a',
     signKey: '4gKLe7Qq2WX249NBfymQySZbAzXboq2emMig6wBR82Bj' } }

API

sovrinDID.gen()

Generates a new did, verification key, signing key, and also gives you the seed used to generate them.

{
    did: "<base58 did>",
    verifyKey: "<base58 publicKey>",

    secret: {
        seed: "<hex encoded 32-byte seed>",
        signKey: "<base58 secretKey>"
    }
}

sovrinDID.fromSeed(seed)

Same as .gen() except you supply the seed. The seed should be a 32-byte Uint8Array (i.e. Buffer).

Example:

var seed = Buffer.from("36a572a7e43956784b517c57b26720a8ef838d114c0619f1d8c7801c37fa4f6a", "hex");

var d = sovrinDID.fromSeed(seed);

console.log(d);

The output is the same as the .gen() example.

sovrinDID.signMessage(message, signKey, verifyKey)

Signs a message with the given signKey and verifyKey.

  • The message should be a string.
  • Both the signKey and verifyKey should be the signKey and verifyKey given from the gen() or fromSeed(seed) methods

Returns a signed message as a Uint8Array (i.e. Buffer).

Example:

  var sovrin = sovrinDID.gen();
 
  var signKey = sovrin.secret.signKey;
  var verifyKey = sovrin.verifyKey;
  var message = "Hello World!!";
 
  var signedMessage = sovrinDID.signMessage(message, signKey, verifyKey);;

sovrinDID.verifySignedMessage(signedMessage, verifyKey)

Verifies that the given message has been signed by the possessor of the given verifyKey.

  • The signedMessage should be what is returned from the signMessage(message, signKey, verifyKey) method
  • The verifyKey should be the verifyKey given from the gen() or fromSeed(seed) methods

Returns true if the message was signed by the owner of the verifyKey false otherwise.

Example:

  var sovrin = sovrinDID.gen();
  var sovrin2 = sovrinDID.gen();
 
  var signKey = sovrin.secret.signKey;
  var verifyKey = sovrin.verifyKey;
  var verifyKey2 = sovrin2.verifyKey;
 
  var message = "Hello World!!";
 
  var signedMessage = sovrinDID.signMessage(message, signKey, verifyKey);
 
  console.log(sovrinDID.verifySignedMessage(signedMessage, verifyKey));
  console.log(sovrinDID.verifySignedMessage(signedMessage, verifyKey2))

Output:

  true
  false

License

MIT

Keywords

FAQs

Package last updated on 27 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc