Search in sources :

Example 1 with FilecoinSignature

use of tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature in project web3signer by ConsenSys.

the class FcBlsVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.

@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
    startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.BLS_VALUE, expectedSignature.getSignatureData().toBytesCompressed().toBase64String());
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(network), dataString, filecoinSignature), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
Also used : Response(io.restassured.response.Response) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilecoinSignature(tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature) Test(org.junit.jupiter.api.Test)

Example 2 with FilecoinSignature

use of tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature in project web3signer by ConsenSys.

the class CompareFilecoinApisAcceptanceTest method compareWalletSignAndVerifyResponsesWithRandomDataToSign.

@RepeatedTest(25)
@Test
void compareWalletSignAndVerifyResponsesWithRandomDataToSign() {
    addressMap.keySet().parallelStream().forEach(address -> {
        final Bytes dataToSign = Bytes.random(32);
        assertThatCode(() -> {
            final FilecoinSignature lotusFcSig = LOTUS_NODE.walletSign(address, dataToSign);
            final FilecoinSignature signerFcSig = signer.walletSign(address, dataToSign);
            assertThat(signerFcSig).isEqualTo(lotusFcSig);
            // verify signatures
            final Boolean lotusSigVerify = LOTUS_NODE.walletVerify(address, dataToSign, lotusFcSig);
            final Boolean signerSigVerify = signer.walletVerify(address, dataToSign, signerFcSig);
            assertThat(lotusSigVerify).isTrue();
            assertThat(signerSigVerify).isTrue();
        }).as("Running with data %s for address %s", dataToSign, address).doesNotThrowAnyException();
    });
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) FilecoinSignature(tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 3 with FilecoinSignature

use of tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature in project web3signer by ConsenSys.

the class FcSecpVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.

@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
    startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.SECP_VALUE, expectedBase64Signature);
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.TESTNET), dataString, filecoinSignature), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
Also used : Response(io.restassured.response.Response) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilecoinSignature(tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 FilecoinSignature (tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ValueNode (com.fasterxml.jackson.databind.node.ValueNode)2 Request (com.github.arteam.simplejsonrpc.core.domain.Request)2 Response (io.restassured.response.Response)2 SignerConfigurationBuilder (tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder)2 Bytes (org.apache.tuweni.bytes.Bytes)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1