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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.5.6;

contract ERC1271 {
contract ERC1654 {

/// @dev bytes4(keccak256("isValidSignature(bytes32,bytes)")
bytes4 internal constant ERC1271_VALIDSIGNATURE = 0x1626ba7e;
bytes4 internal constant ERC1654_VALIDSIGNATURE = 0x1626ba7e;

/// @dev Should return whether the signature provided is valid for the provided data
/// @param hash 32-byte hash of the data that is signed
Expand Down
2 changes: 1 addition & 1 deletion contracts/Test/Selector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract Selector {
return w.invoke2.selector;
}

// ERC1271
// ERC1654
function isValidSignatureSelector() public pure returns (bytes4) {
FullWallet w;
return w.isValidSignature.selector;
Expand Down
10 changes: 5 additions & 5 deletions contracts/Wallet/CoreWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.5.6;

import "../ERC721/ERC721Receivable.sol";
import "../ERC223/ERC223Receiver.sol";
import "../ERC1271/ERC1271.sol";
import "../ERC1654/ERC1654.sol";
import "../ECDSA.sol";


Expand All @@ -20,7 +20,7 @@ import "../ECDSA.sol";
/// implemented here) is negligible even if you don't need the cosigner functionality, and
/// (B) two-of-two multisig (as implemented here) handles a lot of really common use cases, most
/// notably third-party gas payment and off-chain blacklisting and fraud detection.
contract CoreWallet is ERC721Receivable, ERC223Receiver, ERC1271 {
contract CoreWallet is ERC721Receivable, ERC223Receiver, ERC1654 {

using ECDSA for bytes;

Expand Down Expand Up @@ -276,7 +276,7 @@ contract CoreWallet is ERC721Receivable, ERC223Receiver, ERC1271 {
}

/// @notice Should return whether the signature provided is valid for the provided data
/// See https://github.com/ethereum/EIPs/issues/1271
/// See https://github.com/ethereum/EIPs/issues/1654
/// @dev This function meets the following conditions as per the EIP:
/// MUST return the bytes4 magic value `0x1626ba7e` when function passes.
/// MUST NOT modify state (using `STATICCALL` for solc < 0.5, `view` modifier for solc > 0.5)
Expand Down Expand Up @@ -335,7 +335,7 @@ contract CoreWallet is ERC721Receivable, ERC223Receiver, ERC1271 {
return 0;
}

return ERC1271_VALIDSIGNATURE;
return ERC1654_VALIDSIGNATURE;
}

/// @notice Query if a contract implements an interface
Expand All @@ -351,7 +351,7 @@ contract CoreWallet is ERC721Receivable, ERC223Receiver, ERC1271 {
interfaceID == ERC721_RECEIVED_FINAL || // ERC721 Final
interfaceID == ERC721_RECEIVED_DRAFT || // ERC721 Draft
interfaceID == ERC223_ID || // ERC223
interfaceID == ERC1271_VALIDSIGNATURE; // ERC1271
interfaceID == ERC1654_VALIDSIGNATURE; // ERC1654
}

/// @notice A version of `invoke()` that has no explicit signatures, and uses msg.sender
Expand Down
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const funcHash = signature => {
* @param {string} walletAddr address of wallet
* @param {Buffer} hash hashed data
*/
const getSha3ForERC1271 = (walletAddr, hash) => {
const getSha3ForERC1654 = (walletAddr, hash) => {
return abi.soliditySHA3(
['int8', 'int8', 'address', 'bytes32'],
[0x19, 0x0, new BN(walletAddr.replace('0x', ''), 16), hash]
Expand Down Expand Up @@ -199,7 +199,7 @@ module.exports = {
waitForEvents,
expectThrow,
getSha3ForConfirmationTx,
getSha3ForERC1271,
getSha3ForERC1654,
//getSha3ForConfirmationTxCallData,
serializeSignature,
serializeSignatures,
Expand Down
40 changes: 20 additions & 20 deletions test/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
}
});

describe('concerning ERC1271 compatibility', function () {
describe('concerning ERC1654 compatibility', function () {
const data = "hello world";
const ERC1271_VS = "0x1626ba7e";
const ERC1654_VS = "0x1626ba7e";

it('should be able to validate a signature', async function () {
// prepare a signature from the signer and the cosigner
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -234,12 +234,12 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
// call contract
const result = await wallet.isValidSignature('0x' + dataHash.toString('hex'), combined);
// check result
result.should.eql(ERC1271_VS);
result.should.eql(ERC1654_VS);
});

it('should return 0 if provided an invalid signature', async function () {
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -257,7 +257,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
it('should return 0 if provided an invalid signature length', async function () {

const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -273,7 +273,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress

it('should return 0 if only given 1 signature', async function () {
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -287,7 +287,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
it('should return 0 if given signature from a key that is not the cosigner', async function () {

const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -304,7 +304,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
it('should return 0 if given signature from a key that is not an authorized key', async function () {

const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand Down Expand Up @@ -3561,14 +3561,14 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
}
});

describe('concerning ERC1271 compatibility', function () {
describe('concerning ERC1654 compatibility', function () {
const data = "hello worlds";
const ERC1271_VS = "0x1626ba7e";
const ERC1654_VS = "0x1626ba7e";

it('should be able to validate a signature', async function () {
// prepare a signature from the signer and the cosigner
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -3578,13 +3578,13 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
// call contract
const result = await wallet.isValidSignature('0x' + dataHash.toString('hex'), combined);
// check result
result.should.eql(ERC1271_VS);
result.should.eql(ERC1654_VS);
});

it('should be able to validate a signature with two signatures', async function () {
// prepare a signature from the signer and the cosigner
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -3596,12 +3596,12 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress
// call contract
const result = await wallet.isValidSignature('0x' + dataHash.toString('hex'), combined);
// check result
result.should.eql(ERC1271_VS);
result.should.eql(ERC1654_VS);
});

it('should return 0 if provided an invalid signature', async function () {
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -3615,7 +3615,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress

it('should return 0 if provided an invalid signature length', async function () {
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand All @@ -3630,7 +3630,7 @@ const testSuite = async function (wtype, accounts, _walletFactory, _cloneAddress

it('should return 0 if given signature from a key that is not an authorized key', async function () {
const dataHash = abi.soliditySHA3(['string'], [data]);
const hashToSign = utils.getSha3ForERC1271(
const hashToSign = utils.getSha3ForERC1654(
wallet.address,
dataHash
);
Expand Down Expand Up @@ -4851,8 +4851,8 @@ contract('Wallet', async (accounts) => {
const ERC721_RECEIVED_DRAFT = "0xf0b9e5ba";
const ERC223_ID = "0xc0ee0b8a";
const ERC165_ID = "0x01ffc9a7"
const ERC1271_VS = "0x1626ba7e";
addrs = [ERC721_RECEIVED_FINAL, ERC721_RECEIVED_DRAFT, ERC223_ID, ERC165_ID, ERC1271_VS];
const ERC1654_VS = "0x1626ba7e";
addrs = [ERC721_RECEIVED_FINAL, ERC721_RECEIVED_DRAFT, ERC223_ID, ERC165_ID, ERC1654_VS];
});

it('should return true for the interfaces it implements', async function () {
Expand Down