hex encode the enclave lookup ID in the response (#1902)

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/1918/head
Sally MacFarlane 4 years ago committed by GitHub
parent 67db876fcb
commit e8abb3c592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/GoQuorumStoreRawPrivateTransaction.java

@ -28,7 +28,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import java.util.Base64;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
public class GoQuorumStoreRawPrivateTransaction implements JsonRpcMethod {
@ -52,9 +55,9 @@ public class GoQuorumStoreRawPrivateTransaction implements JsonRpcMethod {
try {
LOG.debug("sending payload " + payload);
final StoreRawResponse storeRawResponse = enclave.storeRaw(payload);
String enclaveLookupId = storeRawResponse.getKey();
LOG.debug("got key from GoQuorum enclave " + enclaveLookupId);
return new JsonRpcSuccessResponse(id, enclaveLookupId);
final String enclaveLookupId = storeRawResponse.getKey();
LOG.debug("retrieved lookupId from GoQuorum enclave " + enclaveLookupId);
return new JsonRpcSuccessResponse(id, hexEncodeEnclaveKey(enclaveLookupId));
} catch (final IllegalArgumentException | RLPException e) {
LOG.error(e);
return new JsonRpcErrorResponse(id, DECODE_ERROR);
@ -62,4 +65,8 @@ public class GoQuorumStoreRawPrivateTransaction implements JsonRpcMethod {
return new JsonRpcErrorResponse(id, convertEnclaveInvalidReason(e.getMessage()));
}
}
private String hexEncodeEnclaveKey(final String enclaveKey) {
return Bytes.wrap(Base64.getDecoder().decode(enclaveKey)).toHexString();
}
}

Loading…
Cancel
Save