Skip to content

Commit

Permalink
feat: pass a contract address to verifyCiphertext
Browse files Browse the repository at this point in the history
Will be needed in the future to verify the input ZKPoK.
  • Loading branch information
dartdart26 committed Jun 21, 2024
1 parent 6f02d11 commit bf2cf64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit bf2cf64

Please sign in to comment.