Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit boost API - Generate Proxy Key, Signing Request #1033

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
764517e
feat: Commit boost API - Get Public Keys
usmansaleem Oct 20, 2024
82ce60b
Cli options for commit boost. Load proxy signers
usmansaleem Oct 20, 2024
cd20c6c
Unit test for DefaultArtifactSignerProvider loading proxy keys
usmansaleem Oct 20, 2024
94d9be4
empty proxy signers unit test
usmansaleem Oct 21, 2024
3433f75
changelog
usmansaleem Oct 21, 2024
9277a3e
feat: Commit boost API - Generate Proxy Key
usmansaleem Oct 21, 2024
ca5cc03
Generate proxy keys based on scheme
usmansaleem Oct 22, 2024
62b26a9
code fix
usmansaleem Oct 22, 2024
ec91f2e
skeleton for compute signing root
usmansaleem Oct 22, 2024
16277ed
Commit Boost - Gen Proxy Key - BLS Signing root
usmansaleem Oct 22, 2024
5267e71
Rewrite EthPublicKeyUtils to use compressed and uncompressed public keys
usmansaleem Oct 23, 2024
20daaad
Use updated EthPublicKeyUtils methods
usmansaleem Oct 23, 2024
92108da
EthSecpArtifactSigner to use compressed identifier or public key
usmansaleem Oct 23, 2024
1f18946
Commit Boost - Compute signing root for ECPublicKey
usmansaleem Oct 23, 2024
b261b84
Seperate out SigningRootGenerator for Commit Boost
usmansaleem Oct 23, 2024
a2b0c15
Fix EthAccountsResultProviderTest to use proper ECPublicKeys
usmansaleem Oct 23, 2024
afc10d9
Fix Eth1AddressSignerIdentifierTest to use proper SECP keys
usmansaleem Oct 23, 2024
bfb35d3
Fix Eth1AddressSignerIdentifier and unit test
usmansaleem Oct 24, 2024
501e3d8
prepping for unit test
usmansaleem Oct 24, 2024
a740c68
refactoring DefaultArtifactSignerProvider and unit test
usmansaleem Oct 24, 2024
9de3c02
fix json encoding in publickeysroot for 500
usmansaleem Oct 24, 2024
574f104
Merge branch 'commit_boost_support' into commit_boost_gen_proxy
usmansaleem Oct 24, 2024
ac50178
cleaning up ProxyKeyGenerator to use BLS and SECP256k1 and subdirecto…
usmansaleem Oct 24, 2024
eed0048
simplify bulk loading for proxy keys
usmansaleem Oct 24, 2024
3f9e82c
default gvr to zero for minimal networks
usmansaleem Oct 24, 2024
836b6ec
Merge remote-tracking branch 'upstream/master' into commit_boost_gen_…
usmansaleem Oct 24, 2024
b9360e1
refactor eth2 network override to mixin class
usmansaleem Oct 25, 2024
81611e6
Refactor to specify genesis validators root in commit boost api param…
usmansaleem Oct 25, 2024
e3066aa
fix password file path in DefaultArtifactSignerProvider
usmansaleem Oct 29, 2024
9b535c9
Use --genesis-state instead of gvr value from cli
usmansaleem Oct 29, 2024
4c9a144
Fix custom genesis cli option
usmansaleem Oct 29, 2024
eb81e87
refactor EthPublicKeyUtils methods. Add unit test for ProxykeyGenerator
usmansaleem Oct 29, 2024
02562a0
commit boost signing root generator unit test
usmansaleem Oct 29, 2024
40d2c27
unit test for signing root generator
usmansaleem Oct 29, 2024
6611ecd
Use GVR as ZERO. Update Signing root generator tests
usmansaleem Oct 30, 2024
41e781b
Update Signing Root Generator Test to verify bls signature
usmansaleem Oct 30, 2024
300cc68
Update unit tests
usmansaleem Oct 30, 2024
b196f63
Refactor ProxyDelegation names and getEncoded method
usmansaleem Oct 30, 2024
0ab780a
Refactor Eth2SubCommand
usmansaleem Oct 30, 2024
27c9188
Delete Unused Bytes32Converter
usmansaleem Oct 30, 2024
6c0e3b1
changelog
usmansaleem Oct 30, 2024
64b20d1
minor refactoring
usmansaleem Oct 30, 2024
ebccf38
Merge remote-tracking branch 'upstream/master' into commit_boost_gen_…
usmansaleem Oct 31, 2024
5a8a343
Commit Boost - Request Signature
usmansaleem Nov 1, 2024
d0c1119
refactor code
usmansaleem Nov 4, 2024
b8f7910
rename to CommitBoostSignerProvider
usmansaleem Nov 4, 2024
0ddab6e
refactor public keys route and handler
usmansaleem Nov 4, 2024
71435c9
Use CommitBoostSignerProvider
usmansaleem Nov 6, 2024
4cd9ef7
Simplify SignerForIdentifier
usmansaleem Nov 7, 2024
ad2e0ef
Delete SignatureFormatter
usmansaleem Nov 7, 2024
30c6f1b
cleaning SignerForIdentifier generic usage
usmansaleem Nov 7, 2024
b8aa52d
simplifying code
usmansaleem Nov 7, 2024
6dd046b
illegal state exception
usmansaleem Nov 7, 2024
0cce568
Introduce K256ArtifactSigner that generates R+S signature
usmansaleem Nov 10, 2024
45da58b
K256ArtifactSigner that matches Rust K-256 signature generation
usmansaleem Nov 11, 2024
53f2c59
K256ArtifactSigner that matches Rust K-256 signature generation
usmansaleem Nov 11, 2024
a2a16f8
Use K256ArtifactSigner for commit boost api usages
usmansaleem Nov 11, 2024
8ea96fc
Commit Boost Acceptance Tests List and Generate
usmansaleem Nov 14, 2024
a1ed50c
Commit Boost Acceptance Test
usmansaleem Nov 14, 2024
75c3e50
minor cleanup
usmansaleem Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Java 21 for build and runtime. [#995](https://github.com/Consensys/web3signer/pull/995)
- Electra fork support. [#1020](https://github.com/Consensys/web3signer/pull/1020) and [#1023](https://github.com/Consensys/web3signer/pull/1023)
- Commit boost API - Get Public Keys. [#1031](https://github.com/Consensys/web3signer/pull/1031)
- Commit boost API - Generate Proxy Keys. [#1033](https://github.com/Consensys/web3signer/pull/1033)

### Bugs fixed
- Override protobuf-java to 3.25.5 which is a transitive dependency from google-cloud-secretmanager. It fixes CVE-2024-7254.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static tech.pegasys.web3signer.signing.KeyType.BLS;

import tech.pegasys.web3signer.core.service.http.SigningObjectMapperFactory;
import tech.pegasys.web3signer.core.service.http.handlers.commitboost.json.SignRequestType;
import tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody;
import tech.pegasys.web3signer.dsl.Accounts;
import tech.pegasys.web3signer.dsl.Eth;
Expand Down Expand Up @@ -47,6 +48,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.Ethereum;
import org.web3j.protocol.core.JsonRpc2_0Web3j;
Expand Down Expand Up @@ -187,6 +189,34 @@ public Response callApiPublicKeys(final KeyType keyType) {
return given().baseUri(getUrl()).get(publicKeysPath(keyType));
}

public Response callCommitBoostGetPubKeys() {
return given().baseUri(getUrl()).get("/signer/v1/get_pubkeys");
}

public Response callCommitBoostGenerateProxyKey(final String pubkey, final String scheme) {
return given()
.baseUri(getUrl())
.contentType(ContentType.JSON)
.body(new JsonObject().put("pubkey", pubkey).put("scheme", scheme).toString())
.post("/signer/v1/generate_proxy_key");
}

public Response callCommitBoostReqeustForSignature(
final SignRequestType type, final String pubkey, final Bytes32 objectRoot) {
return given()
.baseUri(getUrl())
.contentType(ContentType.JSON)
.log()
.all()
.body(
new JsonObject()
.put("type", type.name().toLowerCase())
.put("pubkey", pubkey)
.put("object_root", objectRoot.toHexString())
.toString())
.post("/signer/v1/request_signature");
}

public List<String> listPublicKeys(final KeyType keyType) {
return callApiPublicKeys(keyType).as(new TypeRef<>() {});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import tech.pegasys.web3signer.dsl.tls.TlsCertificateDefinition;
import tech.pegasys.web3signer.signing.config.AwsVaultParameters;
import tech.pegasys.web3signer.signing.config.AzureKeyVaultParameters;
import tech.pegasys.web3signer.signing.config.CommitBoostParameters;
import tech.pegasys.web3signer.signing.config.GcpSecretManagerParameters;
import tech.pegasys.web3signer.signing.config.KeystoresParameters;

Expand Down Expand Up @@ -81,6 +82,7 @@ public class SignerConfiguration {
private final Optional<KeystoresParameters> v3KeystoresBulkloadParameters;

private final boolean signingExtEnabled;
private final CommitBoostParameters commitBoostParameters;

public SignerConfiguration(
final String hostname,
Expand Down Expand Up @@ -128,7 +130,8 @@ public SignerConfiguration(
final Optional<ClientTlsOptions> downstreamTlsOptions,
final ChainIdProvider chainIdProvider,
final Optional<KeystoresParameters> v3KeystoresBulkloadParameters,
final boolean signingExtEnabled) {
final boolean signingExtEnabled,
final CommitBoostParameters commitBoostParameters) {
this.hostname = hostname;
this.logLevel = logLevel;
this.httpRpcPort = httpRpcPort;
Expand Down Expand Up @@ -175,6 +178,7 @@ public SignerConfiguration(
this.chainIdProvider = chainIdProvider;
this.v3KeystoresBulkloadParameters = v3KeystoresBulkloadParameters;
this.signingExtEnabled = signingExtEnabled;
this.commitBoostParameters = commitBoostParameters;
}

public String hostname() {
Expand Down Expand Up @@ -368,4 +372,8 @@ public Optional<KeystoresParameters> getV3KeystoresBulkloadParameters() {
public boolean isSigningExtEnabled() {
return signingExtEnabled;
}

public Optional<CommitBoostParameters> getCommitBoostParameters() {
return Optional.ofNullable(commitBoostParameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import tech.pegasys.web3signer.dsl.tls.TlsCertificateDefinition;
import tech.pegasys.web3signer.signing.config.AwsVaultParameters;
import tech.pegasys.web3signer.signing.config.AzureKeyVaultParameters;
import tech.pegasys.web3signer.signing.config.CommitBoostParameters;
import tech.pegasys.web3signer.signing.config.GcpSecretManagerParameters;
import tech.pegasys.web3signer.signing.config.KeystoresParameters;

Expand Down Expand Up @@ -85,6 +86,7 @@ public class SignerConfigurationBuilder {
private KeystoresParameters v3KeystoresBulkloadParameters;

private boolean signingExtEnabled;
private CommitBoostParameters commitBoostParameters;

public SignerConfigurationBuilder withLogLevel(final Level logLevel) {
this.logLevel = logLevel;
Expand Down Expand Up @@ -331,6 +333,12 @@ public SignerConfigurationBuilder withSigningExtEnabled(final boolean signingExt
return this;
}

public SignerConfigurationBuilder withCommitBoostParameters(
final CommitBoostParameters commitBoostParameters) {
this.commitBoostParameters = commitBoostParameters;
return this;
}

public SignerConfiguration build() {
if (mode == null) {
throw new IllegalArgumentException("Mode cannot be null");
Expand Down Expand Up @@ -381,6 +389,7 @@ public SignerConfiguration build() {
Optional.ofNullable(downstreamTlsOptions),
chainIdProvider,
Optional.ofNullable(v3KeystoresBulkloadParameters),
signingExtEnabled);
signingExtEnabled,
commitBoostParameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import tech.pegasys.web3signer.dsl.utils.DatabaseUtil;
import tech.pegasys.web3signer.signing.config.AwsVaultParameters;
import tech.pegasys.web3signer.signing.config.AzureKeyVaultParameters;
import tech.pegasys.web3signer.signing.config.CommitBoostParameters;
import tech.pegasys.web3signer.signing.config.GcpSecretManagerParameters;
import tech.pegasys.web3signer.signing.config.KeystoresParameters;

Expand Down Expand Up @@ -163,6 +164,12 @@ public List<String> createCmdLineParams() {
String.format(YAML_BOOLEAN_FMT, "eth2.Xsigning-ext-enabled", Boolean.TRUE));
}

signerConfig
.getCommitBoostParameters()
.ifPresent(
commitBoostParameters ->
appendCommitBoostParameters(commitBoostParameters, yamlConfig));

final CommandArgs subCommandArgs = createSubCommandArgs();
params.addAll(subCommandArgs.params);
yamlConfig.append(subCommandArgs.yamlConfig);
Expand Down Expand Up @@ -204,6 +211,23 @@ public List<String> createCmdLineParams() {
return params;
}

private static void appendCommitBoostParameters(
final CommitBoostParameters commitBoostParameters, final StringBuilder yamlConfig) {
yamlConfig.append(
String.format(
YAML_BOOLEAN_FMT, "eth2.commit-boost-api-enabled", commitBoostParameters.isEnabled()));
yamlConfig.append(
String.format(
YAML_STRING_FMT,
"eth2.proxy-keystores-path",
commitBoostParameters.getProxyKeystoresPath().toAbsolutePath()));
yamlConfig.append(
String.format(
YAML_STRING_FMT,
"eth2.proxy-keystores-password-file",
commitBoostParameters.getProxyKeystoresPasswordFile().toAbsolutePath()));
}

private Consumer<? super KeystoresParameters> setV3KeystoresBulkloadParameters(
final StringBuilder yamlConfig) {
return keystoresParameters -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import tech.pegasys.web3signer.dsl.utils.DatabaseUtil;
import tech.pegasys.web3signer.signing.config.AwsVaultParameters;
import tech.pegasys.web3signer.signing.config.AzureKeyVaultParameters;
import tech.pegasys.web3signer.signing.config.CommitBoostParameters;
import tech.pegasys.web3signer.signing.config.GcpSecretManagerParameters;
import tech.pegasys.web3signer.signing.config.KeystoresParameters;

Expand Down Expand Up @@ -138,6 +139,12 @@ public List<String> createCmdLineParams() {
if (signerConfig.isSigningExtEnabled()) {
params.add("--Xsigning-ext-enabled=true");
}

signerConfig
.getCommitBoostParameters()
.ifPresent(
commitBoostParameters -> params.addAll(commitBoostOptions(commitBoostParameters)));

} else if (signerConfig.getMode().equals("eth1")) {
params.add("--downstream-http-port");
params.add(Integer.toString(signerConfig.getDownstreamHttpPort()));
Expand All @@ -160,6 +167,15 @@ public List<String> createCmdLineParams() {
return params;
}

private static List<String> commitBoostOptions(CommitBoostParameters commitBoostParameters) {
return List.of(
"--commit-boost-api-enabled=" + commitBoostParameters.isEnabled(),
"--proxy-keystores-path",
commitBoostParameters.getProxyKeystoresPath().toAbsolutePath().toString(),
"--proxy-keystores-password-file",
commitBoostParameters.getProxyKeystoresPasswordFile().toAbsolutePath().toString());
}

private static Consumer<KeystoresParameters> setV3KeystoresBulkloadParameters(
final List<String> params) {
return keystoresParameters -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 ConsenSys AG.
*
* 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.
*/
package tech.pegasys.web3signer.dsl.utils;

import tech.pegasys.web3signer.signing.config.CommitBoostParameters;

import java.nio.file.Path;
import java.util.Objects;

public class CommitBoostATParameters implements CommitBoostParameters {
private final boolean enabled;
private final Path proxyKeystoresPath;
private final Path proxyKeystoresPasswordFile;

public CommitBoostATParameters(
final boolean enabled, final Path proxyKeystoresPath, final Path proxyKeystoresPasswordFile) {
this.enabled = enabled;
this.proxyKeystoresPath = proxyKeystoresPath;
this.proxyKeystoresPasswordFile = proxyKeystoresPasswordFile;
}

@Override
public boolean isEnabled() {
return enabled;
}

@Override
public Path getProxyKeystoresPath() {
return proxyKeystoresPath;
}

@Override
public Path getProxyKeystoresPasswordFile() {
return proxyKeystoresPasswordFile;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CommitBoostATParameters that)) return false;
return enabled == that.enabled
&& Objects.equals(proxyKeystoresPath, that.proxyKeystoresPath)
&& Objects.equals(proxyKeystoresPasswordFile, that.proxyKeystoresPasswordFile);
}

@Override
public int hashCode() {
return Objects.hash(enabled, proxyKeystoresPath, proxyKeystoresPasswordFile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package tech.pegasys.web3signer.dsl.utils;

import static java.util.Collections.emptyList;
import static tech.pegasys.web3signer.core.util.DepositSigningRootUtil.computeDomain;
import static tech.pegasys.web3signer.core.util.Web3SignerSigningRootUtil.computeDomain;

import tech.pegasys.teku.api.schema.AggregateAndProof;
import tech.pegasys.teku.api.schema.Attestation;
Expand Down Expand Up @@ -48,7 +48,7 @@
import tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.RandaoReveal;
import tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.SyncCommitteeMessage;
import tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ValidatorRegistration;
import tech.pegasys.web3signer.core.util.DepositSigningRootUtil;
import tech.pegasys.web3signer.core.util.Web3SignerSigningRootUtil;

import java.util.Random;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -216,7 +216,7 @@ private static Eth2SigningRequestBody createDepositRequest() {
genesisForkVersion);
final Bytes32 depositDomain = computeDomain(Domain.DEPOSIT, genesisForkVersion, Bytes32.ZERO);
final Bytes signingRoot =
DepositSigningRootUtil.computeSigningRoot(
Web3SignerSigningRootUtil.computeSigningRoot(
depositMessage.asInternalDepositMessage(), depositDomain);
return Eth2SigningRequestBodyBuilder.anEth2SigningRequestBody()
.withType(ArtifactType.DEPOSIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ static void initV3Keystores() throws IOException, GeneralSecurityException, Ciph
publicKeys = new ArrayList<>();
for (int i = 0; i < 4; i++) {
final ECKeyPair ecKeyPair = Keys.createEcKeyPair();
final ECPublicKey ecPublicKey = EthPublicKeyUtils.createPublicKey(ecKeyPair.getPublicKey());
final ECPublicKey ecPublicKey =
EthPublicKeyUtils.bigIntegerToECPublicKey(ecKeyPair.getPublicKey());
final String publicKeyHex =
IdentifierUtils.normaliseIdentifier(EthPublicKeyUtils.toHexString(ecPublicKey));
publicKeys.add(publicKeyHex);
Expand Down
Loading
Loading