aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-08-25 04:11:17 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-08-25 05:40:00 +0800
commit1932aff35c6b07093534cde66dec63c5f919fcf0 (patch)
treefa886f0d47c46ddf27b85d920a6f719ba26256ba /packages
parent4f27991959ba6e4e15839e6195a40b0fd8a2122c (diff)
downloaddexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar.gz
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar.bz2
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar.lz
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar.xz
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.tar.zst
dexon-sol-tools-1932aff35c6b07093534cde66dec63c5f919fcf0.zip
Remove Trezor SignatureType
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol28
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol3
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts47
-rw-r--r--packages/order-utils/CHANGELOG.json9
-rw-r--r--packages/order-utils/src/signature_utils.ts12
-rw-r--r--packages/order-utils/test/signature_utils_test.ts14
-rw-r--r--packages/types/CHANGELOG.json4
-rw-r--r--packages/types/src/index.ts1
8 files changed, 15 insertions, 103 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
index 401fdd377..f30adcdb8 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
@@ -211,34 +211,6 @@ contract MixinSignatureValidator is
} else if (signatureType == SignatureType.PreSigned) {
isValid = preSigned[hash][signerAddress];
return isValid;
-
- // Signature from Trezor hardware wallet.
- // It differs from web3.eth_sign in the encoding of message length
- // (Bitcoin varint encoding vs ascii-decimal, the latter is not
- // self-terminating which leads to ambiguities).
- // See also:
- // https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
- // https://github.com/trezor/trezor-mcu/blob/master/firmware/ethereum.c#L602
- // https://github.com/trezor/trezor-mcu/blob/master/firmware/crypto.c#L36
- } else if (signatureType == SignatureType.Trezor) {
- require(
- signature.length == 65,
- "LENGTH_65_REQUIRED"
- );
- v = uint8(signature[0]);
- r = signature.readBytes32(1);
- s = signature.readBytes32(33);
- recovered = ecrecover(
- keccak256(abi.encodePacked(
- "\x19Ethereum Signed Message:\n\x20",
- hash
- )),
- v,
- r,
- s
- );
- isValid = signerAddress == recovered;
- return isValid;
}
// Anything else is illegal (We do not return false because
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
index b00c5e8da..1fe88b908 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
@@ -39,8 +39,7 @@ contract MSignatureValidator is
Wallet, // 0x04
Validator, // 0x05
PreSigned, // 0x06
- Trezor, // 0x07
- NSignatureTypes // 0x08, number of signature types. Always leave at end.
+ NSignatureTypes // 0x07, number of signature types. Always leave at end.
}
/// @dev Verifies signature using logic defined by Wallet contract.
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index ac07b0636..9113e5248 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -414,53 +414,6 @@ describe('MixinSignatureValidator', () => {
expect(isValidSignature).to.be.false();
});
- it('should return true when SignatureType=Trezor and signature is valid', async () => {
- // Create Trezor signature
- const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- const orderHashWithTrezorPrefixHex = signatureUtils.addSignedMessagePrefix(orderHashHex, SignerType.Trezor);
- const orderHashWithTrezorPrefixBuffer = ethUtil.toBuffer(orderHashWithTrezorPrefixHex);
- const ecSignature = ethUtil.ecsign(orderHashWithTrezorPrefixBuffer, signerPrivateKey);
- // Create 0x signature from Trezor signature
- const signature = Buffer.concat([
- ethUtil.toBuffer(ecSignature.v),
- ecSignature.r,
- ecSignature.s,
- ethUtil.toBuffer(`0x${SignatureType.Trezor}`),
- ]);
- const signatureHex = ethUtil.bufferToHex(signature);
- // Validate signature
- const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
- orderHashHex,
- signerAddress,
- signatureHex,
- );
- expect(isValidSignature).to.be.true();
- });
-
- it('should return false when SignatureType=Trezor and signature is invalid', async () => {
- // Create Trezor signature
- const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- const orderHashWithTrezorPrefixHex = signatureUtils.addSignedMessagePrefix(orderHashHex, SignerType.Trezor);
- const orderHashWithTrezorPrefixBuffer = ethUtil.toBuffer(orderHashWithTrezorPrefixHex);
- const ecSignature = ethUtil.ecsign(orderHashWithTrezorPrefixBuffer, signerPrivateKey);
- // Create 0x signature from Trezor signature
- const signature = Buffer.concat([
- ethUtil.toBuffer(ecSignature.v),
- ecSignature.r,
- ecSignature.s,
- ethUtil.toBuffer(`0x${SignatureType.Trezor}`),
- ]);
- const signatureHex = ethUtil.bufferToHex(signature);
- // Validate signature.
- // This will fail because `signerAddress` signed the message, but we're passing in `notSignerAddress`
- const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
- orderHashHex,
- notSignerAddress,
- signatureHex,
- );
- expect(isValidSignature).to.be.false();
- });
-
it('should return true when SignatureType=Presigned and signer has presigned hash', async () => {
// Presign hash
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index 81782b501..d18bf51ed 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "1.0.1-rc.5",
+ "changes": [
+ {
+ "note": "Remove Caller and Trezor SignatureTypes",
+ "pr": 1015
+ }
+ ]
+ },
+ {
"version": "1.0.1-rc.4",
"changes": [
{
diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts
index f8ed9cf9c..23577efdc 100644
--- a/packages/order-utils/src/signature_utils.ts
+++ b/packages/order-utils/src/signature_utils.ts
@@ -77,12 +77,6 @@ export const signatureUtils = {
return signatureUtils.isValidPresignedSignatureAsync(provider, data, signerAddress);
}
- case SignatureType.Trezor: {
- const prefixedMessageHex = signatureUtils.addSignedMessagePrefix(data, SignerType.Trezor);
- const ecSignature = signatureUtils.parseECSignature(signature);
- return signatureUtils.isValidECSignature(prefixedMessageHex, ecSignature, signerAddress);
- }
-
default:
throw new Error(`Unhandled SignatureType: ${signatureTypeIndexIfExists}`);
}
@@ -288,10 +282,6 @@ export const signatureUtils = {
signatureType = SignatureType.EthSign;
break;
}
- case SignerType.Trezor: {
- signatureType = SignatureType.Trezor;
- break;
- }
default:
throw new Error(`Unrecognized SignerType: ${signerType}`);
}
@@ -345,7 +335,7 @@ export const signatureUtils = {
*/
parseECSignature(signature: string): ECSignature {
assert.isHexString('signature', signature);
- const ecSignatureTypes = [SignatureType.EthSign, SignatureType.EIP712, SignatureType.Trezor];
+ const ecSignatureTypes = [SignatureType.EthSign, SignatureType.EIP712];
assert.isOneOfExpectedSignatureTypes(signature, ecSignatureTypes);
// tslint:disable-next-line:custom-no-magic-numbers
diff --git a/packages/order-utils/test/signature_utils_test.ts b/packages/order-utils/test/signature_utils_test.ts
index 4ce99a1c7..0e7831b41 100644
--- a/packages/order-utils/test/signature_utils_test.ts
+++ b/packages/order-utils/test/signature_utils_test.ts
@@ -76,20 +76,6 @@ describe('Signature utils', () => {
);
expect(isValidSignatureLocal).to.be.true();
});
-
- it('should return true for a valid Trezor signature', async () => {
- dataHex = '0xd0d994e31c88f33fd8a572552a70ed339de579e5ba49ee1d17cc978bbe1cdd21';
- address = '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb';
- const trezorSignature =
- '0x1ce4760660e6495b5ae6723087bea073b3a99ce98ea81fdf00c240279c010e63d05b87bc34c4d67d4776e8d5aeb023a67484f4eaf0fd353b40893e5101e845cd9908';
- const isValidSignatureLocal = await signatureUtils.isValidSignatureAsync(
- provider,
- dataHex,
- trezorSignature,
- address,
- );
- expect(isValidSignatureLocal).to.be.true();
- });
});
describe('#isValidECSignature', () => {
const signature = {
diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json
index 980a12ad3..1210168d4 100644
--- a/packages/types/CHANGELOG.json
+++ b/packages/types/CHANGELOG.json
@@ -5,6 +5,10 @@
{
"note": "Add WalletError and ValidatorError revert reasons",
"pr": 1012
+ },
+ {
+ "note": "Remove Caller and Trezor SignatureTypes",
+ "pr": 1015
}
]
},
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index beedc24a3..5261ddfe2 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -136,7 +136,6 @@ export enum SignatureType {
Wallet,
Validator,
PreSigned,
- Trezor,
NSignatureTypes,
}