Skip to content

Commit

Permalink
dependency update
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 committed Jun 5, 2024
1 parent 339c666 commit 691419d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/RAVEBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0 <0.9.0;

import { BytesUtils } from "./BytesUtils.sol";
import { RSAVerify } from "ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol";
import { RSAVerify } from "./RSAVerify.sol";
import { IRave } from "rave/IRave.sol";

abstract contract RAVEBase is IRave {
Expand Down
37 changes: 37 additions & 0 deletions src/RSAVerify.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pragma solidity >=0.8.0 <0.9.0;

// Copied from https://github.com/ensdomains/ens-contracts/blob/80aa5108f11d11cd7956135ef21ac45da8eb934d/contracts/dnssec-oracle/algorithms/RSAVerify.sol

library ModexpPrecompile {
/**
* @dev Computes (base ^ exponent) % modulus over big numbers.
*/
function modexp(bytes memory base, bytes memory exponent, bytes memory modulus)
internal
view
returns (bool success, bytes memory output)
{
bytes memory input = abi.encodePacked(
uint256(base.length), uint256(exponent.length), uint256(modulus.length), base, exponent, modulus
);

output = new bytes(modulus.length);

assembly {
success := staticcall(gas(), 5, add(input, 32), mload(input), add(output, 32), mload(modulus))
}
}
}

library RSAVerify {
/**
* @dev Recovers the input data from an RSA signature, returning the result in S.
* @param N The RSA public modulus.
* @param E The RSA public exponent.
* @param S The signature to recover.
* @return True if the recovery succeeded.
*/
function rsarecover(bytes memory N, bytes memory E, bytes memory S) internal view returns (bool, bytes memory) {
return ModexpPrecompile.modexp(S, E, N);
}
}
2 changes: 1 addition & 1 deletion src/X509Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0 <0.9.0;

import { Asn1Decode, NodePtr } from "rave/ASN1Decode.sol";
import { RSAVerify } from "ens-contracts/dnssec-oracle/algorithms/RSAVerify.sol";
import { RSAVerify } from "./RSAVerify.sol";
import { BytesUtils } from "./BytesUtils.sol";

library X509Verifier {
Expand Down

0 comments on commit 691419d

Please sign in to comment.