Skip to content

Instantly share code, notes, and snippets.

@edmundmiller
Created March 1, 2019 02:12
Show Gist options
  • Save edmundmiller/568737cf174eaf1f2e1753a723e54b8f to your computer and use it in GitHub Desktop.
Save edmundmiller/568737cf174eaf1f2e1753a723e54b8f to your computer and use it in GitHub Desktop.
// Whatever it is to make a web3 call mock to RSA contract
let ethbs;
////////////
// Step 1 //
////////////
let aKeyId = ethbs.createKey(nodeId, 1, keyName, signature, keyInstance);
let CreationEvent = [nodeAAddress, keyId, stepNumber]; //Step number would be 1
////////////
// Step 2 //
////////////
/* CreationEvent triggers this */
let keyName = ethbs.getKeyName(aKeyId);
let nodeId = ethbs.getNodeId(aKeyId);
// Create a new ephemeral RSA key pair on NODE-B key manager.
// Retrieve the ephemeral RSA public key from the NODE-B key manager.
// Encrypt the ephemeral RSA public key with NODE-A’s public key.
let ephKeyId = ethbs.createEphKey(
nodeId,
2,
keyName,
signature,
keyInstance,
encryptedEphKey
);
/* This is the normal creation event */
let ephKeyCreationCreation = [nodeAddress, keyId, stepNumber]; //Step number would be 2
/* This would be the ephEvent. So you can get it on Node A*/
let ephKeyCreationCreation = [encryptedPubKey];
// Sign the encrypted ephemeral RSA public key with the local node’s (NODE-B) private key.
let retrievalRequest = ethbs.requestKey(ephKeyId);
let RequestEvent = [nodeBAddress, keyId]; // Id would be 2
////////////
// Step 3 //
////////////
/* Triggered by RequestEvent */
// Verify the signature of NODE-B
// Verify the RSA key existence in the local key manager.
let whetherNodeBhasAuth = ethbs.getAuthority(ephKeyId, bAddress); // I need to create a user registery
// Verify the user’s authority to the RSA key. /* WIP */
// Decrypt NODE-B’s ephemeral RSA public key with NODE-A’s private key.
// Retrieve the requested RSA key pair from the local key manager.
// Encrypt the retrieved RSA key pair with NODE-B’s ephemeral RSA public key.
// Sign the encrypted RSA key pair with NODE-A’s private key.
let retrievalResponse = ethbs.authorizeNode(ephKeyId, aAddress);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment