![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
node.js module to generate DID and Ed25519 keys to use with Sovrin
$ npm i sovrin-did
var sovrinDID = require("sovrin-did");
var d = sovrinDID.gen();
console.log(d);
output:
{ did: 'S7evWWTSbaXELyE9w53sFr',
verifyKey: 'EgvhZsLKSsqsbNBfJ2wfR9FFWo9YqkpxpfXeT4ifR1Cq',
encryptionPublicKey: '5UAXeov4Gi7ioSTLDoMPtdvqX6RRmJcQAWagVgdaxUej',
secret:
{ seed: '36a572a7e43956784b517c57b26720a8ef838d114c0619f1d8c7801c37fa4f6a',
signKey: '4gKLe7Qq2WX249NBfymQySZbAzXboq2emMig6wBR82Bj',
encryptionPrivateKey: '7H25Jfb2ND51hhaomL5FPhhqQvBGujd1jJeSjZZ8HQzR'} }
Generates a new did, verification key, signing key, and also gives you the seed used to generate them. It also includes the public and private key used for encryption.
{
did: "<base58 did>",
verifyKey: "<base58 publicKey>",
publicKey: "<base58 publicKey>",
secret: {
seed: "<hex encoded 32-byte seed>",
signKey: "<base58 secretKey>",
privateKey: "<base58 privateKey>"
}
}
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.
Signs a message with the given signKey and verifyKey.
gen()
or fromSeed(seed)
methodsReturns 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);
Verifies that the given message has been signed by the possessor of the given verifyKey.
signMessage(message, signKey, verifyKey)
gen()
or fromSeed(seed)
methodsReturns the original message 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:
Hello World!!
false
Returns a key pair that is valid to use for encrypting.
gen()
or fromSeed()
Example:
var sovrin = sovrinDID.gen();
var signKey = sovrin.secret.signKey;
var keyPair = sovrinDID.getKeyPairFromSignKey(signKey);
console.log(keyPair);
Output:
{
publicKey: ... // Uint8Array with 32-byte public key
secretKey: ... // Uint8Array with 32-byte secret key
}
Returns a random nonce as a Uint8Array that can be used for encrypting.
Example:
var nonce = sovrinDID.getNonce();
Computes a sharedSecret to be used for encryption.
getKeyPairFromSignKey(signKey)
method or the publicKey string given from the gen()
method.getKeyPairFromSignKey(signKey)
method or the privateKey given from the gen()
method.Example:
var sovrin1 = sovrinDID.gen();
var sovrin2 = sovrinDID.gen();
// Using the strings given via the gen() method
var sharedSecret1 = sovrinDID.getSharedSecret(sovrin2.encryptionPublicKey, sovrin1.secret.encryptionPrivateKey);
var sharedSecret2 = sovrinDID.getSharedSecret(sovrin1.encryptionPublicKey, sovrin2.secret.encryptionPrivateKey);
var signKey1 = sovrin1.secret.signKey;
var signKey2 = sovrin2.secret.signKey;
var keyPair1 = sovrinDID.getKeyPairFromSignKey(signKey1);
var keyPair2 = sovrinDID.getKeyPairFromSignKey(signKey2);
// Using the buffer given from the getKeyPairFromSignKey(signKey2) method
var sharedSecret3 = sovrinDID.getSharedSecret(keyPair2.publicKey, keyPair1.secretKey);
var sharedSecret4 = sovrinDID.getSharedSecret(keyPair1.publicKey, keyPair2.secretKey);
// All the secrets generated are equivalent
Encrypts a the given message using a precomputed sharedSecret.
getNonce()
method
getSharedSecret(theirVerifyKey, mySigningKey)
methodExample:
var sovrin1 = sovrinDID.gen();
var sovrin2 = sovrinDID.gen();
var signKey1 = sovrin1.secret.signKey;
var signKey2 = sovrin2.secret.signKey;
var keyPair1 = sovrinDID.getKeyPairFromSignKey(signKey1);
var keyPair2 = sovrinDID.getKeyPairFromSignKey(signKey2);
var sharedSecret1To2 = sovrinDID.getSharedSecret(keyPair2.publicKey, keyPair1.secretKey);
var message = "Hello World!!";
var nonce = sovrinDID.getNonce();
var encryptedMessage = sovrinDID.encryptMessage(message, nonce, sharedSecret1To2);
Verifies and decrypts a previously encrypted message.
encryptMessage(message, nonce, sharedSecret)
methodgetNonce()
method
getSharedSecret(theirVerifyKey, mySigningKey)
methodExample:
var signKey1 = "4bMnc36WuLYJqsWTZtiazJJrtkvPwgyWnirn7gKk7ium";
var signKey2 = "516mChDX1BRjwHJc2w838W8cXxy8a6Eb35HKXjPR2fD8";
var signKey3 = "7H25Jfb2ND51hhaomL5FPhhqQvBGujd1jJeSjZZ8HQzR";
var keyPair1 = sovrinDID.getKeyPairFromSignKey(signKey1);
var keyPair2 = sovrinDID.getKeyPairFromSignKey(signKey2);
var keyPair3 = sovrinDID.getKeyPairFromSignKey(signKey3);
var sharedSecret1To2 = sovrinDID.getSharedSecret(keyPair2.publicKey, keyPair1.secretKey);
var sharedSecret2To1 = sovrinDID.getSharedSecret(keyPair1.publicKey, keyPair2.secretKey);
var sharedSecret3To1 = sovrinDID.getSharedSecret(keyPair3.publicKey, keyPair1.secretKey);
var message = "Hello World!!";
var nonce = sovrinDID.getNonce();
var encryptedMessage = sovrinDID.encryptMessage(message, nonce, sharedSecret1To2);
var decryptedMessage = sovrinDID.decryptMessage(encryptedMessage, nonce, sharedSecret2To1);
var attemptedDecryption = sovrinDID.decryptMessage(encryptedMessage, nonce, sharedSecret3To1);
console.log(decryptedMessage);
console.log(attemptedDecryption);
Output:
Hello World!!
false
MIT
FAQs
node.js module to generate DID and Ed25519 keys to use with Sovrin
The npm package sovrin-did receives a total of 0 weekly downloads. As such, sovrin-did popularity was classified as not popular.
We found that sovrin-did demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.