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: add server action for decryption of shares and reconstruct it back to the private key #180

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Feat: add server action for decryption of shares and reconstruct it back to the private key #180

merged 1 commit into from
Sep 18, 2024

Conversation

rahulbarmann
Copy link
Contributor


Feat: add server action for decryption of shares and reconstruct it back to the private key

Main Addition:

I have added a server action that first decrypts all the shares of the user after pulling them from the database via AES, AWS, and GCP decrypt modules. I have also added a new shamirCombine() function which I use next to reconstruct the decrypted shares into the original private key of the user.

I also fixed some encoding issues that popped up while working on this, by correctly implementing base58 for decoding the private key to a Uint8Array before splitting and also encoding the reconstructed key back to base58 after combining.

Explanation of the Fix:

Before, we were not correctly encoding the private key after generating them from the keyPair before sending it to the shamirSplit() function and these faulty shares were being encrypted which further caused errors while combining these shares during reconstruction. We now always encode and decode the private key right from the generation in base58 format which is a popular encoding format for crypto public/ private keys.

https://www.npmjs.com/package/bs58

Video Demonstration:

I am currently adding some console.logs to show if both the generated private key is the same as the reconstructed one. I will be removing these logs in this PR as it is not good practice to log user's private keys but you can add the same logs which I show in the video to test it out for yourself!

server-action-reconstruction.mp4

Issue Number: Resolves #169

🛠️ Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🚨 Breaking change
  • 📚 Documentation update

✅ Checklist

To ensure a smooth review process, please check off each item as you complete it:

  • Code Style: My code adheres to the project’s style guidelines.
  • Self-Review: I have reviewed my own code and made improvements.
  • Comments: I’ve added comments to explain complex or non-obvious parts of the code.
  • Documentation: I’ve updated the documentation to reflect my changes.
  • Warnings: My changes introduce no new warnings.
  • Tests: I’ve added tests to verify that my changes work as expected.
  • Passes Locally: All new and existing unit tests pass on my local machine.

…ack to the private key

fix: encoding errors in keyShardingService
@cb7chaitanya
Copy link
Collaborator

Amazing work @rahulbarmann, merging it right away, finishes the private key decryption-encryption workflow

@cb7chaitanya cb7chaitanya merged commit b0c33b3 into code100x:dev Sep 18, 2024
1 check passed
cb7chaitanya added a commit that referenced this pull request Sep 19, 2024
Feat: add server action for decryption of shares and reconstruct it back to the private key
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.

[FEAT] Create a server action for decrypting shares and piecing all the shares together
2 participants