Skip to content

Commit

Permalink
fix: use legacy sign and close kleros/gtcr#32
Browse files Browse the repository at this point in the history
  • Loading branch information
eccentricexit committed May 27, 2020
1 parent b18d9d2 commit f0881f3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"eth-sig-util": "^2.5.2",
"ethereumjs-util": "^7.0.2",
"ethers": "^4.0.40",
"express": "^4.17.1",
"json-schema": "^0.2.5",
Expand Down
6 changes: 4 additions & 2 deletions routes/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const express = require('express')
const ethers = require('ethers')
const cors = require('cors')
const { recoverTypedSignature } = require('eth-sig-util')
const { bufferToHex } = require('ethereumjs-util')
const { recoverPersonalSignature } = require('eth-sig-util')
const {
abi: _GTCR
} = require('@kleros/tcr/build/contracts/GeneralizedTCR.json')
Expand Down Expand Up @@ -165,8 +166,9 @@ const buildRouter = (
} = data

// Recover checksummed address.
const hexMsg = bufferToHex(Buffer.from(JSON.stringify(data), 'utf8'))
const subscriberAddr = ethers.utils.getAddress(
recoverTypedSignature({ data, sig: signature })
recoverPersonalSignature({ data: hexMsg, sig: signature })
)

let emailSettings = {}
Expand Down
60 changes: 56 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,13 @@ bignumber.js@^7.2.1:
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f"
integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==

"bignumber.js@git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2":
"bignumber.js@git+https://github.com/debris/bignumber.js#master":
version "2.0.7"
resolved "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2"
resolved "git+https://github.com/debris/bignumber.js#c7a38de919ed75e6fb6ba38051986e294b328df9"

"bignumber.js@git+https://github.com/debris/bignumber.js.git#master":
"bignumber.js@git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2":
version "2.0.7"
resolved "git+https://github.com/debris/bignumber.js.git#c7a38de919ed75e6fb6ba38051986e294b328df9"
resolved "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2"

binary-extensions@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -921,6 +921,11 @@ bn.js@^5.1.1:
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.1.tgz#48efc4031a9c4041b9c99c6941d903463ab62eb5"
integrity sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA==

bn.js@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.2.tgz#c9686902d3c9a27729f43ab10f9d79c2004da7b0"
integrity sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA==

[email protected], body-parser@^1.16.0, body-parser@^1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
Expand Down Expand Up @@ -2631,6 +2636,19 @@ ethereumjs-util@^6.0.0:
rlp "^2.2.3"
secp256k1 "^3.0.1"

ethereumjs-util@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.2.tgz#7e0d9fcd225ece6e49ee4ea65609d124715f1d15"
integrity sha512-ATAP02eJLpAlWGfiKQddNrRfZpwXiTFhRN2EM/yLXMCdBW/xjKYblNKcx8GLzzrjXg0ymotck+lam1nuV90arQ==
dependencies:
"@types/bn.js" "^4.11.3"
bn.js "^5.1.2"
create-hash "^1.1.2"
ethjs-util "0.1.6"
keccak "^3.0.0"
rlp "^2.2.4"
secp256k1 "^4.0.1"

ethereumjs-vm@^2.0.2:
version "2.6.0"
resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz#76243ed8de031b408793ac33907fb3407fe400c6"
Expand Down Expand Up @@ -4112,6 +4130,14 @@ keccak@^2.0.0:
nan "^2.14.0"
safe-buffer "^5.2.0"

keccak@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.0.tgz#420d1de4a38a04f33ff8401f0535fb93756861d4"
integrity sha512-/4h4FIfFEpTEuySXi/nVFM5rqSKPnnhI7cL4K3MFSwoI3VyM7AhPSq3SsysARtnEBEeIKMBUWD8cTh9nHE8AkA==
dependencies:
node-addon-api "^2.0.0"
node-gyp-build "^4.2.0"

keccakjs@^0.2.0:
version "0.2.3"
resolved "https://registry.yarnpkg.com/keccakjs/-/keccakjs-0.2.3.tgz#5e4e969ce39689a3861f445d7752ee3477f9fe72"
Expand Down Expand Up @@ -4857,6 +4883,11 @@ nice-try@^1.0.4:
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==

node-addon-api@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.0.tgz#f9afb8d777a91525244b01775ea0ddbe1125483b"
integrity sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA==

node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
Expand All @@ -4870,6 +4901,11 @@ node-forge@^0.9.1:
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.1.tgz#775368e6846558ab6676858a4d8c6e8d16c677b5"
integrity sha512-G6RlQt5Sb4GMBzXvhfkeFmbqR6MzhtnT7VTHuLadjkii3rdYHNdw0m8zA4BTxVIh68FicCQ2NSUANpsqkr9jvQ==

node-gyp-build@^4.2.0:
version "4.2.2"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.2.tgz#3f44b65adaafd42fb6c3d81afd630e45c847eb66"
integrity sha512-Lqh7mrByWCM8Cf9UPqpeoVBBo5Ugx+RKu885GAzmLBVYjeywScxHXPGLa4JfYNZmcNGwzR0Glu5/9GaQZMFqyA==

node-gyp-build@~4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.1.1.tgz#d7270b5d86717068d114cc57fff352f96d745feb"
Expand Down Expand Up @@ -5990,6 +6026,13 @@ rlp@^2.0.0, rlp@^2.2.3:
dependencies:
bn.js "^4.11.1"

rlp@^2.2.4:
version "2.2.5"
resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.5.tgz#b0577b763e909f21a9dea31b4b235b2393f15ef1"
integrity sha512-y1QxTQOp0OZnjn19FxBmped4p+BSKPHwGndaqrESseyd2xXZtcgR3yuTIosh8CaMaOii9SKIYerBXnV/CpJ3qw==
dependencies:
bn.js "^4.11.1"

run-async@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
Expand Down Expand Up @@ -6100,6 +6143,15 @@ secp256k1@^3.0.1:
nan "^2.14.0"
safe-buffer "^5.1.2"

secp256k1@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.1.tgz#b9570ca26ace9e74c3171512bba253da9c0b6d60"
integrity sha512-iGRjbGAKfXMqhtdkkuNxsgJQfJO8Oo78Rm7DAvsG3XKngq+nJIOGqrCSXcQqIVsmCj0wFanE5uTKFxV3T9j2wg==
dependencies:
elliptic "^6.5.2"
node-addon-api "^2.0.0"
node-gyp-build "^4.2.0"

secretlint@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/secretlint/-/secretlint-2.0.0.tgz#27a4b45150c193f95a8a55f9e0d63fc5c9a3f5d2"
Expand Down

0 comments on commit f0881f3

Please sign in to comment.