Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/libraries/BN254.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ library BN254 {
uint256[2] Y;
}

function generatorG1() external pure returns (G1Point memory) {
function generatorG1() internal pure returns (G1Point memory) {
return G1Point(1, 2);
}

Expand All @@ -62,7 +62,7 @@ library BN254 {
/// this is because of the (unknown to us) convention used in the bn254 pairing precompile contract
/// "Elements a * i + b of F_p^2 are encoded as two elements of F_p, (a, b)."
/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md#encoding
function generatorG2() external pure returns (G2Point memory) {
function generatorG2() internal pure returns (G2Point memory) {
return G2Point([G2x1, G2x0], [G2y1, G2y0]);
}

Expand All @@ -73,7 +73,7 @@ library BN254 {
uint256 internal constant nG2y1 = 17805874995975841540914202342111839520379459829704422454583296818431106115052;
uint256 internal constant nG2y0 = 13392588948715843804641432497768002650278120570034223513918757245338268106653;

function negGeneratorG2() external pure returns (G2Point memory) {
function negGeneratorG2() internal pure returns (G2Point memory) {
return G2Point([nG2x1, nG2x0], [nG2y1, nG2y0]);
}

Expand All @@ -84,7 +84,7 @@ library BN254 {
* @param p Some point in G1.
* @return The negation of `p`, i.e. p.plus(p.negate()) should be zero.
*/
function negate(G1Point memory p) external pure returns (G1Point memory) {
function negate(G1Point memory p) internal pure returns (G1Point memory) {
// The prime q in the base field F_q for G1
if (p.X == 0 && p.Y == 0) {
return G1Point(0, 0);
Expand Down Expand Up @@ -122,7 +122,7 @@ library BN254 {
* @param p the point to multiply
* @param s the scalar to multiply by
* @dev this function is only safe to use if the scalar is 9 bits or less
*/
*/
function scalar_mul_tiny(BN254.G1Point memory p, uint16 s) internal view returns (BN254.G1Point memory) {
require(s < 2**9, "scalar-too-large");

Expand Down Expand Up @@ -155,7 +155,7 @@ library BN254 {
++i;
}
}

// return the accumulated product
return acc;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ library BN254 {
G2Point memory a2,
G1Point memory b1,
G2Point memory b2
) external view returns (bool) {
) internal view returns (bool) {
G1Point[2] memory p1 = [a1, b1];
G2Point[2] memory p2 = [a2, b2];

Expand Down Expand Up @@ -238,7 +238,7 @@ library BN254 {
G1Point memory b1,
G2Point memory b2,
uint256 pairingGas
) external view returns (bool, bool) {
) internal view returns (bool, bool) {
G1Point[2] memory p1 = [a1, b1];
G2Point[2] memory p2 = [a2, b2];

Expand Down Expand Up @@ -270,7 +270,7 @@ library BN254 {

/// @return hashedG1 the keccak256 hash of the G1 Point
/// @dev used for BLS signatures
function hashG1Point(BN254.G1Point memory pk) external pure returns (bytes32 hashedG1) {
function hashG1Point(BN254.G1Point memory pk) internal pure returns (bytes32 hashedG1) {
assembly {
mstore(0, mload(pk))
mstore(0x20, mload(add(0x20, pk)))
Expand All @@ -282,14 +282,14 @@ library BN254 {
/// @dev used for BLS signatures
function hashG2Point(
BN254.G2Point memory pk
) external pure returns (bytes32) {
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(pk.X[0], pk.X[1], pk.Y[0], pk.Y[1]));
}

/**
* @notice adapted from https://github.com/HarryR/solcrypto/blob/master/contracts/altbn128.sol
*/
function hashToG1(bytes32 _x) external view returns (G1Point memory) {
function hashToG1(bytes32 _x) internal view returns (G1Point memory) {
uint256 beta = 0;
uint256 y = 0;

Expand Down
8 changes: 4 additions & 4 deletions src/libraries/QuorumBitmapHistoryLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library QuorumBitmapHistoryLib {
function currentOperatorBitmap(
mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self,
bytes32 operatorId
) external view returns (uint192) {
) internal view returns (uint192) {
uint256 historyLength = self[operatorId].length;
if (historyLength == 0) {
return 0;
Expand All @@ -59,7 +59,7 @@ library QuorumBitmapHistoryLib {
mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self,
uint32 blockNumber,
bytes32[] memory operatorIds
) external view returns (uint32[] memory) {
) internal view returns (uint32[] memory) {
uint32[] memory indices = new uint32[](operatorIds.length);
for (uint256 i = 0; i < operatorIds.length; i++) {
indices[i] = getQuorumBitmapIndexAtBlockNumber(self, blockNumber, operatorIds[i]);
Expand All @@ -78,7 +78,7 @@ library QuorumBitmapHistoryLib {
bytes32 operatorId,
uint32 blockNumber,
uint256 index
) external view returns (uint192) {
) internal view returns (uint192) {
IRegistryCoordinator.QuorumBitmapUpdate memory quorumBitmapUpdate = self[operatorId][index];

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ library QuorumBitmapHistoryLib {
mapping(bytes32 => IRegistryCoordinator.QuorumBitmapUpdate[]) storage self,
bytes32 operatorId,
uint192 newBitmap
) external {
) internal {
uint256 historyLength = self[operatorId].length;

if (historyLength == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/SignatureCheckerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "@openzeppelin-upgrades/contracts/utils/cryptography/SignatureCheckerUpgr
*/
library SignatureCheckerLib {
error InvalidSignature();

/**
* @notice Validates a signature using EIP-1271 standard.
* @param signer The address of the signer.
Expand All @@ -22,7 +22,7 @@ library SignatureCheckerLib {
address signer,
bytes32 digestHash,
bytes memory signature
) external view {
) internal view {
if (!SignatureCheckerUpgradeable.isValidSignatureNow(signer, digestHash, signature)) {
revert InvalidSignature();
}
Expand Down
Loading