-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change to better distinguish signature schemes #19
Conversation
25a680e
to
1954cc2
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.
LGTM
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 would consider calling it MultiSignature
. Beyond that, LGTM.
derive(Archive, Deserialize, Serialize), | ||
archive_attr(derive(bytecheck::CheckBytes)) | ||
)] | ||
pub struct MultisigSignature(pub(crate) G1Affine); |
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.
Doesn't feel redundant to call it Multi signature signature?
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 feel like I would then also have to change the name of MultisigPublicKey
to have the pair of:
MultiPublicKey
MultiSignature
I don't like it though, since the concept of "multi-sig" refers specifically to the scheme, not the structure, and erasing it would kind of defeat the purpose of this PR.
It is currently possible to call `APK::verify` or `PublicKey::verify` on the same signature type, leading to situations where even if a user is technically *allowed* to call the function, verification is in principle impossible, since the signature schemes used to produce a signature are different. Furthermore, the `sign_vulnerable` function is arguably misnamed, since it is only actually vulnerable to a rogue key attack *when used in a multi-signature context*. In the interest of fixing this, this commit introduces a couple of changes to the API of the crate, designed to better distinguish and clarify the usage of the two different signature schemes it provides. First and foremost, a new signature type - `MultisigSignature` is added, representing a signature produced using the multi-signature scheme. Conversely, the already existing `Signature` type is taken to mean the a signature produced using the single-key scheme. The functions under `SecretKey`, `sign_vulnerable` and `sign`, are respectively renamed into `sign` and `sign_multisig`, and the latter is changed to return the new `MultisigSignature` type. The "aggregated public key" type is renamed from `APK` into `MultisigPublicKey`, to better denote its use and to be in line with the kind signature it can now verify using the `verify` function - which is changed to take a `MultisigSignature`. On a more subtle note, the `From<&PublicKey>` and `From<&SecretKey>` implementations for `MultisigPublicKey`, formerly `APK` are removed and the API of `MultisigPublicKey::aggregate` is changed to *not* take `&self`, and only take a slice of `PublicKey`. This is designed to promote the intended usage of the struct - aggregating a collection of public keys, as opposed to just "aggregating" one. Resolves: #18
1954cc2
to
d428201
Compare
It is currently possible to call the
APK::verify
orPublicKey::verify
on the same signature type, leading to situations where even if a user is technically allowed to call the function, verification is in principle impossible, since the signature schemes used to produce a signature are different. Furthermore, thesign_vulnerable
function is arguably misnamed, since it is only actually vulnerable to a rogue key attack when used in a multi-signature context.In the interest of fixing this, this commit introduces a couple of changes to the API of the crate, designed to better distinguish and clarify the usage of the two different signature schemes it provides.
First and foremost, a new signature type -
MultisigSignature
is added, representing a signature produced using the multi-signature scheme. Conversely, the already existingSignature
type is taken to mean the a signature produced using the single-key scheme.The functions under
SecretKey
,sign_vulnerable
andsign
, are respectivelly renamed intosign
andsign_multisig
, and the latter is changed to return the newMultisigSignature
type. The "aggregated public key" type is renamed fromAPK
intoMultisigPublicKey
, to better denote its use and to be in line with the kind signature it can now verify using theverify
function - which is changed to take aMultisigSignature
.On a more subtle note, the
From<&PublicKey>
andFrom<&SecretKey>
implementations forMultisigPublicKey
, formerlyAPK
are removed and the API ofMultisigPublicKey::aggregate
is changed to not take&self
, and only take a slice ofPublicKey
. This is designed to promote the intended usage of the struct - aggregating a collection of public keys, as opposed to just "aggregating" one.Resolves: #18