@keep-network/tbtc-v2 0.1.1-dev.69 → 0.1.1-dev.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/Bank.json +3 -3
- package/artifacts/Bridge.json +5 -5
- package/artifacts/DefaultProxyAdmin.json +2 -2
- package/artifacts/Deposit.json +7 -7
- package/artifacts/DepositSweep.json +9 -9
- package/artifacts/EcdsaDkgValidator.json +2 -2
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/Fraud.json +18 -18
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/MovingFunds.json +7 -7
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +7 -7
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +9 -9
- package/artifacts/SortitionPool.json +3 -3
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +10 -10
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +6 -6
- package/artifacts/WalletRegistry_Implementation.json +1 -1
- package/artifacts/WalletRegistry_Proxy.json +6 -6
- package/artifacts/Wallets.json +9 -9
- package/artifacts/solcInputs/{eb507899925af50d85171e90b51ddf5f.json → 55619e5b15411ce6622d6da869c273a1.json} +6 -6
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +18 -18
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +98 -2
- package/contracts/bridge/Bridge.sol +23 -18
- package/contracts/bridge/Fraud.sol +32 -19
- package/contracts/vault/TBTCVault.sol +33 -1
- package/export.json +4 -4
- package/package.json +1 -1
|
@@ -893,12 +893,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
893
893
|
/// challenge or confiscated otherwise.
|
|
894
894
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
895
895
|
/// and unprefixed format (64 bytes)
|
|
896
|
-
/// @param
|
|
897
|
-
///
|
|
898
|
-
///
|
|
899
|
-
///
|
|
900
|
-
///
|
|
901
|
-
///
|
|
896
|
+
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
897
|
+
/// one time over the preimage used during input signing. The preimage
|
|
898
|
+
/// is a serialized subset of the transaction and its structure
|
|
899
|
+
/// depends on the transaction input (see BIP-143 for reference).
|
|
900
|
+
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
901
|
+
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
902
|
+
/// this:
|
|
903
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
902
904
|
/// @param signature Bitcoin signature in the R/S/V format
|
|
903
905
|
/// @dev Requirements:
|
|
904
906
|
/// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
|
|
@@ -907,13 +909,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
907
909
|
/// fraud challenge deposit
|
|
908
910
|
/// - The signature (represented by r, s and v) must be generated by
|
|
909
911
|
/// the wallet behind `walletPubKey` during signing of `sighash`
|
|
912
|
+
/// which was calculated from `preimageSha256`
|
|
910
913
|
/// - Wallet can be challenged for the given signature only once
|
|
911
914
|
function submitFraudChallenge(
|
|
912
915
|
bytes calldata walletPublicKey,
|
|
913
|
-
|
|
916
|
+
bytes memory preimageSha256,
|
|
914
917
|
BitcoinTx.RSVSignature calldata signature
|
|
915
918
|
) external payable {
|
|
916
|
-
self.submitFraudChallenge(walletPublicKey,
|
|
919
|
+
self.submitFraudChallenge(walletPublicKey, preimageSha256, signature);
|
|
917
920
|
}
|
|
918
921
|
|
|
919
922
|
/// @notice Allows to defeat a pending fraud challenge against a wallet if
|
|
@@ -997,17 +1000,19 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
997
1000
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
998
1001
|
/// and unprefixed format (64 bytes)
|
|
999
1002
|
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
1000
|
-
/// @param
|
|
1001
|
-
///
|
|
1002
|
-
///
|
|
1003
|
-
///
|
|
1004
|
-
///
|
|
1005
|
-
///
|
|
1003
|
+
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
1004
|
+
/// one time over the preimage used during input signing. The preimage
|
|
1005
|
+
/// is a serialized subset of the transaction and its structure
|
|
1006
|
+
/// depends on the transaction input (see BIP-143 for reference).
|
|
1007
|
+
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
1008
|
+
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
1009
|
+
/// this:
|
|
1010
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
1006
1011
|
/// @dev Requirements:
|
|
1007
1012
|
/// - The wallet must be in the Live or MovingFunds or Closing or
|
|
1008
1013
|
/// Terminated state
|
|
1009
|
-
/// - The `walletPublicKey` and `sighash`
|
|
1010
|
-
/// challenge
|
|
1014
|
+
/// - The `walletPublicKey` and `sighash` calculated from
|
|
1015
|
+
/// `preimageSha256` must identify an open fraud challenge
|
|
1011
1016
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
1012
1017
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
1013
1018
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
@@ -1019,12 +1024,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1019
1024
|
function notifyFraudChallengeDefeatTimeout(
|
|
1020
1025
|
bytes calldata walletPublicKey,
|
|
1021
1026
|
uint32[] calldata walletMembersIDs,
|
|
1022
|
-
|
|
1027
|
+
bytes memory preimageSha256
|
|
1023
1028
|
) external {
|
|
1024
1029
|
self.notifyFraudChallengeDefeatTimeout(
|
|
1025
1030
|
walletPublicKey,
|
|
1026
1031
|
walletMembersIDs,
|
|
1027
|
-
|
|
1032
|
+
preimageSha256
|
|
1028
1033
|
);
|
|
1029
1034
|
}
|
|
1030
1035
|
|
|
@@ -112,12 +112,14 @@ library Fraud {
|
|
|
112
112
|
/// challenge or confiscated otherwise
|
|
113
113
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
114
114
|
/// and unprefixed format (64 bytes)
|
|
115
|
-
/// @param
|
|
116
|
-
///
|
|
117
|
-
///
|
|
118
|
-
///
|
|
119
|
-
///
|
|
120
|
-
///
|
|
115
|
+
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
116
|
+
/// one time over the preimage used during input signing. The preimage
|
|
117
|
+
/// is a serialized subset of the transaction and its structure
|
|
118
|
+
/// depends on the transaction input (see BIP-143 for reference).
|
|
119
|
+
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
120
|
+
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
121
|
+
/// this:
|
|
122
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
121
123
|
/// @param signature Bitcoin signature in the R/S/V format
|
|
122
124
|
/// @dev Requirements:
|
|
123
125
|
/// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
|
|
@@ -125,12 +127,13 @@ library Fraud {
|
|
|
125
127
|
/// - The challenger must send appropriate amount of ETH used as
|
|
126
128
|
/// fraud challenge deposit
|
|
127
129
|
/// - The signature (represented by r, s and v) must be generated by
|
|
128
|
-
/// the wallet behind `
|
|
130
|
+
/// the wallet behind `walletPubKey` during signing of `sighash`
|
|
131
|
+
/// which was calculated from `preimageSha256`
|
|
129
132
|
/// - Wallet can be challenged for the given signature only once
|
|
130
133
|
function submitFraudChallenge(
|
|
131
134
|
BridgeState.Storage storage self,
|
|
132
135
|
bytes calldata walletPublicKey,
|
|
133
|
-
|
|
136
|
+
bytes memory preimageSha256,
|
|
134
137
|
BitcoinTx.RSVSignature calldata signature
|
|
135
138
|
) external {
|
|
136
139
|
require(
|
|
@@ -138,6 +141,12 @@ library Fraud {
|
|
|
138
141
|
"The amount of ETH deposited is too low"
|
|
139
142
|
);
|
|
140
143
|
|
|
144
|
+
// To prevent ECDSA signature forgery `sighash` must be calculated
|
|
145
|
+
// inside the function and not passed as a function parameter.
|
|
146
|
+
// Signature forgery could result in a wrongful fraud accusation
|
|
147
|
+
// against a wallet.
|
|
148
|
+
bytes32 sighash = sha256(preimageSha256);
|
|
149
|
+
|
|
141
150
|
require(
|
|
142
151
|
CheckBitcoinSigs.checkSig(
|
|
143
152
|
walletPublicKey,
|
|
@@ -338,8 +347,8 @@ library Fraud {
|
|
|
338
347
|
/// @notice Notifies about defeat timeout for the given fraud challenge.
|
|
339
348
|
/// Can be called only if there was a fraud challenge identified by
|
|
340
349
|
/// the provided `walletPublicKey` and `sighash` and it was not
|
|
341
|
-
/// defeated on time. The amount of time that needs to pass after
|
|
342
|
-
/// fraud challenge is reported is indicated by the
|
|
350
|
+
/// defeated on time. The amount of time that needs to pass after
|
|
351
|
+
/// a fraud challenge is reported is indicated by the
|
|
343
352
|
/// `challengeDefeatTimeout`. After a successful fraud challenge
|
|
344
353
|
/// defeat timeout notification the fraud challenge is marked as
|
|
345
354
|
/// resolved, the stake of each operator is slashed, the ether
|
|
@@ -348,17 +357,19 @@ library Fraud {
|
|
|
348
357
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
349
358
|
/// and unprefixed format (64 bytes)
|
|
350
359
|
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
351
|
-
/// @param
|
|
352
|
-
///
|
|
353
|
-
///
|
|
354
|
-
///
|
|
355
|
-
///
|
|
356
|
-
///
|
|
360
|
+
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
361
|
+
/// one time over the preimage used during input signing. The preimage
|
|
362
|
+
/// is a serialized subset of the transaction and its structure
|
|
363
|
+
/// depends on the transaction input (see BIP-143 for reference).
|
|
364
|
+
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
365
|
+
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
366
|
+
/// this:
|
|
367
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
357
368
|
/// @dev Requirements:
|
|
358
369
|
/// - The wallet must be in the Live or MovingFunds or Closing or
|
|
359
370
|
/// Terminated state
|
|
360
|
-
/// - The `walletPublicKey` and `sighash`
|
|
361
|
-
/// challenge
|
|
371
|
+
/// - The `walletPublicKey` and `sighash` calculated from
|
|
372
|
+
/// `preimageSha256` must identify an open fraud challenge
|
|
362
373
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
363
374
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
364
375
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
@@ -371,8 +382,10 @@ library Fraud {
|
|
|
371
382
|
BridgeState.Storage storage self,
|
|
372
383
|
bytes calldata walletPublicKey,
|
|
373
384
|
uint32[] calldata walletMembersIDs,
|
|
374
|
-
|
|
385
|
+
bytes memory preimageSha256
|
|
375
386
|
) external {
|
|
387
|
+
bytes32 sighash = sha256(preimageSha256);
|
|
388
|
+
|
|
376
389
|
uint256 challengeKey = uint256(
|
|
377
390
|
keccak256(abi.encodePacked(walletPublicKey, sighash))
|
|
378
391
|
);
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
pragma solidity ^0.8.9;
|
|
17
17
|
|
|
18
|
+
import "@keep-network/random-beacon/contracts/Governable.sol";
|
|
19
|
+
|
|
18
20
|
import "./IVault.sol";
|
|
19
21
|
import "../bank/Bank.sol";
|
|
20
22
|
import "../token/TBTC.sol";
|
|
@@ -27,7 +29,7 @@ import "../token/TBTC.sol";
|
|
|
27
29
|
/// Bank.
|
|
28
30
|
/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract
|
|
29
31
|
/// minting the token.
|
|
30
|
-
contract TBTCVault is IVault {
|
|
32
|
+
contract TBTCVault is IVault, Governable {
|
|
31
33
|
Bank public bank;
|
|
32
34
|
TBTC public tbtcToken;
|
|
33
35
|
|
|
@@ -53,6 +55,36 @@ contract TBTCVault is IVault {
|
|
|
53
55
|
|
|
54
56
|
bank = _bank;
|
|
55
57
|
tbtcToken = _tbtcToken;
|
|
58
|
+
|
|
59
|
+
_transferGovernance(msg.sender);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// @notice Allows the governance of the TBTCVault to recover any ERC20
|
|
63
|
+
/// token sent mistakenly to the TBTC token contract address.
|
|
64
|
+
/// @param token Address of the recovered ERC20 token contract
|
|
65
|
+
/// @param recipient Address the recovered token should be sent to
|
|
66
|
+
/// @param amount Recovered amount
|
|
67
|
+
function recoverERC20(
|
|
68
|
+
IERC20 token,
|
|
69
|
+
address recipient,
|
|
70
|
+
uint256 amount
|
|
71
|
+
) external onlyGovernance {
|
|
72
|
+
tbtcToken.recoverERC20(token, recipient, amount);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// @notice Allows the governance of the TBTCVault to recover any ERC721
|
|
76
|
+
/// token sent mistakenly to the TBTC token contract address.
|
|
77
|
+
/// @param token Address of the recovered ERC721 token contract
|
|
78
|
+
/// @param recipient Address the recovered token should be sent to
|
|
79
|
+
/// @param tokenId Identifier of the recovered token
|
|
80
|
+
/// @param data Additional data
|
|
81
|
+
function recoverERC721(
|
|
82
|
+
IERC721 token,
|
|
83
|
+
address recipient,
|
|
84
|
+
uint256 tokenId,
|
|
85
|
+
bytes calldata data
|
|
86
|
+
) external onlyGovernance {
|
|
87
|
+
tbtcToken.recoverERC721(token, recipient, tokenId, data);
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
/// @notice Transfers the given `amount` of the Bank balance from caller
|
package/export.json
CHANGED
|
@@ -15858,8 +15858,8 @@
|
|
|
15858
15858
|
"name": "walletMembersIDs"
|
|
15859
15859
|
},
|
|
15860
15860
|
{
|
|
15861
|
-
"type": "
|
|
15862
|
-
"name": "
|
|
15861
|
+
"type": "bytes",
|
|
15862
|
+
"name": "preimageSha256"
|
|
15863
15863
|
}
|
|
15864
15864
|
],
|
|
15865
15865
|
"outputs": []
|
|
@@ -16652,8 +16652,8 @@
|
|
|
16652
16652
|
"name": "walletPublicKey"
|
|
16653
16653
|
},
|
|
16654
16654
|
{
|
|
16655
|
-
"type": "
|
|
16656
|
-
"name": "
|
|
16655
|
+
"type": "bytes",
|
|
16656
|
+
"name": "preimageSha256"
|
|
16657
16657
|
},
|
|
16658
16658
|
{
|
|
16659
16659
|
"type": "tuple",
|