From e071b0fb551a72f0010045c06bbe7e831f5a0c7e Mon Sep 17 00:00:00 2001 From: b1m0n Date: Wed, 10 Apr 2024 01:49:57 +0700 Subject: [PATCH] Update ECDSA lib version --- contracts/eip712/TestPaymaster.sol | 2 +- contracts/eip712/tmp/TestPaymasterBytecode | 2 +- contracts/libraries/ECDSA.sol | 25 +++------------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/contracts/eip712/TestPaymaster.sol b/contracts/eip712/TestPaymaster.sol index ea15994..8a3f0ee 100644 --- a/contracts/eip712/TestPaymaster.sol +++ b/contracts/eip712/TestPaymaster.sol @@ -21,7 +21,7 @@ contract TestPaymaster is IPaymaster, EIP712 { } function signDataMessage(bytes32 suggestedSignedHash) internal view returns (bytes32) { - return ECDSA.toTypedDataHash(_domainSeparatorV4(), keccak256(abi.encode( + return _hashTypedDataV4(keccak256(abi.encode( signDataTypeHash(), suggestedSignedHash ))); diff --git a/contracts/eip712/tmp/TestPaymasterBytecode b/contracts/eip712/tmp/TestPaymasterBytecode index 457fa7a..c5c6ca3 100644 --- a/contracts/eip712/tmp/TestPaymasterBytecode +++ b/contracts/eip712/tmp/TestPaymasterBytecode @@ -1 +1 @@ -61014060405234801562000011575f80fd5b506040516200123b3803806200123b833981810160405281019062000037919062000314565b81815f828051906020012090505f828051906020012090505f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e08181525050816101008181525050620000946200013e60201b60201c565b60a08181525050620000ae8184846200014560201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250508061012081815250505050505050335f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505062000469565b5f46905090565b5f838383620001596200013e60201b60201c565b30604051602001620001709594939291906200040e565b6040516020818303038152906040528051906020012090509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620001f082620001a8565b810181811067ffffffffffffffff82111715620002125762000211620001b8565b5b80604052505050565b5f620002266200018f565b9050620002348282620001e5565b919050565b5f67ffffffffffffffff821115620002565762000255620001b8565b5b6200026182620001a8565b9050602081019050919050565b5f5b838110156200028d57808201518184015260208101905062000270565b5f8484015250505050565b5f620002ae620002a88462000239565b6200021b565b905082815260208101848484011115620002cd57620002cc620001a4565b5b620002da8482856200026e565b509392505050565b5f82601f830112620002f957620002f8620001a0565b5b81516200030b84826020860162000298565b91505092915050565b5f80604083850312156200032d576200032c62000198565b5b5f83015167ffffffffffffffff8111156200034d576200034c6200019c565b5b6200035b85828601620002e2565b925050602083015167ffffffffffffffff8111156200037f576200037e6200019c565b5b6200038d85828601620002e2565b9150509250929050565b5f819050919050565b620003ab8162000397565b82525050565b5f819050919050565b620003c581620003b1565b82525050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f620003f682620003cb565b9050919050565b6200040881620003ea565b82525050565b5f60a082019050620004235f830188620003a0565b620004326020830187620003a0565b620004416040830186620003a0565b620004506060830185620003ba565b6200045f6080830184620003fd565b9695505050505050565b60805160a05160c05160e0516101005161012051610d8a620004b15f395f6102b901525f6102fb01525f6102da01525f61020801525f61025e01525f61028e0152610d8a5ff3fe608060405260043610610033575f3560e01c8063391c91d2146100375780638da5cb5b146100685780639f3cb0b014610092575b5f80fd5b610051600480360381019061004c9190610814565b6100ae565b60405161005f929190610964565b60405180910390f35b348015610073575f80fd5b5061007c610167565b60405161008991906109d1565b60405180910390f35b6100ac60048036038101906100a79190610a9d565b61018a565b005b5f60605f6100c46100be87610193565b866101db565b90505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610153576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161014a90610be3565b60405180910390fd5b63391c91d260e01b92505094509492505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b50505050505050565b5f6101d461019f610205565b6101a7610325565b846040516020016101b9929190610c10565b6040516020818303038152906040528051906020012061034c565b9050919050565b5f805f806101e9868661038c565b9250925092506101f982826103e1565b82935050505092915050565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561028757507f0000000000000000000000000000000000000000000000000000000000000000610285610543565b145b156102b4577f00000000000000000000000000000000000000000000000000000000000000009050610322565b61031f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061054a565b90505b90565b5f7f2bb156903cb7269fcabf8c90e4a20f3c4eaf1dde6b407dbc50a24ac21c9fab69905090565b5f6040517f190100000000000000000000000000000000000000000000000000000000000081528360028201528260228201526042812091505092915050565b5f805f60418451036103cc575f805f602087015192506040870151915060608701515f1a90506103be8882858561058a565b9550955095505050506103da565b5f600285515f1b9250925092505b9250925092565b5f60038111156103f4576103f3610c37565b5b82600381111561040757610406610c37565b5b031561053f576001600381111561042157610420610c37565b5b82600381111561043457610433610c37565b5b0361046b576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600381111561047f5761047e610c37565b5b82600381111561049257610491610c37565b5b036104d657805f1c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016104cd9190610c73565b60405180910390fd5b6003808111156104e9576104e8610c37565b5b8260038111156104fc576104fb610c37565b5b0361053e57806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016105359190610c8c565b60405180910390fd5b5b5050565b5f46905090565b5f838383610556610543565b3060405160200161056b959493929190610ca5565b6040516020818303038152906040528051906020012090509392505050565b5f805f7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0845f1c11156105c6575f600385925092509250610667565b5f6001888888886040515f81526020016040526040516105e99493929190610d11565b6020604051602081039080840390855afa158015610609573d5f803e3d5ffd5b5050506020604051035190505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361065a575f60015f801b93509350935050610667565b805f805f1b935093509350505b9450945094915050565b5f604051905090565b5f80fd5b5f80fd5b5f819050919050565b61069481610682565b811461069e575f80fd5b50565b5f813590506106af8161068b565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610703826106bd565b810181811067ffffffffffffffff82111715610722576107216106cd565b5b80604052505050565b5f610734610671565b905061074082826106fa565b919050565b5f67ffffffffffffffff82111561075f5761075e6106cd565b5b610768826106bd565b9050602081019050919050565b828183375f83830152505050565b5f61079561079084610745565b61072b565b9050828152602081018484840111156107b1576107b06106b9565b5b6107bc848285610775565b509392505050565b5f82601f8301126107d8576107d76106b5565b5b81356107e8848260208601610783565b91505092915050565b5f80fd5b5f610220828403121561080b5761080a6107f1565b5b81905092915050565b5f805f806080858703121561082c5761082b61067a565b5b5f610839878288016106a1565b945050602061084a878288016106a1565b935050604085013567ffffffffffffffff81111561086b5761086a61067e565b5b610877878288016107c4565b925050606085013567ffffffffffffffff8111156108985761089761067e565b5b6108a4878288016107f5565b91505092959194509250565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6108e4816108b0565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610921578082015181840152602081019050610906565b5f8484015250505050565b5f610936826108ea565b61094081856108f4565b9350610950818560208601610904565b610959816106bd565b840191505092915050565b5f6040820190506109775f8301856108db565b8181036020830152610989818461092c565b90509392505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6109bb82610992565b9050919050565b6109cb816109b1565b82525050565b5f6020820190506109e45f8301846109c2565b92915050565b5f80fd5b5f80fd5b5f8083601f840112610a0757610a066106b5565b5b8235905067ffffffffffffffff811115610a2457610a236109ea565b5b602083019150836001820283011115610a4057610a3f6109ee565b5b9250929050565b60028110610a53575f80fd5b50565b5f81359050610a6481610a47565b92915050565b5f819050919050565b610a7c81610a6a565b8114610a86575f80fd5b50565b5f81359050610a9781610a73565b92915050565b5f805f805f805f60c0888a031215610ab857610ab761067a565b5b5f88013567ffffffffffffffff811115610ad557610ad461067e565b5b610ae18a828b016109f2565b9750975050602088013567ffffffffffffffff811115610b0457610b0361067e565b5b610b108a828b016107f5565b9550506040610b218a828b016106a1565b9450506060610b328a828b016106a1565b9350506080610b438a828b01610a56565b92505060a0610b548a828b01610a89565b91505092959891949750929550565b5f82825260208201905092915050565b7f5061796d61737465723a20556e617574686f72697a6564207369676e617475725f8201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b5f610bcd602183610b63565b9150610bd882610b73565b604082019050919050565b5f6020820190508181035f830152610bfa81610bc1565b9050919050565b610c0a81610682565b82525050565b5f604082019050610c235f830185610c01565b610c306020830184610c01565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b610c6d81610a6a565b82525050565b5f602082019050610c865f830184610c64565b92915050565b5f602082019050610c9f5f830184610c01565b92915050565b5f60a082019050610cb85f830188610c01565b610cc56020830187610c01565b610cd26040830186610c01565b610cdf6060830185610c64565b610cec60808301846109c2565b9695505050505050565b5f60ff82169050919050565b610d0b81610cf6565b82525050565b5f608082019050610d245f830187610c01565b610d316020830186610d02565b610d3e6040830185610c01565b610d4b6060830184610c01565b9594505050505056fea2646970667358221220d2a7d277607bf46c3ee79ab177bb58aabc4fccb2381b50fec4e37ec7e100e69a64736f6c63430008140033 \ No newline at end of file +61014060405234801562000011575f80fd5b50604051620012d5380380620012d5833981810160405281019062000037919062000314565b81815f828051906020012090505f828051906020012090505f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e08181525050816101008181525050620000946200013e60201b60201c565b60a08181525050620000ae8184846200014560201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250508061012081815250505050505050335f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505062000469565b5f46905090565b5f838383620001596200013e60201b60201c565b30604051602001620001709594939291906200040e565b6040516020818303038152906040528051906020012090509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620001f082620001a8565b810181811067ffffffffffffffff82111715620002125762000211620001b8565b5b80604052505050565b5f620002266200018f565b9050620002348282620001e5565b919050565b5f67ffffffffffffffff821115620002565762000255620001b8565b5b6200026182620001a8565b9050602081019050919050565b5f5b838110156200028d57808201518184015260208101905062000270565b5f8484015250505050565b5f620002ae620002a88462000239565b6200021b565b905082815260208101848484011115620002cd57620002cc620001a4565b5b620002da8482856200026e565b509392505050565b5f82601f830112620002f957620002f8620001a0565b5b81516200030b84826020860162000298565b91505092915050565b5f80604083850312156200032d576200032c62000198565b5b5f83015167ffffffffffffffff8111156200034d576200034c6200019c565b5b6200035b85828601620002e2565b925050602083015167ffffffffffffffff8111156200037f576200037e6200019c565b5b6200038d85828601620002e2565b9150509250929050565b5f819050919050565b620003ab8162000397565b82525050565b5f819050919050565b620003c581620003b1565b82525050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f620003f682620003cb565b9050919050565b6200040881620003ea565b82525050565b5f60a082019050620004235f830188620003a0565b620004326020830187620003a0565b620004416040830186620003a0565b620004506060830185620003ba565b6200045f6080830184620003fd565b9695505050505050565b60805160a05160c05160e0516101005161012051610e24620004b15f395f6104c701525f61050901525f6104e801525f61041601525f61046c01525f61049c0152610e245ff3fe608060405260043610610033575f3560e01c8063391c91d2146100375780638da5cb5b146100685780639f3cb0b014610092575b5f80fd5b610051600480360381019061004c9190610804565b6100ae565b60405161005f929190610954565b60405180910390f35b348015610073575f80fd5b5061007c610167565b60405161008991906109c1565b60405180910390f35b6100ac60048036038101906100a79190610a8d565b61018a565b005b5f60605f6100c46100be87610193565b866101d3565b90505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610153576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161014a90610bd3565b60405180910390fd5b63391c91d260e01b92505094509492505050565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b50505050505050565b5f6101cc61019f6101fd565b836040516020016101b1929190610c00565b60405160208183030381529060405280519060200120610224565b9050919050565b5f805f806101e1868661025c565b9250925092506101f182826102b1565b82935050505092915050565b5f7f2bb156903cb7269fcabf8c90e4a20f3c4eaf1dde6b407dbc50a24ac21c9fab69905090565b5f61022d610413565b8260405160200161023f929190610c9b565b604051602081830303815290604052805190602001209050919050565b5f805f604184510361029c575f805f602087015192506040870151915060608701515f1a905061028e88828585610533565b9550955095505050506102aa565b5f600285515f1b9250925092505b9250925092565b5f60038111156102c4576102c3610cd1565b5b8260038111156102d7576102d6610cd1565b5b031561040f57600160038111156102f1576102f0610cd1565b5b82600381111561030457610303610cd1565b5b0361033b576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600381111561034f5761034e610cd1565b5b82600381111561036257610361610cd1565b5b036103a657805f1c6040517ffce698f700000000000000000000000000000000000000000000000000000000815260040161039d9190610d0d565b60405180910390fd5b6003808111156103b9576103b8610cd1565b5b8260038111156103cc576103cb610cd1565b5b0361040e57806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016104059190610d26565b60405180910390fd5b5b5050565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561049557507f000000000000000000000000000000000000000000000000000000000000000061049361061a565b145b156104c2577f00000000000000000000000000000000000000000000000000000000000000009050610530565b61052d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610621565b90505b90565b5f805f7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0845f1c111561056f575f600385925092509250610610565b5f6001888888886040515f81526020016040526040516105929493929190610d5a565b6020604051602081039080840390855afa1580156105b2573d5f803e3d5ffd5b5050506020604051035190505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610603575f60015f801b93509350935050610610565b805f805f1b935093509350505b9450945094915050565b5f46905090565b5f83838361062d61061a565b30604051602001610642959493929190610d9d565b6040516020818303038152906040528051906020012090509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f819050919050565b61068481610672565b811461068e575f80fd5b50565b5f8135905061069f8161067b565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6106f3826106ad565b810181811067ffffffffffffffff82111715610712576107116106bd565b5b80604052505050565b5f610724610661565b905061073082826106ea565b919050565b5f67ffffffffffffffff82111561074f5761074e6106bd565b5b610758826106ad565b9050602081019050919050565b828183375f83830152505050565b5f61078561078084610735565b61071b565b9050828152602081018484840111156107a1576107a06106a9565b5b6107ac848285610765565b509392505050565b5f82601f8301126107c8576107c76106a5565b5b81356107d8848260208601610773565b91505092915050565b5f80fd5b5f61022082840312156107fb576107fa6107e1565b5b81905092915050565b5f805f806080858703121561081c5761081b61066a565b5b5f61082987828801610691565b945050602061083a87828801610691565b935050604085013567ffffffffffffffff81111561085b5761085a61066e565b5b610867878288016107b4565b925050606085013567ffffffffffffffff8111156108885761088761066e565b5b610894878288016107e5565b91505092959194509250565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6108d4816108a0565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156109115780820151818401526020810190506108f6565b5f8484015250505050565b5f610926826108da565b61093081856108e4565b93506109408185602086016108f4565b610949816106ad565b840191505092915050565b5f6040820190506109675f8301856108cb565b8181036020830152610979818461091c565b90509392505050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6109ab82610982565b9050919050565b6109bb816109a1565b82525050565b5f6020820190506109d45f8301846109b2565b92915050565b5f80fd5b5f80fd5b5f8083601f8401126109f7576109f66106a5565b5b8235905067ffffffffffffffff811115610a1457610a136109da565b5b602083019150836001820283011115610a3057610a2f6109de565b5b9250929050565b60028110610a43575f80fd5b50565b5f81359050610a5481610a37565b92915050565b5f819050919050565b610a6c81610a5a565b8114610a76575f80fd5b50565b5f81359050610a8781610a63565b92915050565b5f805f805f805f60c0888a031215610aa857610aa761066a565b5b5f88013567ffffffffffffffff811115610ac557610ac461066e565b5b610ad18a828b016109e2565b9750975050602088013567ffffffffffffffff811115610af457610af361066e565b5b610b008a828b016107e5565b9550506040610b118a828b01610691565b9450506060610b228a828b01610691565b9350506080610b338a828b01610a46565b92505060a0610b448a828b01610a79565b91505092959891949750929550565b5f82825260208201905092915050565b7f5061796d61737465723a20556e617574686f72697a6564207369676e617475725f8201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b5f610bbd602183610b53565b9150610bc882610b63565b604082019050919050565b5f6020820190508181035f830152610bea81610bb1565b9050919050565b610bfa81610672565b82525050565b5f604082019050610c135f830185610bf1565b610c206020830184610bf1565b9392505050565b5f81905092915050565b7f19010000000000000000000000000000000000000000000000000000000000005f82015250565b5f610c65600283610c27565b9150610c7082610c31565b600282019050919050565b5f819050919050565b610c95610c9082610672565b610c7b565b82525050565b5f610ca582610c59565b9150610cb18285610c84565b602082019150610cc18284610c84565b6020820191508190509392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b610d0781610a5a565b82525050565b5f602082019050610d205f830184610cfe565b92915050565b5f602082019050610d395f830184610bf1565b92915050565b5f60ff82169050919050565b610d5481610d3f565b82525050565b5f608082019050610d6d5f830187610bf1565b610d7a6020830186610d4b565b610d876040830185610bf1565b610d946060830184610bf1565b95945050505050565b5f60a082019050610db05f830188610bf1565b610dbd6020830187610bf1565b610dca6040830186610bf1565b610dd76060830185610cfe565b610de460808301846109b2565b969550505050505056fea2646970667358221220072ef40a10e6cee80466e8db32779bb3e99e9138e59300d541cb378055838be664736f6c63430008140033 \ No newline at end of file diff --git a/contracts/libraries/ECDSA.sol b/contracts/libraries/ECDSA.sol index 93f7380..c70a38e 100644 --- a/contracts/libraries/ECDSA.sol +++ b/contracts/libraries/ECDSA.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT +// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) -pragma solidity >=0.6.2; +pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. @@ -94,7 +95,7 @@ library ECDSA { /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * - * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] + * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { @@ -170,24 +171,4 @@ library ECDSA { revert ECDSAInvalidSignatureS(errorArg); } } - - /** - * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). - * - * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with - * `\x19\x01` and hashing the result. It corresponds to the hash signed by the - * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. - * - * See {ECDSA-recover}. - */ - function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { - /// @solidity memory-safe-assembly - assembly { - let ptr := mload(0x40) - mstore(ptr, hex"19_01") - mstore(add(ptr, 0x02), domainSeparator) - mstore(add(ptr, 0x22), structHash) - digest := keccak256(ptr, 0x42) - } - } } \ No newline at end of file