Skip to content

Commit 498eed9

Browse files
jclapisltitanbManuelBilbao
authored
CBST2-02: Make proposer commitment signatures unique to modules (#329)
Co-authored-by: eltitanb <[email protected]> Co-authored-by: ltitanb <[email protected]> Co-authored-by: Manuel Iñaki Bilbao <[email protected]>
1 parent 151e811 commit 498eed9

File tree

34 files changed

+1337
-297
lines changed

34 files changed

+1337
-297
lines changed

api/signer-api.yml

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ paths:
6060

6161
/signer/v1/request_signature:
6262
post:
63-
summary: Send a signature request
63+
summary: Request a signature for a 32-byte blob of data (typically a hash), signed by the requested BLS or ECDSA key.
6464
tags:
6565
- Signer
6666
security:
@@ -81,15 +81,15 @@ paths:
8181
type: string
8282
enum: [consensus, proxy_bls, proxy_ecdsa]
8383
pubkey:
84-
description: Public key of the validator for consensus signatures
84+
description: The 48-byte BLS public key, with optional `0x` prefix, of the proposer key that you want to request a signature from.
8585
$ref: "#/components/schemas/BlsPubkey"
8686
proxy:
87-
description: BLS proxy pubkey or ECDSA address for proxy signatures
87+
description: The 48-byte BLS public key (for `proxy_bls` mode) or the 20-byte Ethereum address (for `proxy_ecdsa` mode), with optional `0x` prefix, of the proxy key that you want to request a signature from.
8888
oneOf:
8989
- $ref: "#/components/schemas/BlsPubkey"
9090
- $ref: "#/components/schemas/EcdsaAddress"
9191
object_root:
92-
description: The root of the object to be signed
92+
description: The 32-byte data you want to sign, with optional `0x` prefix.
9393
type: string
9494
format: hex
9595
pattern: "^0x[a-fA-F0-9]{64}$"
@@ -112,7 +112,7 @@ paths:
112112
object_root: "0x3e9f4a78b5c21d64f0b8e3d9a7f5c02b4d1e67a3c8f29b5d6e4a3b1c8f72e6d9"
113113
responses:
114114
"200":
115-
description: Success
115+
description: A successful signature response. The returned signature is the Merkle root hash of the provided `object_root` field and the requesting module's Signing ID as specified in the Commit-Boost configuration. For details on this signature, see the [signature structure documentation](https://commit-boost.github.io/commit-boost-client/developing/prop-commit-signing.md#structure-of-a-signature).
116116
content:
117117
application/json:
118118
schema:
@@ -126,8 +126,45 @@ paths:
126126
value: "0xa3ffa9241f78279f1af04644cb8c79c2d8f02bcf0e28e2f186f6dcccac0a869c2be441fda50f0dea895cfce2e53f0989a3ffa9241f78279f1af04644cb8c79c2d8f02bcf0e28e2f186f6dcccac0a869c2be441fda50f0dea895cfce2e53f0989"
127127
ProxyEcdsa:
128128
value: "0x985b495f49d1b96db3bba3f6c5dd1810950317c10d4c2042bd316f338cdbe74359072e209b85e56ac492092d7860063dd096ca31b4e164ef27e3f8d508e656801c"
129+
"400":
130+
description: |
131+
This can occur in several scenarios:
132+
133+
- You requested an operation while using the Dirk signer mode instead of locally-managed signer mode, but Dirk doesn't support that operation.
134+
- Something went wrong while preparing your request; the error text will provide more information.
135+
content:
136+
application/json:
137+
schema:
138+
type: object
139+
required:
140+
- code
141+
- message
142+
properties:
143+
code:
144+
type: number
145+
example: 400
146+
message:
147+
type: string
148+
example: "Bad request: Invalid pubkey format"
149+
"401":
150+
description: The requesting module did not provide a JWT string in the request's authorization header, or the JWT string was not configured in the signer service's configuration file as belonging to the module.
151+
content:
152+
application/json:
153+
schema:
154+
type: object
155+
required:
156+
- code
157+
- message
158+
properties:
159+
code:
160+
type: number
161+
example: 401
162+
message:
163+
type: string
164+
example: "Unauthorized"
165+
129166
"404":
130-
description: Unknown value (pubkey, etc.)
167+
description: You either requested a route that doesn't exist, or you requested a signature from a key that does not exist.
131168
content:
132169
application/json:
133170
schema:
@@ -142,8 +179,24 @@ paths:
142179
message:
143180
type: string
144181
example: "Unknown pubkey"
182+
"429":
183+
description: Your module attempted and failed JWT authentication too many times recently, and is currently timed out. It cannot make any more requests until the timeout ends.
184+
content:
185+
application/json:
186+
schema:
187+
type: object
188+
required:
189+
- code
190+
- message
191+
properties:
192+
code:
193+
type: number
194+
example: 429
195+
message:
196+
type: string
197+
example: "Too many requests"
145198
"500":
146-
description: Internal error
199+
description: Your request was valid, but something went wrong internally that prevented it from being fulfilled.
147200
content:
148201
application/json:
149202
schema:
@@ -158,6 +211,22 @@ paths:
158211
message:
159212
type: string
160213
example: "Internal error"
214+
"502":
215+
description: The signer service is running in Dirk signer mode, but Dirk could not be reached.
216+
content:
217+
application/json:
218+
schema:
219+
type: object
220+
required:
221+
- code
222+
- message
223+
properties:
224+
code:
225+
type: number
226+
example: 502
227+
message:
228+
type: string
229+
example: "Bad gateway: Dirk signer service is unreachable"
161230

162231
/signer/v1/generate_proxy_key:
163232
post:

bin/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub mod prelude {
1010
load_pbs_custom_config, LogsSettings, StartCommitModuleConfig, PBS_MODULE_NAME,
1111
},
1212
pbs::{BuilderEvent, BuilderEventClient, OnBuilderApiEvent},
13+
signature::{
14+
verify_proposer_commitment_signature_bls, verify_proposer_commitment_signature_ecdsa,
15+
},
1316
signer::{BlsPublicKey, BlsSignature, EcdsaSignature},
1417
types::Chain,
1518
utils::{initialize_tracing_log, utcnow_ms, utcnow_ns, utcnow_sec, utcnow_us},

config.example.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09f
152152
# - Dirk: a remote Dirk instance
153153
# - Local: a local Signer module
154154
# More details on the docs (https://commit-boost.github.io/commit-boost-client/get_started/configuration/#signer-module)
155-
# [signer]
155+
[signer]
156156
# Docker image to use for the Signer module.
157157
# OPTIONAL, DEFAULT: ghcr.io/commit-boost/signer:latest
158-
# docker_image = "ghcr.io/commit-boost/signer:latest"
158+
docker_image = "ghcr.io/commit-boost/signer:latest"
159159
# Host to bind the Signer API server to
160160
# OPTIONAL, DEFAULT: 127.0.0.1
161161
host = "127.0.0.1"
@@ -249,6 +249,8 @@ proxy_dir = "./proxies"
249249
[[modules]]
250250
# Unique ID of the module
251251
id = "DA_COMMIT"
252+
# Unique hash that the Signer service will combine with the incoming data in signing requests to generate a signature specific to this module
253+
signing_id = "0x6a33a23ef26a4836979edff86c493a69b26ccf0b4a16491a815a13787657431b"
252254
# Type of the module. Supported values: commit, events
253255
type = "commit"
254256
# Docker image of the module

crates/common/src/commit/request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use alloy::{
88
hex,
9-
primitives::{Address, B256},
9+
primitives::{aliases::B32, Address, B256},
1010
rpc::types::beacon::BlsSignature,
1111
};
1212
use derive_more::derive::From;
@@ -62,7 +62,8 @@ impl<T: ProxyId> SignedProxyDelegation<T> {
6262
&self.message.delegator,
6363
&self.message,
6464
&self.signature,
65-
COMMIT_BOOST_DOMAIN,
65+
None,
66+
&B32::from(COMMIT_BOOST_DOMAIN),
6667
)
6768
}
6869
}

crates/common/src/config/module.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::HashMap;
22

3+
use alloy::primitives::B256;
34
use eyre::{ContextCompat, Result};
45
use serde::{de::DeserializeOwned, Deserialize, Serialize};
56
use toml::Table;
@@ -37,6 +38,8 @@ pub struct StaticModuleConfig {
3738
/// Type of the module
3839
#[serde(rename = "type")]
3940
pub kind: ModuleKind,
41+
/// Signing ID for the module to use when requesting signatures
42+
pub signing_id: B256,
4043
}
4144

4245
/// Runtime config to start a module

0 commit comments

Comments
 (0)