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);
}
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();
});
}
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);
}
Aggregations