-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cast/decrypt and hardcoded keys #12
Conversation
9af0095
to
24df344
Compare
@@ -18,7 +18,7 @@ package fhevm | |||
|
|||
/* | |||
#cgo CFLAGS: -O3 -I../tfhe-rs/target/release | |||
#cgo LDFLAGS: -L../tfhe-rs/target/release -l:libtfhe.a -lm | |||
#cgo LDFLAGS: -L../tfhe-rs/target/release -ltfhe -lm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use #ifdef
directive to conditionally link dynamically on mac only
#cgo LDFLAGS: -L../tfhe-rs/target/release -ltfhe -lm | |
// FIXME: link statically on mac as well | |
#ifdef __APPLE__ | |
#cgo LDFLAGS: -L../tfhe-rs/target/release -ltfhe -lm | |
#else | |
#cgo LDFLAGS: -L../tfhe-rs/target/release -l:libtfhe.a -lm | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it locally, and it doesn't seem to work. The #ifdef isn't evaluated to get those flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like cgo doesn't support ifdefs https://groups.google.com/g/golang-nuts/c/xNFNfPCej70/m/Y7nZGF4lXAUJ?pli=1
fhevm/test-fhevm-keys/sks
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the sks is relatively big, would it make sense to provide a script or something else to generate the keys on-demand?
var pksHash common.Hash | ||
var networkKeysDir string | ||
var usersKeysDir string | ||
|
||
//go:embed test-fhevm-keys/sks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, clever!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, what would it do if the file doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If file doesn't exist it is compile time error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good. We need to remove the decryption stuff, because we can't support it in the way it works at Evmos.
// If there are optimistic requires, check them by doing bitwise AND on all of them. | ||
// That works, because we assume their values are either 0 or 1. If there is at least | ||
// one 0, the result will be 0 (false). | ||
func evaluateRemainingOptimisticRequires(environment EVMEnvironment) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will have to be removed, because we won't support decryptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we can't have decryptions in non-view functions, we can't have optimistic requires too in non-views. Wondering if we should keep optimistic requires in view functions, though. And how useful they would be.
@@ -159,3 +222,131 @@ func fheAddRun(environment *EVMEnvironment, caller common.Address, addr common.A | |||
return resultHash[:], nil | |||
} | |||
} | |||
|
|||
func decryptRun(environment EVMEnvironment, caller common.Address, addr common.Address, input []byte, readOnly bool) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will have to be removed, because we won't support decryptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spoke too early. We need to disable decryptions in non-view functions. For views, it is fine to leave them.
Implement cast/decrypt
Also, hardcodes the keys in our library (We'll load them in the future from interface)
This should be sufficient to run add operator tests.