Skip to content
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 fheLib precompile with first fheAdd method #160

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

david-zk
Copy link
Contributor

Fhe library precompiled, only with one method now.

I reuse code of current precompiles and just pass subslice of the previous solidity abi call convention to the existing precompile so everything works.

@tremblaythibaultl @dartdart26

case 0xf953e427:
bwCompatBytes := input[4:minInt(69, len(input))]
// state of fheAdd struct is never needed or accessed so we use nil
return (*fheAdd)(nil).Run(accessibleState, caller, addr, bwCompatBytes, readOnly)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't know about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is static dispatch so in theory should be faster

isScalarByte = 0
}
ret = append(ret, isScalarByte)
// padding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like

padding = make([]byte, 31)
ret = append(ret, padding...)

be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tremblaythibaultl yeah, we could do that, I was just paranoid about extra allocation for padding array but I hope compiler is smart enough these days to detect this. I added this to dfc0040 commit, padding is allocated only once as static variable.

Copy link
Contributor

@tremblaythibaultl tremblaythibaultl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@david-zk david-zk merged commit 8800c42 into 1.10.19-zama Sep 12, 2023
1 check passed
@david-zk david-zk deleted the feature/fhe-lib branch September 12, 2023 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants