-
Notifications
You must be signed in to change notification settings - Fork 96
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: pubkey compendium stores pubkeys #51
refactor: pubkey compendium stores pubkeys #51
Conversation
... which means pubkey parameters for various functions/structs can be removed
…t with other registry contracts
require( | ||
pubkeyHash != ZERO_PK_HASH, "BLSPublicKeyCompendium.registerBLSPublicKey: cannot register zero pubkey" | ||
); |
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.
seems odd we weren't doing this before. @gpsanant is there something else preventing someone from registering the zero key? Lack of knowledge of the corresponding private key?
guess we could check that the G1 point doesn't equal the zero point, but this is equivalent 🤷
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'm also curious about this. private key for zero point is just 0, so that shouldn't be the problem.
Seems like one could register by using pkG2=sigG1=0 ? I think the check e(sigG1,G2)=e(h(m),pkG2)
would pass sincee(0,anything) = e(anything,0) = 0
afaiu (it's a multilinear map after all)
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.
this isn't really a substantive check, it's not needed, it doesn't prevent any attacks
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.
so it might not prevent an attack per se, but it would prevent weird behavior, right?
the fact that the apk doesn't change when zero is added to or subtracted from it feels like it could lead to some strange effects. For example, any signature would appear as if you both did and didn't sign it, depending on the interpretation in the context of the code.
I get that it's like using a key that everyone else knows, but it also has this special aspect. Seems safer to avoid the possibility of it happening.
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.
this isn't really a substantive check, it's not needed, it doesn't prevent any attacks
i think it's more substantive now, since nowhere else checks this. i got rid of the checks against the zero hash in the pk registry in favor of checking it here
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.
Loving this PR, thank you!
I have been in favor of this storage change for a while, and this PR really helps make the simplifications it enables clear.
Renaming changes LGTM as well.
I noted one place where we are doing a redundant (and as far as I understand potentially expensive?) check, but we can debate that later / I wouldn't consider resolving the discussion to be blocking for this PR, personally.
Builds on PR #28 and #43; merge those first! It looks like I'm merging 20 commits, but those are actually commits from the other PRs :) Only the final 2 commits in this PR are relevant.
Functional changes in this PR:
BLSPublicKeyCompendium
:operatorToPubkey
, which maps operator addresses toG1Point
BLSPublicKeyCompendium.getRegisteredPubkey(address)
which performs a pubkey lookup along with validation that the pubkey exists/isn't the zero pubkey.BLSPubkeyRegistry
BLSPubkeyRegistry
andBLSRegistryCoordinatorWithIndices
. The pubkey registry is able to look up pubkeys with just an operator address, now.BLSPubkeyRegistry
state variable naming changes (these better match the rest of the contracts):quorumApk
->currentApk
quorumApkUpdates
->apkHistory
BLSPubkeyRegistry
view function naming changes:getApkIndicesForQuorumsAtBlockNumber
->getApkIndicesAtBlockNumber
getApkForQuorum
->getApk
getApkUpdateForQuorumByIndex
->getApkUpdateAtIndex
getApkHashForQuorumAtBlockNumberFromIndex
->getApkHashAtBlockNumberAndIndex
getQuorumApkHistoryLength
->getApkHistoryLength
Recommended review order:
BLSPublicKeyCompendium
changes inb883fd0
to see what new state we're tracking and get some context for the other changes in this commit.