From 6f68c19638ab2d6c465d00ff2ba802f462a1c419 Mon Sep 17 00:00:00 2001 From: Petar Ivanov <29689712+dartdart26@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:47:52 +0300 Subject: [PATCH] Return raw FHE public key if called directly If the fhePubKey precompile is called directly (e.g. from eth_call), return the raw key bytes. If called from the EVM (i.e. Solidity lib), return it as an EVM array that can be used in Solidity. --- core/vm/contracts.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index d274d5df215b..56c1d626634e 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -2064,7 +2064,12 @@ func (e *fhePubKey) Run(accessibleState PrecompileAccessibleState, caller common accessibleState.Interpreter().evm.Logger.Error(msg, "existing", existing.Hex(), "pksHash", pksHash.Hex()) return nil, errors.New(msg) } - return toEVMBytes(pksBytes), nil + // If we have a single byte with the value of 1, return as an EVM array. Otherwise, returh the raw bytes. + if len(input) == 1 && input[0] == 1 { + return toEVMBytes(pksBytes), nil + } else { + return pksBytes, nil + } } type trivialEncrypt struct{}