Skip to content
Permalink
Browse files

signs message before getting

  • Loading branch information...
kendricktan committed Jul 23, 2019
1 parent 4166e54 commit dad44cdd4bab349170b4fcf1759630975453dbcd
Showing with 27 additions and 15 deletions.
  1. +2 −2 README.md
  2. +1 −0 src/components/DepositPage.js
  3. +24 −13 src/components/WithdrawPage.js
@@ -10,9 +10,9 @@

Heiswap (黑 swap) is an Ethereum transaction mixer that ultilizes parts of [CryptoNote](https://cryptonote.org) to enable zero-knowledge transactions.

It ulitilizes Ring Signatures and pseudo-stealth addresses to achieve its zero-knowledge properties. The [deployed smart contract](https://ropsten.etherscan.io/address/0xbbbf35a4485992520557ae729e21ba35aab178d7) handles the signature verification, while the client is responsible for generating the pseudo-stealth address.
It ulitilizes Ring Signatures and pseudo-stealth addresses to achieve its zero-knowledge properties. The [deployed smart contract](https://ropsten.etherscan.io/address/0x8AAbE42EeCA45E040fab330fD24eA6746b832Ad2) handles the signature verification, while the client is responsible for generating the pseudo-stealth address.

Ring signatures was only possible on the EVM (gas-wise) due to the recent addition of [EIP198](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-198.md).
Ring signatures was only possible on the EVM (gas-wise) due to the recent addition of [EIP198](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-198.md) and [EIP1895](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1895.md).

[You can play with the Ropsten version right now](https://heiswap.exchange/).

@@ -169,6 +169,7 @@ const DepositPage = (props: { dappGateway: DappGateway, noWeb3: Boolean, noContr
<Form.Field label='ETH amount' width={1}>
<Select
items={[
'1',
'2',
'4',
'8',
@@ -306,14 +306,38 @@ const WithdrawPage = (props: { dappGateway: DappGateway, noWeb3: Boolean, noCont
s
).encodeABI()

const gas = await web3.eth.estimateGas({
to: heiswapInstance._address,
data: dataBytecode
})

const tx = {
from: ethAddress,
to: heiswapInstance._address,
gas,
data: dataBytecode,
nonce: await web3.eth.getTransactionCount(ethAddress)
}

// Just send the dataBytecode to a relayer
// TFW can't signTransaction with web3.eth.signTransaction
// web3 is so broken, the versioning is so fucked,
// the docs are so outdated. Fucking hell.
if (useRelayer) {
const relayerURL = useDefaultRelayer ? 'https://relayer.heiswap.exchange' : customerRelayerURL
try {
// Nicer user flow for withdrawal (has prompts to sign message even through relayer)
// Also safer since relayer knows address authorized it
const message = `Get ETH from Heiswap via Relayer (Destination: ${dappGateway.ethAddress})`

const signedMessage = await web3.eth.personal.sign(
message,
dappGateway.ethAddress
)

const resp = await axios.post(relayerURL, {
message,
signedMessage,
receiver: ethAddress,
ethAmount,
ringIdx,
@@ -347,19 +371,6 @@ const WithdrawPage = (props: { dappGateway: DappGateway, noWeb3: Boolean, noCont
} else {
// Broadcast the transaction otherwise
try {
const gas = await web3.eth.estimateGas({
to: heiswapInstance._address,
data: dataBytecode
})

const tx = {
from: ethAddress,
to: heiswapInstance._address,
gas,
data: dataBytecode,
nonce: await web3.eth.getTransactionCount(ethAddress)
}

const txR = await web3.eth.sendTransaction(tx)

setTxReceipt(txR)

0 comments on commit dad44cd

Please sign in to comment.
You can’t perform that action at this time.