Skip to content

Commit

Permalink
Merge pull request ethereum#12 from zama-ai/petar/separate-proof-in-v…
Browse files Browse the repository at this point in the history
…erify

Separate proof from input in verifyCiphertext()
  • Loading branch information
dartdart26 authored Dec 15, 2022
2 parents d72105f + 287b056 commit 46ed19c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,17 @@ func (e *verifyCiphertext) RequiredGas(input []byte) uint64 {
}

func (e *verifyCiphertext) Run(accessibleState PrecompileAccessibleState, caller common.Address, addr common.Address, input []byte, readOnly bool) (ret []byte, err error) {
const MinInputSize = 65544
if len(input) < MinInputSize {
return nil, errors.New("invalid input")
}

// TODO: treat the first `MinInputSize` as ciphertext.
ciphertext := input[0:MinInputSize]

// TODO: Accept a proof from `input` too
ctHash := crypto.Keccak256Hash(input)
accessibleState.Interpreter().verifiedCiphertexts[ctHash] = &verifiedCiphertext{accessibleState.Interpreter().evm.depth, input}
ctHash := crypto.Keccak256Hash(ciphertext)
accessibleState.Interpreter().verifiedCiphertexts[ctHash] = &verifiedCiphertext{accessibleState.Interpreter().evm.depth, ciphertext}
return ctHash.Bytes(), nil
}

Expand Down

0 comments on commit 46ed19c

Please sign in to comment.