-
Notifications
You must be signed in to change notification settings - Fork 28
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
refactor!: cryptosuite-style signers #801
Conversation
893bf03
to
0d876eb
Compare
c92a0f9
to
04eb5b3
Compare
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.
In general I like it! I see what you did there. I left some comments around naming and typing. It looks like there's mostly raw string
s everywhere, and maybe we can change that to help TS developers a bit more? Or am I missing something?
packages/types/src/Signers.ts
Outdated
|
||
export type SignerInterface = { | ||
algorithm: string | ||
id: string |
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.
Also, should the id
be optional? For instance when signing an extrinsic, we don't really care about the ID of the key. We don't care about the algorithm either, but I guess we have it to rule out signatures that will definitely fail when submitted to the chain.
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.
We do care about the id even when signing extrinsics, because we need it to figure out which verification relationship a key is in. Even as an account signer we need to know for which account this signs. So I'd say the id is crucial, always
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.
Ok, I see. I guess I was referring to the case where the signer is an account, indeed. It kinda feels a bit of a stretch to use the account representing the key as the ID for that key. Let's see what the others have to say about it. Cc @lukeg90 @Dudleyneedham
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 think it could potentially be confusing for a developer to determine what string they should enter here as the ID, especially when signers can be both accounts and DIDs, depending on the context . But I don't really have a suggestion for improvement, other than making sure we have good documentation.
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.
Of course if they always use the getSigner
methods then they don't even have to care what the ID is.
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 think that's the intended way for the signer to be created, indeed.
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.
yeah this would mostly get unnoticed; there may be a getAccountSigners
function or method that creates all signers for an account (using Addresses as ids) and a getSigners
method on a DID class or something that returns all signers for its verificationMethods (where all ids are DID URLs). This higher level api is TBD in a follow-up PR, but I see a lot of potential
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.
Not sure I like the term signers however, I couldn't come up with anything interesting.
Looks good.
} | ||
const verificationMethod = delegateDid.verificationMethod?.find( | ||
({ id }) => id === fragment | ||
const { byDid, verifiableOnChain } = Signers.select |
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.
What does byDid
mean?
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.
you select
a Signer
byDid
(-> by it's association to a Did, via the DidDocument). I thought that was self-explanatory, how can this be improved?
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 think on its own it might not make sense, but when it's exported with a named object, it made more sense to me, also the way it's used in the tests.
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.
any suggestions here?
Good riddance signing callbacks! |
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.
There's few incompatibilities with the underlying DID refactoring branch by now (sorry about that). But as far as I am concerned, this could be merged. Looking forward for the rest of the issues by others to be resolved.
f66d2d9
to
b39f32b
Compare
* allows removing reimplementation signer factories * allows stronger typing of algorithm identifiers
fixes KILTProtocol/ticket#2962
Apparently nobody likes our present signer interfaces; they seem to be hard to wrap your head around.
Upcoming presentation signing with data integrity proofs means that a different sort of signer interface is required to produce those signatures, as the key identifier and algorithm is signed into the proof and thus must be known prior to signing, which does not work with our current callbacks (which return the key id together with the signature).
In order to avoid a proliferation of different signing interfaces in our sdk, this PR aims to migrate all signer functions to the interfaces introduced by our data integrity proof cryptosuites. This may actually also increase ergonomics, as it is implemented in a way that users can generate signers for their keys and DIDs once, and simply throw them all at a given function, which will select and call the appropriate handler.
TBD (possibly in a later PR)
How to test:
This is WIP; ergonomics is important here, so writing some example signing flows would help a lot.
Checklist: