@ -46,7 +46,6 @@ import org.apache.logging.log4j.Logger;
public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
private final Enclave enclave ;
private final Enclave enclave ;
private final String enclavePublicKey ;
private final WorldStateArchive privateWorldStateArchive ;
private final WorldStateArchive privateWorldStateArchive ;
private final PrivateStateStorage privateStateStorage ;
private final PrivateStateStorage privateStateStorage ;
private PrivateTransactionProcessor privateTransactionProcessor ;
private PrivateTransactionProcessor privateTransactionProcessor ;
@ -58,7 +57,6 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
final GasCalculator gasCalculator , final PrivacyParameters privacyParameters ) {
final GasCalculator gasCalculator , final PrivacyParameters privacyParameters ) {
this (
this (
gasCalculator ,
gasCalculator ,
privacyParameters . getEnclavePublicKey ( ) ,
new Enclave ( privacyParameters . getEnclaveUri ( ) ) ,
new Enclave ( privacyParameters . getEnclaveUri ( ) ) ,
privacyParameters . getPrivateWorldStateArchive ( ) ,
privacyParameters . getPrivateWorldStateArchive ( ) ,
privacyParameters . getPrivateStateStorage ( ) ) ;
privacyParameters . getPrivateStateStorage ( ) ) ;
@ -66,13 +64,11 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
PrivacyPrecompiledContract (
PrivacyPrecompiledContract (
final GasCalculator gasCalculator ,
final GasCalculator gasCalculator ,
final String publicKey ,
final Enclave enclave ,
final Enclave enclave ,
final WorldStateArchive worldStateArchive ,
final WorldStateArchive worldStateArchive ,
final PrivateStateStorage privateStateStorage ) {
final PrivateStateStorage privateStateStorage ) {
super ( "Privacy" , gasCalculator ) ;
super ( "Privacy" , gasCalculator ) ;
this . enclave = enclave ;
this . enclave = enclave ;
this . enclavePublicKey = publicKey ;
this . privateWorldStateArchive = worldStateArchive ;
this . privateWorldStateArchive = worldStateArchive ;
this . privateStateStorage = privateStateStorage ;
this . privateStateStorage = privateStateStorage ;
}
}
@ -90,12 +86,12 @@ public class PrivacyPrecompiledContract extends AbstractPrecompiledContract {
@Override
@Override
public BytesValue compute ( final BytesValue input , final MessageFrame messageFrame ) {
public BytesValue compute ( final BytesValue input , final MessageFrame messageFrame ) {
final String key = BytesValues . asBase64String ( input ) ;
final String key = BytesValues . asBase64String ( input ) ;
final ReceiveRequest receiveRequest = new ReceiveRequest ( key , enclavePublicKey ) ;
final ReceiveRequest receiveRequest = new ReceiveRequest ( key ) ;
final ReceiveResponse receiveResponse ;
final ReceiveResponse receiveResponse ;
try {
try {
receiveResponse = enclave . receive ( receiveRequest ) ;
receiveResponse = enclave . receive ( receiveRequest ) ;
} catch ( Exception e ) {
} catch ( final Exception e ) {
LOG . error ( "Enclave probably does not have private transaction with key {}." , key , e ) ;
LOG . error ( "Enclave probably does not have private transaction with key {}." , key , e ) ;
return BytesValue . EMPTY ;
return BytesValue . EMPTY ;
}
}