Skip to content

Commit

Permalink
wip: added proto definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Oct 22, 2024
1 parent eb21c4b commit 753826f
Show file tree
Hide file tree
Showing 17 changed files with 2,227 additions and 63 deletions.
151 changes: 119 additions & 32 deletions bolt-cli/Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion bolt-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ alloy = { version = "0.2.0", features = [
"rpc-types-engine",
] }
blst = "0.3.12"
prost = "0.13.3"

# utils
dotenvy = "0.15.7"
Expand All @@ -27,4 +28,7 @@ lighthouse_eth2_keystore = { package = "eth2_keystore", git = "https://github.co
lighthouse_account_utils = { package = "account_utils", git = "https://github.com/sigp/lighthouse", rev = "a87f19d" }

[dev-dependencies]
tempfile = "3.13.0"
tempfile = "3.13.0"

[build-dependencies]
prost-build = "0.13.3"
7 changes: 7 additions & 0 deletions bolt-cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Perform the code generation for the protobuf files.
fn main() -> std::io::Result<()> {
let mut proto_build = prost_build::Config::new();

proto_build.out_dir("src/pb");
proto_build.compile_protos(&["proto/eth2-signer-api/lister.proto"], &["proto/eth2-signer-api"])
}
7 changes: 7 additions & 0 deletions bolt-cli/proto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Protobuf definitions

## Eth2 signer API

The definitions in this folder are taken from the [eth2-signer-api][eth2-signer-api] package.

[eth2-signer-api]: https://github.com/wealdtech/eth2-signer-api/tree/4aaf36e54f4e62d0cf4edc1b794e9a6354cf4f95/pb/v1
65 changes: 65 additions & 0 deletions bolt-cli/proto/eth2-signer-api/accountmanager.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
syntax = "proto3";

package v1;

import "google/api/annotations.proto";
import "responsestate.proto";
import "endpoint.proto";

option csharp_namespace = "Eth2Signer.v1";
option php_namespace = "Eth2Signer\\v1";
option go_package = "github.com/wealdtech/eth2-signer-api/pb/v1";
option java_package = "com.wealdtech.eth2signerapi.v1";
option java_multiple_files = true;
option java_outer_classname = "AccountManagerProto";

service AccountManager {
rpc Unlock(UnlockAccountRequest) returns (UnlockAccountResponse) {
option (google.api.http) = {
get: "/v1/accountmanager/unlock"
};
}

rpc Lock(LockAccountRequest) returns (LockAccountResponse) {
option (google.api.http) = {
get: "/v1/accountmanager/lock"
};
}

rpc Generate(GenerateRequest) returns (GenerateResponse) {
option (google.api.http) = {
post: "/v1/accountmanager/generate"
};
}
}

message UnlockAccountRequest {
string account = 1;
bytes passphrase = 2;
}

message LockAccountRequest {
string account = 1;
}

message UnlockAccountResponse {
ResponseState state = 1;
}

message LockAccountResponse {
ResponseState state = 1;
}

message GenerateRequest {
string account = 1;
bytes passphrase = 2;
uint32 participants = 3;
uint32 signing_threshold = 4;
}

message GenerateResponse {
ResponseState state = 1;
string message = 2;
bytes public_key = 3;
repeated Endpoint participants = 4;
}
70 changes: 70 additions & 0 deletions bolt-cli/proto/eth2-signer-api/dkg.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
syntax = "proto3";

package v1;

import "google/protobuf/empty.proto";
import "endpoint.proto";

option csharp_namespace = "Eth2Signer.v1";
option php_namespace = "Eth2Signer\\v1";
option go_package = "github.com/wealdtech/eth2-signer-api/pb/v1";
option java_package = "com.wealdtech.eth2signerapi.v1";
option java_multiple_files = true;
option java_outer_classname = "DKGProto";

// DKG is the internal protocol that runs between distributed key generators.
service DKG {
rpc Prepare(PrepareRequest) returns (google.protobuf.Empty) { }
rpc Execute(ExecuteRequest) returns (google.protobuf.Empty) { }
rpc Commit(CommitRequest) returns (CommitResponse) { }
rpc Abort(AbortRequest) returns (google.protobuf.Empty) { }
rpc Contribute(ContributeRequest) returns (ContributeResponse) { }
}

message PrepareRequest {
// account is the name of the account.
string account = 1;
// threshold is the number of participants required to generate a valid signature.
uint32 threshold = 2;
// participants contains the endpoints of all participants.
repeated Endpoint participants = 3;
// passphrase is the passphrase of the account.
bytes passphrase = 4;
}

message ExecuteRequest {
// account is the name of the account.
string account = 1;
}

message CommitRequest {
// account is the name of the account.
string account = 1;
// confirmation data is data used to generate the confirmation signature.
bytes confirmation_data = 2;
}

message CommitResponse {
// public_key is the key generated by the process.
bytes public_key = 1;
// confirmation_signature is the signature generated by the individual secret key.
bytes confirmation_signature = 2;
}

message AbortRequest {
// account is the name of the account.
string account = 1;
}

// ContributeRequest is sent by each part to all other parties with a contribution.
message ContributeRequest {
string account = 1;
bytes secret = 2;
repeated bytes verification_vector = 3;
}

// ContributeResponse receives the contribution from a participant.
message ContributeResponse {
bytes secret = 1;
repeated bytes verification_vector = 2;
}
16 changes: 16 additions & 0 deletions bolt-cli/proto/eth2-signer-api/endpoint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

package v1;

option csharp_namespace = "Eth2Signer.v1";
option php_namespace = "Eth2Signer\\v1";
option go_package = "github.com/wealdtech/eth2-signer-api/pb/v1";
option java_package = "com.wealdtech.eth2signerapi.v1";
option java_multiple_files = true;
option java_outer_classname = "EndpointProto";

message Endpoint {
uint64 id = 1;
string name = 2;
uint32 port = 3;
}
34 changes: 34 additions & 0 deletions bolt-cli/proto/eth2-signer-api/eth2.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";

package v1;

option csharp_namespace = "Eth2Signer.v1";
option php_namespace = "Eth2Signer\\v1";
option go_package = "github.com/wealdtech/eth2-signer-api/pb/v1";
option java_package = "com.wealdtech.eth2signerapi.v1";
option java_multiple_files = true;
option java_outer_classname = "Eth2Proto";

// AttestationData is defined at https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#attestationdata
message AttestationData {
uint64 slot = 1;
uint64 committee_index = 2;
bytes beacon_block_root = 3;
Checkpoint source = 4;
Checkpoint target = 5;
}

// Checkpoint is defined at https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#checkpoint
message Checkpoint {
uint64 epoch = 1;
bytes root = 2;
}

// BeaconBlockheader is defined at https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
message BeaconBlockHeader {
uint64 slot = 1;
uint64 proposer_index = 2;
bytes parent_root = 3;
bytes state_root = 4;
bytes body_root = 5;
}
31 changes: 31 additions & 0 deletions bolt-cli/proto/eth2-signer-api/google/api/annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
Loading

0 comments on commit 753826f

Please sign in to comment.