-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Overview
Implement the generate method in Python SDK to create randomized key shards using threshold cryptography. This will allow generation of a secure master key and its corresponding shards, following the same API structure as the existing JavaScript SDK.
Maintaining consistent function names and response formats with the JS SDK is important for cross-language compatibility.
Function Signature
async def generate(threshold: int = 3, keyCount: int = 5) -> Dict[str, Any]:
passExpected Response
{
"masterKey": "<32-byte master key string>",
"keyShards": [
{ "key": "<shard key string>", "index": "<index string>" }
]
}masterKey: Secure randomly generated 32-byte key.keyShards: List of shards that can reconstruct the masterKey based on the threshold.
Reference (JS SDK)
- File:
/src/methods/generate/index.ts - Method:
generate()
Key Requirements
- Use cryptographically secure random key generation for
masterKey(Python’ssecretsoros.urandom). - Implement threshold secret sharing (Shamir Secret Sharing preferred for first version).
- Validate that
keyCount >= threshold. - Use consistent shard serialization (key + index format) similar to JS SDK.
- Ensure deterministic output for same seed (for testability).
Suggested Python Libraries
secretsharingorcryptographyfor Shamir secret sharing.secretsoros.urandomfor secure key generation.
Deliverables
- Fully implemented
generate()function. - Unit tests covering multiple threshold/keyCount combinations.
- Return values matching JS SDK response schema.
Metadata
Metadata
Assignees
Labels
No labels