You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03-Protocol-Overview.md
+3-2
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,7 @@ The message framing is outlined below:
103
103
| msg_length | U24 | Length of the protocol message, not including this header |
104
104
| payload | BYTES | Message-specific payload of length msg_length. If the MSB in extension_type (the channel_msg bit) is set the first four bytes are defined as a U32 "channel_id", though this definition is repeated in the message definitions below and these 4 bytes are included in msg_length. |
105
105
106
+
106
107
## 3.3 Reconnecting Downstream Nodes
107
108
108
109
An upstream stratum node may occasionally request reconnection of its downstream peers to a different host (e.g. due to maintenance reasons, etc.).
@@ -162,7 +163,7 @@ Clients that are not configured to provide telemetry data to the upstream node S
162
163
However, they MUST always set vendor to a string describing the manufacturer/developer and firmware version and SHOULD always set `hardware_version` to a string describing, at least, the particular hardware/software package in use.
| used_version | U16 | Selected version proposed by the connecting node that the upstream node supports. This version will be used on the connection for the rest of its life. |
187
188
| flags | U32 | Flags indicating optional protocol features the server supports. Each protocol from protocol field has its own values/flags. |
Copy file name to clipboardExpand all lines: 04-Protocol-Security.md
+60-22
Original file line number
Diff line number
Diff line change
@@ -331,29 +331,67 @@ If the server provides a non-empty `CIPHER_CHOICE`:
331
331
2. New keys `key_new` are derived from the original CipherState keys `key_orig` by taking the first 32 bytes from `ENCRYPT(key_orig, maxnonce, zero_len, zeros)` using the negotiated cipher function where `maxnonce` is 2<sup>64</sup> - 1, `zerolen` is a zero-length byte sequence, and `zeros` is a sequence of 32 bytes filled with zeros. (see `Rekey(k)` function<sup>[8](#reference-8)</sup>)
332
332
3. New CipherState objects are reinitialized: `InitializeKey(key_new)`.
333
333
334
-
### 4.5.6 Transport message encryption and format
335
-
336
-
After handshake process is finished, both initiator and responder have CipherState objects for encryption and decryption and after initiator validated server's identity, any subsequent traffic is encrypted and decrypted with `EncryptWithAd()` and `DecryptWithAd()` methods of the respectrive CipherState objects with zero-length associated data.
337
-
338
-
Ciphertext is sent in `NOISE_FRAME` over the wire.
339
-
340
-
##### NOISE_FRAME
341
-
| Field Name | Data Type | Description |
342
-
| ---------- | --------- | ----------- |
343
-
| ciphertext | B0_64K | AEAD ciphertext including 16 bytes MAC |
After handshake process is finished, both initiator and responder have CipherState objects for encryption and decryption and after initiator validated server's identity, any subsequent traffic is encrypted and decrypted with `EncryptWithAd()` and `DecryptWithAd()` methods of the respective CipherState objects with zero-length associated data.
337
+
338
+
Maximum transport message length (ciphertext) is for noise protocol message 65535 bytes.
339
+
340
+
Since Stratum Message Frame consists of
341
+
- fixed length message header: 6 bytes
342
+
- variable length serialized stratum message
343
+
344
+
Stratum Message header and stratum message payload are processed separately.
345
+
346
+
#### Encrypting stratum message
347
+
1. serialize stratum message into a plaintext binary string (payload)
348
+
2. prepare frame header for the stratum message with `message_length` being length of payload ciphertext*
349
+
3. Encrypt and concatenate serialized header and payload:
Note that in regard to Stratum V2 message, `NOISE_FRAME` doesn't necessarily need to contain to exactly one encrypted Stratum message. Ciphertext payload may contain multiple subsequent messages or even only partial message. Examples:
370
+
#### Decrypting stratum message
371
+
1. read exactly 22 bytes and decrypt into stratum frame or fail
372
+
2. read `frame.message_length` number of bytes and decrypt into plaintext payload or fail
373
+
3. deserialize plaintext payload into stratum message given by `frame.extension_type` and `frame.message_type` or fail
352
374
353
-
-`OpenStandardMiningChannelSuccess` followed immediately with `NewMiningJob`
354
-
- Arbitrary message containing `B0_16M` type, since the noise ciphertext can be at most `2**16 - 1 == 65535` bytes long
Serialized stratum-v2 body (payload) is split into 65519-byte chunks and encrypted to form 65535-bytes AEAD ciphertexts,
391
+
where `ct_pld_N` is the N-th ciphertext block of payload and `pt_pld_N` is the N-th plaintext block of payload.
392
+
```
355
393
356
-
## 4.6 URL Scheme and Pool Authority Key
394
+
## 4.7 URL Scheme and Pool Authority Key
357
395
358
396
Downstream nodes that want to use the above outlined security scheme need to have configured the **Pool Authority Public Key** of the pool that they intend to connect to. It is provided by the target pool and communicated to its users via a trusted channel.
359
397
At least, it can be published on the pool's public website.
Copy file name to clipboardExpand all lines: 07-Template-Distribution-Protocol.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Thus, this message is used to indicate that some additional space in the block/c
17
17
18
18
The Job Declarator MUST discover the maximum serialized size of the additional outputs which will be added by the pool(s) it intends to use this work.
19
19
It then MUST communicate the maximum such size to the Template Provider via this message.
20
-
The Template Provider MUST NOT provide `NewWork` messages which would represent consensus-invalid blocks once this additional size — along with a maximally-sized (100 byte) coinbase field — is added.
20
+
The Template Provider MUST NOT provide `NewMiningJob` messages which would represent consensus-invalid blocks once this additional size — along with a maximally-sized (100 byte) coinbase field — is added.
21
21
Further, the Template Provider MUST consider the maximum additional bytes required in the output count variable-length integer in the coinbase transaction when complying with the size limits.
22
22
23
23
| Field Name | Data Type | Description |
@@ -45,7 +45,7 @@ The primary template-providing function. Note that the `coinbase_tx_outputs` byt
45
45
## 7.3 `SetNewPrevHash` (Server -> Client)
46
46
47
47
Upon successful validation of a new best block, the server MUST immediately provide a `SetNewPrevHash` message.
48
-
If a `NewWork` message has previously been sent with an empty `min_ntime`, which is valid work based on the `prev_hash` contained in this message, the `template_id` field SHOULD be set to the `job_id` present in that `NewTemplate` message indicating the client MUST begin mining on that template as soon as possible.
48
+
If a `NewMiningJob` message has previously been sent with an empty `min_ntime`, which is valid work based on the `prev_hash` contained in this message, the `template_id` field SHOULD be set to the `job_id` present in that `NewTemplate` message indicating the client MUST begin mining on that template as soon as possible.
49
49
50
50
TODO: Define how many previous works the client has to track (2? 3?), and require that the server reference one of those in `SetNewPrevHash`.
51
51
@@ -105,7 +105,7 @@ Upon finding a coinbase transaction/nonce pair which double-SHA256 hashes at or
| template_id | U64 | The template_id field as it appeared in NewTemplate |
108
-
| version | U32 | The version field in the block header. Bits not defined by BIP320 as additional nonce MUST be the same as they appear in the NewWork message, other bits may be set to any value. |
108
+
| version | U32 | The version field in the block header. Bits not defined by BIP320 as additional nonce MUST be the same as they appear in the NewMiningJob message, other bits may be set to any value. |
109
109
| header_timestamp | U32 | The nTime field in the block header. This MUST be greater than or equal to the header_timestamp field in the latest SetNewPrevHash message and lower than or equal to that value plus the number of seconds since the receipt of that message. |
110
110
| header_nonce | U32 | The nonce field in the header |
111
-
| coinbase_tx | B0_64K | The full serialized coinbase transaction, meeting all the requirements of the NewWork message, above |
111
+
| coinbase_tx | B0_64K | The full serialized coinbase transaction, meeting all the requirements of the NewMiningJob message, above |
0 commit comments