@keep-network/tbtc-v2 0.1.1-dev.59 → 0.1.1-dev.61

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.
Files changed (66) hide show
  1. package/artifacts/Bank.json +6 -6
  2. package/artifacts/Bridge.json +54 -54
  3. package/artifacts/Deposit.json +7 -7
  4. package/artifacts/DepositSweep.json +9 -9
  5. package/artifacts/EcdsaDkgValidator.json +1 -1
  6. package/artifacts/EcdsaInactivity.json +1 -1
  7. package/artifacts/Fraud.json +9 -9
  8. package/artifacts/KeepRegistry.json +1 -1
  9. package/artifacts/KeepStake.json +2 -2
  10. package/artifacts/KeepToken.json +2 -2
  11. package/artifacts/KeepTokenStaking.json +1 -1
  12. package/artifacts/MovingFunds.json +7 -7
  13. package/artifacts/NuCypherStakingEscrow.json +1 -1
  14. package/artifacts/NuCypherToken.json +2 -2
  15. package/artifacts/RandomBeaconStub.json +1 -1
  16. package/artifacts/Redemption.json +7 -7
  17. package/artifacts/ReimbursementPool.json +2 -2
  18. package/artifacts/Relay.json +11 -11
  19. package/artifacts/SortitionPool.json +2 -2
  20. package/artifacts/T.json +2 -2
  21. package/artifacts/TBTC.json +6 -6
  22. package/artifacts/TBTCToken.json +6 -6
  23. package/artifacts/TokenStaking.json +1 -1
  24. package/artifacts/TokenholderGovernor.json +9 -9
  25. package/artifacts/TokenholderTimelock.json +8 -8
  26. package/artifacts/VendingMachine.json +13 -13
  27. package/artifacts/VendingMachineKeep.json +1 -1
  28. package/artifacts/VendingMachineNuCypher.json +1 -1
  29. package/artifacts/WalletRegistry.json +2 -2
  30. package/artifacts/WalletRegistryGovernance.json +2 -2
  31. package/artifacts/Wallets.json +7 -7
  32. package/artifacts/solcInputs/{c86d08e5f2ce89fcf398a4658c796260.json → 6ff443beb223cf0c26c6b81361aa1799.json} +9 -3
  33. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  34. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  35. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  36. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  37. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  38. package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
  39. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  40. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
  41. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  42. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  43. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  44. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
  45. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  46. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  47. package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
  48. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +4 -0
  49. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +10 -0
  50. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  51. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  52. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
  53. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  54. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  55. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  56. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  57. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  58. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  59. package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
  60. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  61. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  62. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  63. package/contracts/bridge/BitcoinTx.sol +18 -3
  64. package/contracts/bridge/DepositSweep.sol +9 -21
  65. package/contracts/bridge/Heartbeat.sol +107 -0
  66. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // ██████████████ ▐████▌ ██████████████
