-
Notifications
You must be signed in to change notification settings - Fork 55
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
make Keyset Id's member variables public #564
Conversation
Aligns with other structures by exposing Id's member variables, allowing developers to create Ids that don't follow the CDK protocol. [1] [1] https://github.com/cashubtc/nuts/blob/main/02.md#deriving-the-keyset-id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NACK.
This would allow callers to bypass all the From
implementations for Id
( From<&Keys>
, FromStr
, from_bytes
etc) when creating Ids
, which is unnecessary and dangerous.
That was the point of this PR: allow others to implement their own keyset |
version: KeySetVersion, | ||
id: [u8; Self::BYTELEN], | ||
pub version: KeySetVersion, | ||
pub id: [u8; Self::BYTELEN], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is worth making it a trait or something with a default implementation, something more idiomatic and easy to extend.
Also, FYI, perhaps this should be part of the signatory, and the mintd just uses whatever is given to it by the signatory, as it may eventually run as its crate either in the same memory space or with an external service through grpc (#509) /cc @thesimplekid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the codebase currently is, I reckon, converting Id
into a trait is unfeasible: this small struct is used in so many places that converting all of them into generic code over a parameter impl<ID> [...] where ID: Id
would be a bloodbath.
Side note: if ( and I hope it will) the signatory and key management subsystem will become an external service communicating with the mint via grpc, protecting the internals of the keyset Id and how it is built is going to become even less relevant for the security level of the mint itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with codingpeanut that this would end up being a pretty big change. However, we are going to need to something to support keysetv2 whether that be making it a trait or an enum like we do with token, if I remember correctly I started trying to do token as a trait and ended up with an enum forget exactly why.
Also, FYI, perhaps this should be part of the signatory
We still need the type in cashu
as we want this crate to be an implementation of all the cashu types and can be used without the other crates.
I agree with this and don't think the fields should or need to be used directly, however most of the fields on other structs have pub fields, so I don't have an strong argument for drawing the line here and keeping this one private. That being said I think attempting to use cdk for a non cashu protocol is going to inevitability lead to more changes being needed to cdk for it to work that won't be merged even if this is, as it is an implementation of the cashu protocol. |
hello @thesimplekid |
Guys, this is bikeshedding. It brings no value to CDK or CDK callers, to expose these inner fields and allow custom keyset ID generation algorithms. The cashu NUTs specify exactly the algorithm for keyset ID generation. If there's a problem in the CDK algo, then a PR for that is more appropriate. Dev time is limited, so I'd suggest we keep it simple and close this, to avoid unnecessary changes. |
I am going to close this. As @ok300 has pointed out, Keyset Id generation is specifically defined in the nuts, so there is no need for the inner to be public and the Id type should be used. It is true that currently CDK does have many pub types, so this could be seen as inconsistent; however, I think we should make more private instead of making this one public, this will ensure that fields and types are used as we expect. Where access to inner fields is needed, we can provide a read-only getter or a Deref. Furthermore, we will need to add support for IDV2 so making this change will be almost immediately be overwritten by adding support for this. |
Description
Aligns with other structures by exposing Id's member variables, allowing developers to create Ids that don't follow the CDK protocol. [1]
[1] https://github.com/cashubtc/nuts/blob/main/02.md#deriving-the-keyset-id