Skip to content

Conversation

zhangfengcdt
Copy link
Owner

No description provided.

zhangfengcdt and others added 3 commits August 24, 2025 16:08
Expose cryptographic proof functionality from ProllyTree to VersionedKvStore
in both Rust and Python APIs for consistent proof generation and verification
across versioned key-value operations.

## Changes

### Rust Implementation
- Add `generate_proof(&self, key: &[u8]) -> Proof<N>` to VersionedKvStore
- Add `verify(&self, proof: Proof<N>, key: &[u8], expected_value: Option<&[u8]>) -> bool`
- Both methods delegate to underlying ProllyTree implementation
- Add comprehensive unit test `test_versioned_store_proof_methods`

### Python Bindings
- Add `generate_proof(key: bytes) -> bytes` to PyVersionedKvStore
- Add `verify_proof(proof_bytes: bytes, key: bytes, expected_value: Optional[bytes]) -> bool`
- Handle proof serialization/deserialization with bincode
- Thread-safe implementation with proper GIL handling

## API Usage

```python
store = VersionedKvStore.open("/path/to/repo")
proof = store.generate_proof(b"key1")
is_valid = store.verify_proof(proof, b"key1", b"value1")
```

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add documentation for the newly added generate_proof and verify_proof
methods in the VersionedKvStore example section. Also update the
cryptographic verification feature description to clarify it's
available for both trees and versioned storage.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ctionality

Update Python type stubs (.pyi) to include the newly added proof methods
and previously missing merge functionality for better IDE support and
type checking.

## Added Type Stubs

### VersionedKvStore Methods
- `generate_proof(key: bytes) -> bytes` - Generate cryptographic proofs
- `verify_proof(proof: bytes, key: bytes, expected_value: Optional[bytes]) -> bool` - Verify proofs
- `get_commits_for_key(key: bytes) -> List[Dict[str, Union[str, int]]]` - Get key history
- `get_commit_history() -> List[Dict[str, Union[str, int]]]` - Get repository history
- `merge(source_branch: str, conflict_resolution: Optional[ConflictResolution]) -> str` - Merge branches
- `try_merge(source_branch: str) -> Tuple[bool, List[MergeConflict]]` - Attempt merge with conflict detection

### New Classes
- `MergeConflict` - Represents merge conflicts with key, base_value, source_value, destination_value properties
- `ConflictResolution` - Enum with IgnoreAll, TakeSource, TakeDestination strategies

These additions ensure comprehensive IDE support and type checking for all
VersionedKvStore functionality including the newly added proof methods.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zhangfengcdt zhangfengcdt merged commit 00e3569 into main Aug 25, 2025
5 checks passed
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.

1 participant