Skip to content

Conversation

Arlodotexe
Copy link
Collaborator

@Arlodotexe Arlodotexe commented Aug 14, 2025

This PR implements a guard in DagCid to throw when attempting to store a libp2p-key (IPNS) CID as a DagCid link. IPLD DAG links must be immutable; IPNS/libp2p-key CIDs are mutable names.

  • Adds validation in DagCid.Value setter and explicit cast from Cid to DagCid to throw ArgumentException for libp2p-key.
  • Adds unit tests in test/DagCidTest.cs covering both valid and invalid paths.

Closes #43.

@Arlodotexe Arlodotexe requested a review from Copilot August 14, 2025 03:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds validation to prevent libp2p-key CIDs from being stored as DagCid links, enforcing IPLD's immutability requirement by rejecting mutable IPNS addresses.

  • Adds validation in DagCid.Value setter to throw ArgumentException for libp2p-key content type
  • Updates explicit cast operator from Cid to DagCid with same validation logic
  • Comprehensive unit test coverage for both valid operations and error conditions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/DagCid.cs Implements libp2p-key validation in Value setter and explicit cast operator with detailed error messages
test/DagCidTest.cs Adds comprehensive test coverage for valid CID operations and libp2p-key rejection scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Arlodotexe Arlodotexe merged commit 552005d into main Aug 14, 2025
1 check passed
@Arlodotexe Arlodotexe deleted the feature/dagcid-block-libp2p-key branch August 14, 2025 03:55
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.

Add throw/check against storing CID-encoded libp2p key as DagCid link
1 participant