Skip to content

Commit

Permalink
Merge pull request #3 from PaintSwap/calldata
Browse files Browse the repository at this point in the history
use calldata
  • Loading branch information
0xSamWitch authored Mar 8, 2024
2 parents dfcad8d + b66ff56 commit 6d4df04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions contracts/SamWitchVRF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ contract SamWitchVRF is ISamWitchVRF, UUPSUpgradeable, OwnableUpgradeable {
address fulfillAddress,
uint256 callbackGasLimit,
uint256 numWords,
uint256[2] memory publicKey,
uint256[4] memory proof,
uint256[2] memory uPoint,
uint256[4] memory vComponents
uint256[2] calldata publicKey,
uint256[4] calldata proof,
uint256[2] calldata uPoint,
uint256[4] calldata vComponents
) external override returns (bool callSuccess) {
if (!oracles[oracle]) {
revert OnlyOracle();
Expand Down Expand Up @@ -127,9 +127,9 @@ contract SamWitchVRF is ISamWitchVRF, UUPSUpgradeable, OwnableUpgradeable {
/// @param message The message (in bytes) used for computing the VRF
/// @return The fast verify required parameters as the tuple `([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY])`
function computeFastVerifyParams(
uint256[2] memory publicKey,
uint256[4] memory proof,
bytes memory message
uint256[2] calldata publicKey,
uint256[4] calldata proof,
bytes calldata message
) external pure returns (uint256[2] memory, uint256[4] memory) {
return VRF.computeFastVerifyParams(publicKey, proof, message);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ contract SamWitchVRF is ISamWitchVRF, UUPSUpgradeable, OwnableUpgradeable {
return success;
}

function _randomValueFromVRFProof(uint256[4] memory _proof) private view returns (uint256 output) {
function _randomValueFromVRFProof(uint256[4] calldata _proof) private view returns (uint256 output) {
return uint256(keccak256(abi.encode(block.chainid, _proof[0], _proof[1], _proof[2], _proof[3])));
}

Expand Down
18 changes: 9 additions & 9 deletions contracts/libraries/VRF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ library VRF {
/// @param _message The message (in bytes) used for computing the VRF
/// @return true, if VRF proof is valid
function verify(
uint256[2] memory _publicKey,
uint256[4] memory _proof,
uint256[2] calldata _publicKey,
uint256[4] calldata _proof,
bytes memory _message
) internal pure returns (bool) {
// Step 2: Hash to try and increment (outputs a hashed value, a finite EC point in G)
Expand Down Expand Up @@ -105,11 +105,11 @@ library VRF {
/// @param _vComponents The components required to compute `v` as `V = s*H - c*Gamma`
/// @return true, if VRF proof is valid
function fastVerify(
uint256[2] memory _publicKey,
uint256[4] memory _proof,
uint256[2] calldata _publicKey,
uint256[4] calldata _proof,
bytes memory _message,
uint256[2] memory _uPoint,
uint256[4] memory _vComponents
uint256[2] calldata _uPoint,
uint256[4] calldata _vComponents
) internal pure returns (bool) {
// Step 2: Hash to try and increment -> hashed value, a finite EC point in G
(uint256 hPointX, uint256 hPointY) = hashToTryAndIncrement(_publicKey, _message);
Expand Down Expand Up @@ -186,8 +186,8 @@ library VRF {
/// @param _message The message (in bytes) used for computing the VRF
/// @return The fast verify required parameters as the tuple `([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY])`
function computeFastVerifyParams(
uint256[2] memory _publicKey,
uint256[4] memory _proof,
uint256[2] calldata _publicKey,
uint256[4] calldata _proof,
bytes memory _message
) internal pure returns (uint256[2] memory, uint256[4] memory) {
// Requirements for Step 3: U = s*B - c*Y (where B is the generator)
Expand All @@ -206,7 +206,7 @@ library VRF {
/// @param _message The message used for computing the VRF
/// @return The hash point in affine cooridnates
function hashToTryAndIncrement(
uint256[2] memory _publicKey,
uint256[2] calldata _publicKey,
bytes memory _message
) internal pure returns (uint, uint) {
// Step 1: public key to bytes
Expand Down

0 comments on commit 6d4df04

Please sign in to comment.