Skip to content

Commit

Permalink
chore(docs): update md files in book
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Petrov committed Aug 29, 2024
1 parent f103c8d commit da550d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ async fn main() {
let pubkey = *pubkeys.consensus.first().unwrap();

let datagram = Datagram { data: 42 };
let request = SignRequest::builder(pubkey).with_msg(&datagram);
let request = SignConsensusRequest::builder(pubkey).with_msg(&datagram);
let signature = config
.signer_client
.request_signature(&request)
.request_consensus_signature(&request)
.await
.unwrap();

Expand Down
27 changes: 19 additions & 8 deletions docs/docs/developing/commit-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The loaded `config` also has a few other useful fields:


## Requesting signatures
At its core the Signer Module simply provides a signature on a 32-byte data digest. The signatures are currently provided with either the validator keys (BLS) or a proxy key (also BLS) for a given validator key, both on the [builder domain](https://github.com/Commit-Boost/commit-boost-client/blob/main/crates/common/src/signature.rs#L88-L96). Eventually we plan to support [alternative](https://github.com/Commit-Boost/commit-boost-client/issues/20) signing schemes, too.
At its core the Signer Module simply provides a signature on a 32-byte data digest. The signatures are currently provided with either the validator keys (BLS) or a proxy key (BLS or ECDSA) for a given validator key, both on the [builder domain](https://github.com/Commit-Boost/commit-boost-client/blob/main/crates/common/src/signature.rs#L88-L96).

In the example we use `TreeHash`, already used in the CL, to create the digest from a custom struct:
```rust
Expand All @@ -69,26 +69,37 @@ Then, we can request a signature either with a consensus key or with a proxy key
Requesting a signature is as simple as:
```rust
let datagram = Datagram { data: 1 };
let request = SignRequest::builder(pubkey).with_msg(&datagram);
let signature = config.signer_client.request_signature(&request).await.unwrap();
let request = SignConsensusRequest::builder(pubkey).with_msg(&datagram);
let signature = config.signer_client.request_consensus_signature(&request).await.unwrap();
```

Where `pubkey` is the validator (consensus) public key for which the signature is requested.

### With a proxy key
You'll have to first request a proxy key be generated for a given consensus key:
You'll have to first request a proxy key be generated for a given consensus key.
We support two signature schemes for proxies: BLS or ECDSA.

To request a proxy:
```rust
let proxy_delegation = self.config.signer_client.generate_proxy_key(pubkey).await?;
// BLS proxy
let proxy_delegation = self.config.signer_client.generate_proxy_key_bls(pubkey).await?;
let proxy_pubkey = proxy_delegation.message.proxy;

// or ECDSA proxy
let proxy_delegation = self.config.signer_client.generate_proxy_key_ecdsa(pubkey).await?;
let proxy_pubkey = proxy_delegation.message.proxy;
```

Where `pubkey` is the validator (consensus) public key for which a proxy is to be generated.

Then, the only difference from the direct approach is explicitly saying that the signature request uses a proxy key:
Then you can use the generated proxy key to request a signature:
```rust
let datagram = Datagram { data: 1 };
let request = SignRequest::builder(proxy_pubkey).is_proxy().with_msg(&datagram);
let signature = config.signer_client.request_signature(&request).await.unwrap();
let request = SignProxyRequest::builder(proxy_pubkey).with_msg(&datagram);
// if `proxy_pubkey` is a BLS proxy
let signature = config.signer_client.request_proxy_signature_bls(&request).await.unwrap();
// or for ECDSA proxy
let signature = config.signer_client.request_proxy_signature_ecdsa(&request).await.unwrap();
```

## Metrics
Expand Down

0 comments on commit da550d3

Please sign in to comment.