Skip to content

Commit

Permalink
change in struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Soubhik Deb committed Jul 27, 2023
1 parent 0919623 commit f748c0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IBLSPublicKeyCompendium.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ interface IBLSPublicKeyCompendium {
/**
* @notice called to get the BN254 public keys that has been registered by an operator.
*/
function getRegisteredBN254Pubkeys(bytes32 pubkeyHash) external view returns (BN254.G1Point memory, BN254.G2Point memory);
function getRegisteredBN254Pubkeys(bytes32 pubkeyHash) external view returns (BN254Pubkeys memory);
}
7 changes: 2 additions & 5 deletions src/contracts/middleware/BLSOperatorStateRetriever.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ contract BLSOperatorStateRetriever {
struct Operator {
bytes32 operatorId;
uint96 stake;
BN254.G1Point pubkeyG1;
BN254.G2Point pubkeyG2;
IBLSPublicKeyCompendium.BN254Pubkeys pubkeys;
}

struct CheckSignaturesIndices {
Expand Down Expand Up @@ -72,12 +71,10 @@ contract BLSOperatorStateRetriever {
operators[i] = new Operator[](operatorIds.length);
for (uint256 j = 0; j < operatorIds.length; j++) {
bytes32 operatorId = bytes32(operatorIds[j]);
(BN254.G1Point memory pubkeyG1, BN254.G2Point memory pubkeyG2) = BLSPubkeyRegistry(address(registryCoordinator.blsPubkeyRegistry())).pubkeyCompendium().getRegisteredBN254Pubkeys(operatorId);
operators[i][j] = Operator({
operatorId: operatorId,
stake: stakeRegistry.getStakeForOperatorIdForQuorumAtBlockNumber(operatorId, quorumNumber, blockNumber),
pubkeyG1: pubkeyG1,
pubkeyG2: pubkeyG2
pubkeys: BLSPubkeyRegistry(address(registryCoordinator.blsPubkeyRegistry())).pubkeyCompendium().getRegisteredBN254Pubkeys(operatorId)
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/contracts/middleware/BLSPublicKeyCompendium.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ contract BLSPublicKeyCompendium is IBLSPublicKeyCompendium {
emit NewPubkeyRegistration(msg.sender, pubkeyG1, pubkeyG2);
}

function getRegisteredBN254Pubkeys(bytes32 pubkeyHash) external view returns (BN254.G1Point memory, BN254.G2Point memory) {
return (_operatorIDToPubkeys[pubkeyHash].BN254pubkeys.pubkeyG1, _operatorIDToPubkeys[pubkeyHash].BN254pubkeys.pubkeyG2);
function getRegisteredBN254Pubkeys(bytes32 pubkeyHash) external view returns (BN254Pubkeys memory) {
return _operatorIDToPubkeys[pubkeyHash].BN254pubkeys;
}

}
5 changes: 5 additions & 0 deletions src/test/mocks/BLSPublicKeyCompendiumMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ contract BLSPublicKeyCompendiumMock is IBLSPublicKeyCompendium, DSTest {
mapping(address => bytes32) public operatorToPubkeyHash;
/// @notice mapping from pubkey hash to operator address
mapping(bytes32 => address) public pubkeyHashToOperator;
/// @notice mapping from operatorID to pubkey
mapping(bytes32 => Pubkeys) internal _operatorIDToPubkeys;

/**
* @notice Called by an operator to register themselves as the owner of a BLS public key and reveal their G1 and G2 public key.
Expand All @@ -26,6 +28,9 @@ contract BLSPublicKeyCompendiumMock is IBLSPublicKeyCompendium, DSTest {
function registerBLSPublicKey(BN254.G1Point memory signedMessageHash, BN254.G1Point memory pubkeyG1, BN254.G2Point memory pubkeyG2) external {
}

function getRegisteredBN254Pubkeys(bytes32 pubkeyHash) external view returns (BN254Pubkeys memory) {
}

function registerPublicKey(BN254.G1Point memory pk) external {

bytes32 pubkeyHash = BN254.hashG1Point(pk);
Expand Down

0 comments on commit f748c0f

Please sign in to comment.