Skip to content
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

Meadowcap #32

Merged
merged 28 commits into from
Aug 5, 2024
Merged

Meadowcap #32

merged 28 commits into from
Aug 5, 2024

Conversation

sgwilym
Copy link
Contributor

@sgwilym sgwilym commented Jul 29, 2024

Implementation of Meadowcap.

  • Uses traits from signature crate.
  • Aims to makes it impossible for invalid capabilities to be constructed (i.e. no validation functions)

What's done:

  • CommunalCapability
  • OwnedCapability
  • McCapability
  • MeadowcapAuthorisationToken
  • McSubspaceCapability
  • Encodings
  • Tests (always nice)
  • Extra fancy data structures (we will handle this later)

@sgwilym sgwilym added the enhancement New feature or request label Jul 29, 2024
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
access_mode: AccessMode,
namespace_key: NamespacePublicKey,
user_key: UserPublicKey,
delegations: Vec<Delegation<MCL, MCC, MPL, UserPublicKey, UserSignature>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will work for now, but long-term (or even medium-term), we want something that is much cheaper to clone (i.e., something that involves reference counting). We will have many entries with only a few different capabilities, so they should (at least be able to) reuse the same memory. Might even involve interning. CC @Frando, this could be fairly involved. One option would be to require the parameters of the types in a Delegation to be FromBytes, so that we can store things in a Bytes struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've always wanted an intern.

But more seriously... let's follow this up in the willow channel on discord.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean wrapping the delegations, or the full capability?
In iroh-willow I switched to internally wrapping the full delegation in an Arc. My reasoning was that cloning capabilities is much more frequent than modifying them. With the capability-as-arc, I can just clone them freely whenever and wherever I need them, which is nice.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any specific, thought-through ideas. But the same style as the Path struct (encoded data inside a Bytes) comes to mind.
Agreed that cloning is much more important than mutation. Reading a bunch of entries with the same authentication token from the WGPS can reuse refcounted memory when the network encoding specifies the authentication token as one that had been transmitted before. But it might be nice to do interning to also reuse tokens when the network encoding does not explicitly state that it's reusable. Additionally, when reading entries from persistent storage, it would be good to deduplicate memory as well.

meadowcap/src/lib.rs Outdated Show resolved Hide resolved
meadowcap/src/lib.rs Outdated Show resolved Hide resolved
@sgwilym
Copy link
Contributor Author

sgwilym commented Aug 1, 2024

@AljoschaMeyer the fuzz tests are currently running with complaint, but:

  • In the case of the appending delegation fuzz test, one path remains unexplored (append success) because the fuzzer can't generate valid (silly) signatures, even though they are, well, silly.
  • Generating arbitrary capabilities with many delegations is currently implemented within the fuzz tests rather than within the arbitrary implementations themselves.

I would appreciate if you could inspect the fuzz tests as they are for oversights on my part!

@AljoschaMeyer
Copy link
Contributor

To make the silly signature scheme even more silly, how about defining the signature as a single byte which is the XOR of the public key and the first message byte? That way, there are only 255 different signatures, and the fuzzer should hopefully guess them quickly enough.

@sgwilym sgwilym marked this pull request as ready for review August 3, 2024 14:19
@AljoschaMeyer
Copy link
Contributor

Super cool =)!

@sgwilym sgwilym merged commit 5f063e5 into main Aug 5, 2024
1 check passed
@sgwilym sgwilym deleted the meadowcap branch August 5, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants