Skip to content

Instantly share code, notes, and snippets.

@kuboon
Created March 30, 2026 22:37
Show Gist options
  • Select an option

  • Save kuboon/cadce44a0f1f91f8f00aac6addd3b756 to your computer and use it in GitHub Desktop.

Select an option

Save kuboon/cadce44a0f1f91f8f00aac6addd3b756 to your computer and use it in GitHub Desktop.
cryptid.ts
import CryptID from "https://esm.sh/@cryptid/cryptid-js/lib/node/js/index.js";
(async function main() {
const instance = await CryptID.getInstance();
const setupResult = instance.setup(CryptID.SecurityLevel.LOWEST);
if (!setupResult.success) {
console.log('Failed to setup :(');
return;
}
const message = 'Ironic.';
// Name is somewhat unique among Sith Lords :)
const identity = {
name: 'Darth Plagueis'
};
const encryptResult = instance.encrypt(setupResult.publicParameters, identity, message);
if (!encryptResult.success) {
console.log('Failed to encrypt :(');
return;
}
const extractResult = instance.extract(setupResult.publicParameters, setupResult.masterSecret, identity);
if (!extractResult.success) {
console.log('Failed to extract :(');
return;
}
const decryptResult = instance.decrypt(setupResult.publicParameters, extractResult.privateKey, encryptResult.ciphertext);
if (!decryptResult.success) {
console.log('Failed to decrypt :(');
return;
}
console.log(decryptResult.plaintext);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment