use of tech.pegasys.web3signer.signing.filecoin.FilecoinAddress in project web3signer by ConsenSys.
the class FilecoinAddressTest method verifyAddress.
private void verifyAddress(final String address, final String payload, final FilecoinProtocol bls) {
final FilecoinAddress filecoinAddress = FilecoinAddress.fromString(address);
final String expectedPayload = payload.substring(2);
assertThat(filecoinAddress.getPayload().toUnprefixedHexString()).isEqualTo(expectedPayload);
assertThat(filecoinAddress.getProtocol()).isEqualTo(bls);
String encodedAddress = filecoinAddress.encode(FilecoinNetwork.MAINNET);
assertThat(encodedAddress).isEqualTo(address);
}
use of tech.pegasys.web3signer.signing.filecoin.FilecoinAddress in project web3signer by ConsenSys.
the class FcJsonRpc method filecoinWalletVerify.
@JsonRpcMethod("Filecoin.WalletVerify")
public boolean filecoinWalletVerify(@JsonRpcParam("address") final String filecoinAddress, @JsonRpcParam("data") final Bytes dataToVerify, @JsonRpcParam("signature") final FilecoinSignature filecoinSignature) {
final FilecoinAddress address = FilecoinAddress.fromString(filecoinAddress);
final Bytes signature = Bytes.fromBase64String(filecoinSignature.getData());
switch(address.getProtocol()) {
case SECP256K1:
checkArgument(filecoinSignature.getType() == SECP_VALUE, "Invalid signature type");
return FilecoinVerify.verify(address, dataToVerify, SecpArtifactSignature.fromBytes(signature));
case BLS:
checkArgument(filecoinSignature.getType() == BLS_VALUE, "Invalid signature type");
return FilecoinVerify.verify(address, dataToVerify, new BlsArtifactSignature(BLSSignature.fromBytesCompressed(signature)));
default:
throw new IllegalArgumentException("Invalid address protocol type");
}
}
Aggregations