chore: add re-encrypt#28
Conversation
| decryptedValue, err := tee.DecryptToBigInt(ct.ciphertext) | ||
|
|
||
| if err != nil { | ||
| logger.Error("reencrypt decryption failed", "err", err) | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
How about removing the DecryptToBigInt function and using the following lines?
plaintext, err := tee.Decrypt(ct.ciphertext)
if err != nil {
logger.Error("reencrypt decryption failed", "err", err)
return nil, err
}
decryptedValue := big.NewInt(0).SetBytes(plaintext.Value)| TeeReencrypt: map[tfhe.FheUintType]uint64{ | ||
| tfhe.FheBool: 1000, | ||
| tfhe.FheUint4: 1000, | ||
| tfhe.FheUint8: 1000, | ||
| tfhe.FheUint16: 1100, | ||
| tfhe.FheUint32: 1200, |
There was a problem hiding this comment.
These values are much larger than the ones for other TEE operations.
There was a problem hiding this comment.
Basically copy & pasted code from tfhe reencrypt.
There was a problem hiding this comment.
@amaury1093 Do you have any chance to look into this?
There was a problem hiding this comment.
Agreed. Maybe we can do 100, so 10x cheaper than FHE. In the same order of magniture as a mul
| // Always return a 32-byte big-endian integer. | ||
| ret := make([]byte, 32) | ||
| copy(ret[32-len(plaintext):], plaintext) | ||
|
|
||
| return new(big.Int).SetBytes(ret), nil | ||
| } |
There was a problem hiding this comment.
I think we can just use big.NewInt(0).SetBytes(plaintext) because it gives us the big-endian integer. In a word, we can remove this whole function.
7a06d44 to
2c8138e
Compare
| requiredGasFunction: getCiphertextRequiredGas, | ||
| runFunction: getCiphertextRun, | ||
| }, | ||
| // TEE operations |
There was a problem hiding this comment.
In #31, there has been a refactor to move tee operations into teelib.go. Your new function should go there.
| func newTestEVMEnvironmentWithEthCall() *MockEVMEnvironment { | ||
| mockEVM := newTestEVMEnvironment() | ||
| mockEVM.ethCall = true | ||
| return mockEVM | ||
| } | ||
|
|
There was a problem hiding this comment.
Not sure it's super worth it to create a separate function in a separate file just for one instance.
I would rather add the line mockEVM.ethCall = true inside tee_crypto_test.go
| TeeReencrypt: map[tfhe.FheUintType]uint64{ | ||
| tfhe.FheBool: 1000, | ||
| tfhe.FheUint4: 1000, | ||
| tfhe.FheUint8: 1000, | ||
| tfhe.FheUint16: 1100, | ||
| tfhe.FheUint32: 1200, |
There was a problem hiding this comment.
Agreed. Maybe we can do 100, so 10x cheaper than FHE. In the same order of magniture as a mul
| return nil, err | ||
| } | ||
|
|
||
| // TODO: decide if `res.Signature` should be verified here |
There was a problem hiding this comment.
What is this comment about?
| environment.depth = depth | ||
| addr := common.Address{} | ||
| readOnly := false | ||
| ct, err := importTeePlaintextToEVM(environment, depth, tc.expected, tc.typ) |
There was a problem hiding this comment.
The test doesn't use any pubkey. What is it testing exactly here?
Uh oh!
There was an error while loading. Please reload this page.