Skip to content

Instantly share code, notes, and snippets.

@stefan2904
Last active March 31, 2022 13:07
Show Gist options
  • Save stefan2904/f1ac36cebe946a475bcbbb8c3e8960c9 to your computer and use it in GitHub Desktop.
Save stefan2904/f1ac36cebe946a475bcbbb8c3e8960c9 to your computer and use it in GitHub Desktop.
Generate Ed25519 did:key in JSONWebKey format for usage in Hyperledger Aries
// using https://github.com/transmute-industries/did-key.js
// via https://www.npmjs.com/package/@transmute/did-key-ed25519
const main = async function() {
const k = await require('@transmute/did-key-ed25519').Ed25519KeyPair.generate({
secureRandom: () => {
return Buffer.from(
require('crypto').randomBytes(32),
'hex'
);
},
});
const exportedKeyPair = await k.export({
type: 'JsonWebKey2020',
privateKey: true,
});
console.log(exportedKeyPair);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment