1 Commits

Author SHA1 Message Date
kautukkundan
e4e3309b30 added eip-712 to verification gateway 2022-05-26 10:50:00 +05:30
4 changed files with 16 additions and 11 deletions

View File

@@ -1,3 +1,3 @@
import { arrayify, keccak256 } from "ethers/lib/utils";
import { arrayify } from "ethers/lib/utils";
export default arrayify(keccak256("0xfeedbee5"));
export default arrayify("0x425bd46b7016e0395c00f2e05fd74f938023d31f355d5a62fb9c63756c6a5d87");

View File

@@ -8,7 +8,7 @@ import { initBlsWalletSigner, Bundle, Operation } from "../src/signer";
import Range from "./helpers/Range";
const domain = arrayify(keccak256("0xfeedbee5"));
const domain = arrayify("0x425bd46b7016e0395c00f2e05fd74f938023d31f355d5a62fb9c63756c6a5d87");
const weiPerToken = BigNumber.from(10).pow(18);
const samples = (() => {

View File

@@ -8,6 +8,7 @@ import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "./interfaces/IWallet.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
/**
A non-upgradable gateway used to create BLSWallets and call them with
@@ -16,12 +17,13 @@ The gateway holds a single ProxyAdmin contract for all wallets, and can
only called by a wallet that the VG created, and only if the first param
is the calling wallet's address.
*/
contract VerificationGateway
contract VerificationGateway is EIP712
{
/** Domain chosen arbitrarily */
bytes32 BLS_DOMAIN = keccak256(abi.encodePacked(uint32(0xfeedbee5)));
uint8 constant BLS_KEY_LEN = 4;
string public constant BLS_DOMAIN = "BLS_WALLET";
string public constant BLS_DOMAIN_VERSION = "1";
IBLS public blsLib;
ProxyAdmin public immutable walletProxyAdmin;
address public blsWalletLogic;
@@ -53,7 +55,7 @@ contract VerificationGateway
constructor(
IBLS bls,
address blsWalletImpl
) {
) EIP712(BLS_DOMAIN, BLS_DOMAIN_VERSION) {
blsLib = bls;
blsWalletLogic = blsWalletImpl;
walletProxyAdmin = new ProxyAdmin();
@@ -303,7 +305,7 @@ contract VerificationGateway
address wallet
) private {
uint256[2] memory addressMsg = blsLib.hashToPoint(
BLS_DOMAIN,
_domainSeparatorV4(),
abi.encodePacked(wallet)
);
require(
@@ -352,7 +354,7 @@ contract VerificationGateway
);
}
return blsLib.hashToPoint(
BLS_DOMAIN,
_domainSeparatorV4(),
abi.encodePacked(
block.chainid,
op.nonce,
@@ -361,4 +363,7 @@ contract VerificationGateway
);
}
function domainSeparator() public view returns (bytes32) {
return _domainSeparatorV4();
}
}

View File

@@ -42,6 +42,7 @@ async function main() {
console.log("deploying bls-wallet contracts...");
const fx = await Fixture.create();
const [deployedBy] = fx.addresses;
const domainSeparator = await fx.verificationGateway.domainSeparator();
console.log("deploying test token...");
// These can be run in parallel
@@ -61,8 +62,7 @@ async function main() {
auxiliary: {
chainid: fx.chainId,
// From VerificationGateway.sol:BLS_DOMAIN
domain:
"0x0054159611832e24cdd64c6a133e71d373c5f8553dde6c762e6bffe707ad83cc",
domain: domainSeparator,
genesisBlock,
deployedBy,
version,