Skip to content

Commit

Permalink
chore: shorten variable name that is quite clear from context
Browse files Browse the repository at this point in the history
`pubkeyRegistrationParams` => `params`
see discussion here:
#100 (comment)
  • Loading branch information
ChaoticWalrus authored and steven committed Dec 18, 2023
1 parent f9d020a commit 96311bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
26 changes: 13 additions & 13 deletions src/BLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
/**
* @notice Called by the RegistryCoordinator register an operator as the owner of a BLS public key.
* @param operator is the operator for whom the key is being registered
* @param pubkeyRegistrationParams contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
*/
function registerBLSPublicKey(
address operator,
PubkeyRegistrationParams calldata pubkeyRegistrationParams
PubkeyRegistrationParams calldata params
) external onlyRegistryCoordinator returns (bytes32 operatorId) {
bytes32 pubkeyHash = BN254.hashG1Point(pubkeyRegistrationParams.pubkeyG1);
bytes32 pubkeyHash = BN254.hashG1Point(params.pubkeyG1);
require(
pubkeyHash != ZERO_PK_HASH, "BLSApkRegistry.registerBLSPublicKey: cannot register zero pubkey"
);
Expand All @@ -120,29 +120,29 @@ contract BLSApkRegistry is BLSApkRegistryStorage {

// gamma = h(sigma, P, P', H(m))
uint256 gamma = uint256(keccak256(abi.encodePacked(
pubkeyRegistrationParams.pubkeyRegistrationSignature.X,
pubkeyRegistrationParams.pubkeyRegistrationSignature.Y,
pubkeyRegistrationParams.pubkeyG1.X,
pubkeyRegistrationParams.pubkeyG1.Y,
pubkeyRegistrationParams.pubkeyG2.X,
pubkeyRegistrationParams.pubkeyG2.Y,
params.pubkeyRegistrationSignature.X,
params.pubkeyRegistrationSignature.Y,
params.pubkeyG1.X,
params.pubkeyG1.Y,
params.pubkeyG2.X,
params.pubkeyG2.Y,
messageHash.X,
messageHash.Y
))) % BN254.FR_MODULUS;

// e(sigma + P * gamma, [-1]_2) = e(H(m) + [1]_1 * gamma, P')
require(BN254.pairing(
pubkeyRegistrationParams.pubkeyRegistrationSignature.plus(pubkeyRegistrationParams.pubkeyG1.scalar_mul(gamma)),
params.pubkeyRegistrationSignature.plus(params.pubkeyG1.scalar_mul(gamma)),
BN254.negGeneratorG2(),
messageHash.plus(BN254.generatorG1().scalar_mul(gamma)),
pubkeyRegistrationParams.pubkeyG2
params.pubkeyG2
), "BLSApkRegistry.registerBLSPublicKey: either the G1 signature is wrong, or G1 and G2 private key do not match");

operatorToPubkey[operator] = pubkeyRegistrationParams.pubkeyG1;
operatorToPubkey[operator] = params.pubkeyG1;
operatorToPubkeyHash[operator] = pubkeyHash;
pubkeyHashToOperator[pubkeyHash] = operator;

emit NewPubkeyRegistration(operator, pubkeyRegistrationParams.pubkeyG1, pubkeyRegistrationParams.pubkeyG2);
emit NewPubkeyRegistration(operator, params.pubkeyG1, params.pubkeyG2);
return pubkeyHash;
}

Expand Down
18 changes: 9 additions & 9 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,21 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
* @notice Registers msg.sender as an operator for one or more quorums. If any quorum reaches its maximum
* operator capacity, this method will fail.
* @param quorumNumbers is an ordered byte array containing the quorum numbers being registered for
* @param pubkeyRegistrationParams contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @dev the `pubkeyRegistrationParams` input param is ignored if the caller has previously registered a public key
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @dev the `params` input param is ignored if the caller has previously registered a public key
*/
function registerOperator(
bytes calldata quorumNumbers,
string calldata socket,
IBLSApkRegistry.PubkeyRegistrationParams calldata pubkeyRegistrationParams
IBLSApkRegistry.PubkeyRegistrationParams calldata params
) external onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
/**
* IF the operator has never registered a pubkey before, THEN register their pubkey
* OTHERWISE, simply ignore the provided `pubkeyRegistrationParams`
* OTHERWISE, simply ignore the provided `params`
*/
bytes32 operatorId = blsApkRegistry.getOperatorId(msg.sender);
if (operatorId == 0) {
operatorId = blsApkRegistry.registerBLSPublicKey(msg.sender, pubkeyRegistrationParams);
operatorId = blsApkRegistry.registerBLSPublicKey(msg.sender, params);
}

// Register the operator in each of the registry contracts
Expand Down Expand Up @@ -192,16 +192,16 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
* @notice Registers msg.sender as an operator for one or more quorums. If any quorum reaches its maximum operator
* capacity, `operatorKickParams` is used to replace an old operator with the new one.
* @param quorumNumbers is an ordered byte array containing the quorum numbers being registered for
* @param pubkeyRegistrationParams contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @param operatorKickParams are used to determine which operator is removed to maintain quorum capacity as the
* operator registers for quorums.
* @param churnApproverSignature is the signature of the churnApprover on the operator kick params
* @dev the `pubkeyRegistrationParams` input param is ignored if the caller has previously registered a public key
* @dev the `params` input param is ignored if the caller has previously registered a public key
*/
function registerOperatorWithChurn(
bytes calldata quorumNumbers,
string calldata socket,
IBLSApkRegistry.PubkeyRegistrationParams calldata pubkeyRegistrationParams,
IBLSApkRegistry.PubkeyRegistrationParams calldata params,
OperatorKickParam[] calldata operatorKickParams,
SignatureWithSaltAndExpiry memory churnApproverSignature
) external onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
Expand All @@ -213,7 +213,7 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
*/
bytes32 operatorId = blsApkRegistry.getOperatorId(msg.sender);
if (operatorId == 0) {
operatorId = blsApkRegistry.registerBLSPublicKey(msg.sender, pubkeyRegistrationParams);
operatorId = blsApkRegistry.registerBLSPublicKey(msg.sender, params);
}

// Verify the churn approver's signature for the registering operator and kick params
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/IBLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ interface IBLSApkRegistry is IRegistry {
/**
* @notice Called by the RegistryCoordinator register an operator as the owner of a BLS public key.
* @param operator is the operator for whom the key is being registered
* @param pubkeyRegistrationParams contains the G1 & G2 public keys of the operator, and a signature proving their ownership
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
*/
function registerBLSPublicKey(
address operator,
PubkeyRegistrationParams calldata pubkeyRegistrationParams
PubkeyRegistrationParams calldata params
) external returns (bytes32 operatorId);

/**
Expand Down

0 comments on commit 96311bb

Please sign in to comment.