Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

feat: pass a contract address to verifyCiphertext #124

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fhevm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func createInputListWithBadIndex(values []big.Int, types []tfhe.FheUintType, lis
}

func packInputList(handle [32]byte, ciphertext []byte, fheUintType tfhe.FheUintType) []byte {
input, err := verifyCipertextMethod.Inputs.Pack(handle, [20]byte{}, ciphertext, [1]byte{byte(fheUintType)})
input, err := verifyCipertextMethod.Inputs.Pack(handle, [20]byte{}, [20]byte{}, ciphertext, [1]byte{byte(fheUintType)})
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion fhevm/fhelib.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ var fhelibMethods = []*FheLibMethod{
},
{
name: "verifyCiphertext",
argTypes: "(bytes32,address,bytes,bytes1)",
argTypes: "(bytes32,address,address,bytes,bytes1)",
requiredGasFunction: verifyCiphertextRequiredGas,
runFunction: verifyCiphertextRun,
},
Expand Down
10 changes: 7 additions & 3 deletions fhevm/operators_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const verifyCipertextAbiJson = `
"name": "callerAddress",
"type": "address"
},
{
"name": "contractAddress",
"type": "address"
},
{
"name": "inputProof",
"type": "bytes"
Expand Down Expand Up @@ -73,7 +77,7 @@ func parseVerifyCiphertextInput(environment EVMEnvironment, input []byte) ([32]b
unpacked, err := verifyCipertextMethod.Inputs.UnpackValues(input)
if err != nil {
return [32]byte{}, nil, err
} else if len(unpacked) != 4 {
} else if len(unpacked) != 5 {
return [32]byte{}, nil, fmt.Errorf("parseVerifyCiphertextInput unexpected unpacked len: %d", len(unpacked))
}

Expand All @@ -84,13 +88,13 @@ func parseVerifyCiphertextInput(environment EVMEnvironment, input []byte) ([32]b
}

// Get the ciphertext from the input.
ciphertextList, ok := unpacked[2].([]byte)
ciphertextList, ok := unpacked[3].([]byte)
if !ok || len(ciphertextList) == 0 {
return [32]byte{}, nil, fmt.Errorf("parseVerifyCiphertextInput failed to parse bytes inputProof")
}

// Get the type from the input.
inputTypeByteArray, ok := unpacked[3].([1]byte)
inputTypeByteArray, ok := unpacked[4].([1]byte)
if !ok {
return [32]byte{}, nil, fmt.Errorf("parseVerifyCiphertextInput failed to parse byte inputType")
}
Expand Down
Loading