Open
Description
Overview
Implement the recoverShards
method in Python SDK to retrieve key shards from Lighthouse distributed nodes. This method allows authorized users to recover their key shards for decryption or reconstruction, following the same workflow as the JS SDK.
The method must support both simple recovery and dynamic access condition flows.
Function Signature
async def recoverShards(
address: str,
cid: str,
auth_token: str,
keyCount: int = 3,
dynamicData: Optional[Dict] = None
) -> Dict[str, Any]:
pass
Expected Response Format
{
"keyShards": [
{ "key": "<shard key string>", "index": "<index string>" }
],
"error": null
}
keyShards
: List of recovered shards.error
: Null if successful; populated if recovery fails.
Reference (JS SDK)
- File:
/src/methods/recoverShards/index.ts
- Method:
recoverShards()
Key Requirements
- Perform HTTP request to Lighthouse Node’s shard recovery endpoint.
- Use
auth_token
for authorization (generated fromgetAuthMessage
+ signature). - Use optional
dynamicData
for access condition inputs (for smart contract based access policies). - Support
keyCount
to specify how many shards to request. - Validate and return shards following JS SDK format (
{ key, index }
objects). - Parse and handle all Lighthouse API errors into SDK-consistent response shape.
Suggested Python Libraries
- Use
httpx
(preferred async), orrequests
for HTTP calls. - Use
pydantic
or similar for schema validation. - Consider
tenacity
or built-in retry logic for network fault tolerance.
Deliverables
- Working
recoverShards()
method. - Unit tests for:
- Recovery with valid parameters.
- Error cases (invalid auth, insufficient access rights, revoked access, etc.)
- Edge cases for
dynamicData
injection.
- Strict matching of JS SDK request & response structure.
Notes
- This function must be fully compatible with
saveShards
,shareToAddress
,revokeAccess
, andaccessControl
. - This will be one of the most heavily used methods inside the SDK for user decryption flows.
Metadata
Metadata
Assignees
Labels
No labels