Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(key-manager): add method to compute a shared secret #555

Merged
merged 2 commits into from
Jun 10, 2021

Conversation

mirceanis
Copy link
Member

What's here

  • key-manager plugin exposes a new method that computes a shared key (Diffie Hellman) between a secret key the agent manages and a public key of another party, returning a promise that resolves to the hex encoding string of the shared key.
async keyManagerSharedKey({secretKeyRef: string, publicKey: {type: string, publicKeyHex: string}}): Promise<string>`

The result is the RAW shared secret (scalar multiplication in the case of ECC).
To use this for symmetric encryption, one would need to hash it to arrive at a shared Symmetric Key

  • To do this, there is a new requirement of the AbstractKeyManagementSystem class for a new abstract method sharedKey()
  • The kms-local package implements this new sharedKey method
  • kms-local supports Ed25519 & X25519 keys for computing the shared key. Keys are converted to X25519 if they are Ed25519

closes #541

@mirceanis mirceanis requested a review from awoie June 9, 2021 11:50
@codecov
Copy link

codecov bot commented Jun 9, 2021

Codecov Report

Merging #555 (a861cb8) into next (0bf7b24) will increase coverage by 9.80%.
The diff coverage is 67.00%.

@@            Coverage Diff             @@
##             next     #555      +/-   ##
==========================================
+ Coverage   67.58%   77.39%   +9.80%     
==========================================
  Files          62       71       +9     
  Lines        1530     1893     +363     
  Branches      247      321      +74     
==========================================
+ Hits         1034     1465     +431     
- Misses        400      426      +26     
+ Partials       96        2      -94     

@mirceanis mirceanis force-pushed the 541-add-key-manager-ecdh-wrapper branch from 6d49bca to 34d93ce Compare June 10, 2021 09:59
Copy link
Member

@awoie awoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - just fixed some comments

packages/core/src/types/IKeyManager.ts Outdated Show resolved Hide resolved
packages/core/src/types/IKeyManager.ts Outdated Show resolved Hide resolved
packages/key-manager/src/key-manager.ts Outdated Show resolved Hide resolved
packages/kms-local/src/key-management-system.ts Outdated Show resolved Hide resolved
packages/kms-local/src/key-management-system.ts Outdated Show resolved Hide resolved
@mirceanis mirceanis requested a review from awoie June 10, 2021 10:11
Copy link
Member

@awoie awoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mirceanis mirceanis merged commit 393c316 into next Jun 10, 2021
@mirceanis mirceanis deleted the 541-add-key-manager-ecdh-wrapper branch June 10, 2021 10:18
@mirceanis mirceanis mentioned this pull request Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add sharedSecret method to key-manager and KMS abstracts
2 participants