Skip to content

Commit

Permalink
Handle gas estimation for decryp() and reecrypt() as well
Browse files Browse the repository at this point in the history
  • Loading branch information
toml01 committed Jan 2, 2024
1 parent c10d771 commit 9000a14
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions precompiles/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ func Reencrypt(input []byte, tp *TxParams) ([]byte, error) {
return nil, vm.ErrExecutionReverted
}

if tp.GasEstimation {
return []byte{1}, nil
}

decryptedValue, err := tfhe.Decrypt(*ct)
if err != nil {
logger.Error("failed decrypting ciphertext ", "error ", err)
Expand Down Expand Up @@ -178,6 +182,10 @@ func Decrypt(input []byte, tp *TxParams) (*big.Int, error) {
return nil, vm.ErrExecutionReverted
}

if tp.GasEstimation {
return new(big.Int).SetUint64(1), nil
}

decryptedValue, err := tfhe.Decrypt(*ct)
if err != nil {
logger.Error("failed decrypting ciphertext", " error ", err)
Expand Down

0 comments on commit 9000a14

Please sign in to comment.