encryptogroup / ABY

ABY - A Framework for Efficient Mixed-protocol Secure Two-party Computation
GNU Lesser General Public License v3.0
463 stars 132 forks source link

Does ABY support real numbers? #22

Closed xiaolixiaoyi closed 3 years ago

xiaolixiaoyi commented 7 years ago

I want to test the performance of addition and multiplication of real numbers in ABY. Is there built-in types for fixed-point or floating-point numbers in ABY? Does ABY support right shift or left shift operations for sharings?

dd23 commented 7 years ago

ABY does support the following operations on floating-point numbers of different precisions using BooleanCircuit::PutFPGate(): ADD, MUL, SUB, DIV, SIN, SQRT, EXP, EXP2, CMP, LN, LOG2, COS, SQR (as defined here)

There are some shift operations available for Boolean Circuits:

Hope that helps. Let me know if you have further questions.

haik commented 7 years ago

@dd23 I guess the main difference lies in the declaration of operands and I tried to modify them. But I always encountered such problems as no member named PutFPGate, expects argument of type, but argument has type. I was wondering if you could give me some example?

williamclot commented 5 years ago

Would be great to have a example with a SQRT!

dd23 commented 5 years ago

There is an example for using floating-point gates: https://github.com/encryptogroup/ABY/blob/public/src/examples/float/abyfloat.cpp

I have just extended it in b21faaf81c99a3b08a41ff558726da03fb6a8b48 and added an example for SQRT as well. Hope this helps.

williamclot commented 5 years ago

Cheers! Thank you very much.

williamclot commented 5 years ago

I've been working with FPGates on the latest b21faaf commit. Would it be possible to have a different path to the circ folder then "../../bin/circ". Maybe putting it as variable somewhere?

dd23 commented 5 years ago

Took some time, but since ede04f84158900831a020832bde91168852b6b63 it's now possible to specify the path to the circuits at runtime by passing it to the ABYParty constructor, e.g., like in the float example.

The default is still "../../bin/circ" so the old examples and the current directory structure of the repo keeps on working.

ShivamBansal99 commented 4 years ago

Is there an example with an EXP FP gate? Or is there any way to view the intermediate float values in the shares for debugging?

dd23 commented 3 years ago

There is currently no example for the EXP FP gate, but if you submit a pull request, we can include it in the repo.