Skip to content

feat: Encryption Package Implementation #37

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AnonO6
Copy link

@AnonO6 AnonO6 commented Jun 29, 2025

Description

This PR introduces new cryptographic key management functionality under the Kavach class to the SDK, implementing Shamir's Secret Sharing for secure key distribution and recovery.
This PR solves the following issues: #27 and #25

New Features:

  1. Key Generation
  • Implements secure generation of master keys using cryptographically secure random numbers
  • Creates key shards using polynomial evaluation over a finite field
  • Supports configurable threshold and total number of shares
  1. Key Recovery
  • Implements Lagrange interpolation for reconstructing the master key from shares
  • Handles various edge cases and invalid inputs gracefully
  • Includes comprehensive input validation
  • Supports recovery with any number of valid shares
  1. Configuration
  • Defines `prime modulus' parameter.

Technical Details:

  • Uses Python's secrets module for cryptographically secure random number generation
  • Implements finite field arithmetic for polynomial operations
  • Includes comprehensive error handling and input validation
  • Didn't used python's secretsharing package (suggested in the issue) as it is deprecated for python3.
  • Prime modulus Value is set to 2**256 + 297 to handle 32 byte keys.

Testing:

  • Unit tests cover all major functionality
  • Test cases include:
  • Basic key generation and recovery
  • Edge cases (empty input, invalid shares)
  • Various combinations of shares
  • Api follows the same structure as JS SDK

Refrences:

https://en.wikipedia.org/wiki/Shamir%27s_secret_sharing

@AnonO6 AnonO6 changed the title Encryption Package Implementation Feat: Encryption Package Implementation Jun 29, 2025
@AnonO6 AnonO6 force-pushed the encryptionEngine branch from 8011248 to 94a1670 Compare July 6, 2025 18:22
@AnonO6 AnonO6 changed the title Feat: Encryption Package Implementation feat: Encryption Package Implementation Jul 6, 2025
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.

2 participants