4
+ // ██████████████ ▐████▌ ██████████████
5
+ // ▐████▌ ▐████▌
6
+ // ▐████▌ ▐████▌
7
+ // ██████████████ ▐████▌ ██████████████
8
+ // ██████████████ ▐████▌ ██████████████
9
+ // ▐████▌ ▐████▌
10
+ // ▐████▌ ▐████▌
11
+ // ▐████▌ ▐████▌
12
+ // ▐████▌ ▐████▌
13
+ // ▐████▌ ▐████▌
14
+ // ▐████▌ ▐████▌
15
+
16
+ pragma solidity ^0.8.9;
17
+
18
+ import {BytesLib} from "@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol";
19
+
20
+ /// @title Bridge wallet heartbeat
21
+ /// @notice The library establishes expected format for heartbeat messages
22
+ /// signed by wallet ECDSA signing group. Heartbeat messages are
23
+ /// constructed in such a way that they can not be used as a Bitcoin
24
+ /// transaction preimages.
25
+ /// @dev The smallest Bitcoin non-coinbase transaction is a one spending an
26
+ /// OP_TRUE anyonecanspend output and creating 1 OP_TRUE anyonecanspend
27
+ /// output. Such a transaction has 61 bytes (see `BitcoinTx` documentation):
28
+ /// 4 bytes for version
29
+ /// 1 byte for tx_in_count
30
+ /// 36 bytes for tx_in.previous_output
31
+ /// 1 byte for tx_in.script_bytes (value: 0)
32
+ /// 0 bytes for tx_in.signature_script
33
+ /// 4 bytes for tx_in.sequence
34
+ /// 1 byte for tx_out_count
35
+ /// 8 bytes for tx_out.value
36
+ /// 1 byte for tx_out.pk_script_bytes
37
+ /// 1 byte for tx_out.pk_script
38
+ /// 4 bytes for lock_time
39
+ ///
40
+ ///
41
+ /// The smallest Bitcoin coinbase transaction is a one creating
42
+ /// 1 OP_TRUE anyonecanspend output and having an empty coinbase script.
43
+ /// Such a transaction has 65 bytes:
44
+ /// 4 bytes for version
45
+ /// 1 byte for tx_in_count
46
+ /// 32 bytes for tx_in.hash (all 0x00)
47
+ /// 4 bytes for tx_in.index (all 0xff)
48
+ /// 1 byte for tx_in.script_bytes (value: 0)
49
+ /// 4 bytes for tx_in.height
50
+ /// 0 byte for tx_in.coinbase_script
51
+ /// 4 bytes for tx_in.sequence
52
+ /// 1 byte for tx_out_count
53
+ /// 8 bytes for tx_out.value
54
+ /// 1 byte for tx_out.pk_script_bytes
55
+ /// 1 byte for tx_out.pk_script
56
+ /// 4 bytes for lock_time
57
+ ///
58
+ ///
59
+ /// A SIGHASH flag is used to indicate which part of the transaction is
60
+ /// signed by the ECDSA signature. There are currently 3 flags:
61
+ /// SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, and different combinations
62
+ /// of these flags.
63
+ ///
64
+ /// No matter the SIGHASH flag and no matter the combination, the following
65
+ /// fields from the transaction are always included in the constructed
66
+ /// preimage:
67
+ /// 4 bytes for version
68
+ /// 36 bytes for tx_in.previous_output (or tx_in.hash + tx_in.index for coinbase)
69
+ /// 4 bytes for lock_time
70
+ ///
71
+ /// Additionally, the last 4 bytes of the preimage determines the SIGHASH
72
+ /// flag.
73
+ ///
74
+ /// This is enough to say there is no way the preimage could be shorter
75
+ /// than 4 + 36 + 4 + 4 = 48 bytes.
76
+ ///
77
+ /// For this reason, we construct the heartbeat message, as a 16-byte
78
+ /// message. The first 8 bytes are 0xffffffffffffffff. The last 8 bytes
79
+ /// are for an arbitrary uint64, being a signed heartbeat nonce (for
80
+ /// example, the last Ethereum block hash).
81
+ library Heartbeat {
82
+ using BytesLib for bytes;
83
+
84
+ /// @notice Determines if the signed byte array is a valid, non-fraudulent
85
+ /// heartbeat message.
86
+ /// @param message Message signed by the wallet. It is a potential heartbeat
87
+ /// message, Bitcoin transaction preimage, or an arbitrary signed
88
+ /// bytes
89
+ /// @dev Wallet heartbeat message must be exactly 16 bytes long with the first
90
+ /// 8 bytes set to 0xffffffffffffffff.
91
+ /// @return True if valid heartbeat message, false otherwise.
92
+ function isValidHeartbeatMessage(bytes calldata message)
93
+ internal
94
+ pure
95
+ returns (bool)
96
+ {
97
+ if (message.length != 16) {
98
+ return false;
99
+ }
100
+
101
+ if (message.slice8(0) != 0xffffffffffffffff) {
102
+ return false;
103
+ }
104
+
105
+ return true;
106
+ }
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keep-network/tbtc-v2",
3
- "version": "0.1.1-dev.59+main.f223721a9ebc7317055f3d55e79c2a520d5f8efd",
3
+ "version": "0.1.1-dev.61+main.7a1cd6ba871d67f537fa5b44cb36dbd2f29fb161",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "artifacts/",