Skip to content

Commit bbef785

Browse files
authored
fix: add proxy module check (#120)
* add proxy module check * remove unused
1 parent 5c4bead commit bbef785

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ jobs:
3636
os: macos-latest
3737
- target: aarch64-apple-darwin
3838
os: macos-latest
39-
names:
40-
- binary: commit-boost
41-
publish: commit-boost-cli
42-
- binary: default-pbs
43-
publish: commit-boost-pbs
44-
- binary: signer-module
45-
publish: commit-boost-signer
4639

4740
runs-on: ${{ matrix.os }}
4841
steps:

crates/signer/src/manager.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,22 @@ impl SigningManager {
181181
self.consensus_signers.contains_key(pubkey)
182182
}
183183

184-
pub fn has_proxy_ecdsa(&self, ecdsa_pk: &EcdsaPublicKey) -> bool {
185-
self.proxy_signers.ecdsa_signers.contains_key(ecdsa_pk)
184+
pub fn has_proxy_bls_for_module(&self, bls_pk: &BlsPublicKey, module_id: &ModuleId) -> bool {
185+
match self.proxy_pubkeys_bls.get(module_id) {
186+
Some(keys) => keys.contains(bls_pk),
187+
None => false,
188+
}
186189
}
187190

188-
pub fn has_proxy_bls(&self, bls_pk: &BlsPublicKey) -> bool {
189-
self.proxy_signers.bls_signers.contains_key(bls_pk)
191+
pub fn has_proxy_ecdsa_for_module(
192+
&self,
193+
ecdsa_pk: &EcdsaPublicKey,
194+
module_id: &ModuleId,
195+
) -> bool {
196+
match self.proxy_pubkeys_ecdsa.get(module_id) {
197+
Some(keys) => keys.contains(ecdsa_pk),
198+
None => false,
199+
}
190200
}
191201

192202
pub fn get_delegation_bls(
@@ -295,7 +305,8 @@ mod tests {
295305
);
296306

297307
assert!(
298-
signing_manager.has_proxy_bls(&signed_delegation.message.proxy),
308+
signing_manager
309+
.has_proxy_bls_for_module(&signed_delegation.message.proxy, &MODULE_ID),
299310
"Newly generated proxy key must be present in the signing manager's registry."
300311
);
301312
}
@@ -373,7 +384,8 @@ mod tests {
373384
);
374385

375386
assert!(
376-
signing_manager.has_proxy_ecdsa(&signed_delegation.message.proxy),
387+
signing_manager
388+
.has_proxy_ecdsa_for_module(&signed_delegation.message.proxy, &MODULE_ID),
377389
"Newly generated proxy key must be present in the signing manager's registry."
378390
);
379391
}

crates/signer/src/service.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,21 @@ async fn handle_request_signature(
134134
.sign_consensus(&pubkey, &object_root)
135135
.await
136136
.map(|sig| Json(sig).into_response()),
137-
SignRequest::ProxyBls(SignProxyRequest { pubkey: bls_pk, object_root }) => signing_manager
138-
.sign_proxy_bls(&bls_pk, &object_root)
139-
.await
140-
.map(|sig| Json(sig).into_response()),
137+
SignRequest::ProxyBls(SignProxyRequest { pubkey: bls_pk, object_root }) => {
138+
if !signing_manager.has_proxy_bls_for_module(&bls_pk, &module_id) {
139+
return Err(SignerModuleError::UnknownProxySigner(bls_pk.to_vec()));
140+
}
141+
142+
signing_manager
143+
.sign_proxy_bls(&bls_pk, &object_root)
144+
.await
145+
.map(|sig| Json(sig).into_response())
146+
}
141147
SignRequest::ProxyEcdsa(SignProxyRequest { pubkey: ecdsa_pk, object_root }) => {
148+
if !signing_manager.has_proxy_ecdsa_for_module(&ecdsa_pk, &module_id) {
149+
return Err(SignerModuleError::UnknownProxySigner(ecdsa_pk.to_vec()));
150+
}
151+
142152
signing_manager
143153
.sign_proxy_ecdsa(&ecdsa_pk, &object_root)
144154
.await

0 commit comments

Comments
 (0)