Class NativeHEHelper
java.lang.Object
org.apache.sysds.runtime.controlprogram.paramserv.NativeHEHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]accumulateCiphertexts(long server, byte[][] ciphertexts) accumulates the given ciphertexts into a sum ciphertext and returns itstatic byte[]aggregatePartialPublicKeys(long server, byte[][] partial_public_keys) accumulates the given partial public keys into a public key, stores it in server and returns itstatic double[]average(long server, byte[] encrypted_sum, byte[][] partial_plaintexts) averages the partial decryptions and returns the resultstatic byte[]encrypt(long client, double[] plaintexts) encrypts data with public key stored in client setPublicKey() must have been called before calling thisstatic byte[]generateA(long server) this generates the a constant.static byte[]generatePartialPublicKey(long client) generates a partial public key stores a partial private key corresponding to the partial public key in clientstatic longinitClient(byte[] a) generates a Client objectstatic booleanstatic longgenerates the Server object and returns a pointer to itstatic byte[]partiallyDecrypt(long client, byte[] ciphertext) partially decrypts ciphertexts with the partial private key.static voidsetPublicKey(long client, byte[] public_key) sets the public key and stores it in client
-
Constructor Details
-
NativeHEHelper
public NativeHEHelper()
-
-
Method Details
-
initialize
public static boolean initialize() -
initClient
public static long initClient(byte[] a) generates a Client object- Parameters:
a- a constant generated by generateA- Returns:
- a pointer to the native client object
-
generatePartialPublicKey
public static byte[] generatePartialPublicKey(long client) generates a partial public key stores a partial private key corresponding to the partial public key in client- Parameters:
client- A pointer to a Client, obtained from initClient- Returns:
- a serialized partial public key
-
setPublicKey
public static void setPublicKey(long client, byte[] public_key) sets the public key and stores it in client- Parameters:
client- A pointer to a Client, obtained from initClientpublic_key- serialized public key obtained from generatePartialPublicKey
-
encrypt
public static byte[] encrypt(long client, double[] plaintexts) encrypts data with public key stored in client setPublicKey() must have been called before calling this- Parameters:
client- A pointer to a Client, obtained from initClientplaintexts- array of double values to be encrypted- Returns:
- serialized ciphertext
-
partiallyDecrypt
public static byte[] partiallyDecrypt(long client, byte[] ciphertext) partially decrypts ciphertexts with the partial private key. generatePartialPublicKey() must have been called before calling this function- Parameters:
client- A pointer to a Client, obtained from initClientciphertext- serialized ciphertext- Returns:
- serialized partial decryption
-
initServer
public static long initServer()generates the Server object and returns a pointer to it- Returns:
- pointer to a native Server object
-
generateA
public static byte[] generateA(long server) this generates the a constant. in a future version we want to generate this together with the clients to prevent misuse- Parameters:
server- A pointer to a Server, obtained from initServer- Returns:
- serialized a constant
-
aggregatePartialPublicKeys
public static byte[] aggregatePartialPublicKeys(long server, byte[][] partial_public_keys) accumulates the given partial public keys into a public key, stores it in server and returns it- Parameters:
server- A pointer to a Server, obtained from initServerpartial_public_keys- array of serialized partial public keys- Returns:
- serialized partial public key
-
accumulateCiphertexts
public static byte[] accumulateCiphertexts(long server, byte[][] ciphertexts) accumulates the given ciphertexts into a sum ciphertext and returns it- Parameters:
server- A pointer to a Server, obtained from initServerciphertexts- array of serialized ciphertexts- Returns:
- serialized accumulated ciphertext
-
average
public static double[] average(long server, byte[] encrypted_sum, byte[][] partial_plaintexts) averages the partial decryptions and returns the result- Parameters:
server- A pointer to a Server, obtained from initServerencrypted_sum- the result of accumulateCiphertexts()partial_plaintexts- the result of partiallyDecrypt of each ciphertext fed into accumulateCiphertexts- Returns:
- average of original data
-