Search in sources :

Example 1 with Eth2SigningRequestBody

use of tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody in project web3signer by ConsenSys.

the class Eth2AltairBlockSigningAcceptanceTest method signAndVerifyLegacyBlockSignature.

@Test
void signAndVerifyLegacyBlockSignature() throws Exception {
    final Eth2BlockSigningRequestUtil util = new Eth2BlockSigningRequestUtil(SpecMilestone.PHASE0);
    setupEth2SignerMinimalWithoutAltairFork();
    final Eth2SigningRequestBody request = util.createLegacyBlockRequest();
    final Response response = signer.eth2Sign(keyPair.getPublicKey().toString(), request, ContentType.JSON);
    final Bytes signature = verifyAndGetSignatureResponse(response, ContentType.JSON);
    final BLSSignature expectedSignature = BLS.sign(keyPair.getSecretKey(), request.getSigningRoot());
    assertThat(signature).isEqualTo(expectedSignature.toBytesCompressed());
}
Also used : Response(io.restassured.response.Response) Bytes(org.apache.tuweni.bytes.Bytes) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody) Eth2BlockSigningRequestUtil(tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil) BLSSignature(tech.pegasys.teku.bls.BLSSignature) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Eth2SigningRequestBody

use of tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody in project web3signer by ConsenSys.

the class Eth2RequestUtils method createSyncCommitteeMessageRequest.

private static Eth2SigningRequestBody createSyncCommitteeMessageRequest() {
    final ForkInfo forkInfo = forkInfo();
    final Bytes signingRoot;
    try {
        signingRoot = signingRootFromSyncCommitteeUtils(slot, utils -> utils.getSyncCommitteeMessageSigningRoot(beaconBlockRoot, altairSpec.computeEpochAtSlot(slot), forkInfo.asInternalForkInfo())).get();
    } catch (final InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
    final SyncCommitteeMessage syncCommitteeMessage = new SyncCommitteeMessage(beaconBlockRoot, slot);
    return new Eth2SigningRequestBody(ArtifactType.SYNC_COMMITTEE_MESSAGE, signingRoot, forkInfo, null, null, null, null, null, null, null, null, syncCommitteeMessage, null, null);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody) ExecutionException(java.util.concurrent.ExecutionException) SyncCommitteeMessage(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.SyncCommitteeMessage)

Example 3 with Eth2SigningRequestBody

use of tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody in project web3signer by ConsenSys.

the class Eth2RequestUtils method createRandaoReveal.

private static Eth2SigningRequestBody createRandaoReveal() {
    final ForkInfo forkInfo = forkInfo();
    final RandaoReveal randaoReveal = new RandaoReveal(UInt64.valueOf(3));
    final Bytes signingRoot = signingRootUtil.signingRootForRandaoReveal(randaoReveal.getEpoch(), forkInfo.asInternalForkInfo());
    return new Eth2SigningRequestBody(ArtifactType.RANDAO_REVEAL, signingRoot, forkInfo, null, null, null, null, null, null, randaoReveal, null, null, null, null);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) RandaoReveal(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.RandaoReveal) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)

Example 4 with Eth2SigningRequestBody

use of tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody in project web3signer by ConsenSys.

the class Eth2RequestUtils method createVoluntaryExit.

private static Eth2SigningRequestBody createVoluntaryExit() {
    final ForkInfo forkInfo = forkInfo();
    final VoluntaryExit voluntaryExit = new VoluntaryExit(UInt64.valueOf(119), UInt64.ZERO);
    final Bytes signingRoot = signingRootUtil.signingRootForSignVoluntaryExit(voluntaryExit.asInternalVoluntaryExit(), forkInfo.asInternalForkInfo());
    return new Eth2SigningRequestBody(ArtifactType.VOLUNTARY_EXIT, signingRoot, forkInfo, null, null, null, null, null, voluntaryExit, null, null, null, null, null);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) VoluntaryExit(tech.pegasys.teku.api.schema.VoluntaryExit) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)

Example 5 with Eth2SigningRequestBody

use of tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody in project web3signer by ConsenSys.

the class Eth2RequestUtils method createSyncCommitteeContributionAndProofRequest.

private static Eth2SigningRequestBody createSyncCommitteeContributionAndProofRequest() {
    final ForkInfo forkInfo = forkInfo();
    final Bytes signingRoot;
    try {
        signingRoot = signingRootFromSyncCommitteeUtils(slot, utils -> utils.getContributionAndProofSigningRoot(contributionAndProof, forkInfo.asInternalForkInfo())).get();
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
    return new Eth2SigningRequestBody(ArtifactType.SYNC_COMMITTEE_CONTRIBUTION_AND_PROOF, signingRoot, forkInfo, null, null, null, null, null, null, null, null, null, null, getContributionAndProof());
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Eth2SigningRequestBody (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)31 Bytes (org.apache.tuweni.bytes.Bytes)17 Response (io.restassured.response.Response)16 Test (org.junit.jupiter.api.Test)15 ForkInfo (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 BLSSignature (tech.pegasys.teku.bls.BLSSignature)5 Eth2BlockSigningRequestUtil (tech.pegasys.web3signer.dsl.utils.Eth2BlockSigningRequestUtil)5 Path (java.nio.file.Path)4 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 JsonObject (io.vertx.core.json.JsonObject)3 ExecutionException (java.util.concurrent.ExecutionException)3 AttestationData (tech.pegasys.teku.api.schema.AttestationData)2 Checkpoint (tech.pegasys.teku.api.schema.Checkpoint)2 DepositMessage (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.DepositMessage)2 Signer (tech.pegasys.web3signer.dsl.signer.Signer)2 SignerConfigurationBuilder (tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InterchangeV5Format (dsl.InterchangeV5Format)1 SignedArtifacts (dsl.SignedArtifacts)1