14.8. Rotate

Rotate nodes have 3 modes of operation, an encryptor, decryptor, or rotator. Rotate.forward() can, depending on configuration, transform data plaintext->cyphertext, cyphertext->cyphertext, cyphertext->plaintext, plaintext->plaintext. Rotate always keeps the original data shape, but can change which axis is encrypted. For instance a single cyphertext of shape (10,32,32) can come out as a list of (10,) cyphertexts of shape (32,32).

  • node provider/ encryptor non-configured: input will be converted to plaintext, thus cyphertext->plaintext, and plaintext->plaintext mode

  • node provider/ encryptor configured: input will be encrypted with new keys based on given axis, thus plaintext->cyphertext, cyphertext->cyphertext2

This node can thus be used as a replacement for both encrypt and decrypt nodes. The only caveat being those nodes being more specialised give you slightly more warnings. For instance if an encryption node if left unconfigured it makes sense to warn you that it will be operating in plaintext. However if this node is left unconfigured it may be the case that you want it to be a decryption node, thus we don’t warn you.

14.8.1. Rotate API

Generic cyphertext key rotation as abstract node.

class fhez.nn.operations.rotate.Rotate(axis=None, encryptor=None, provider=None, sum_axis=None, flatten=None, **kwargs)

Generic cyphertext key rotation abstraction.

property axis

Get axis of key rotation.

backward(gradient)

Pass gradients back unmodified.

property cost

Return no depth/ cost/ 0 of encryption.

property encryptor

Encryption parameterised object.

property flatten

Get if intermediary should be flattened to 1D flag.

forward(x)

Rotate keys using encryption provider on desired axis.

This function has 3 modes:

  • Encryptor: given some provider or encryptor will encrypt x and return the cyphertext or list of cyphertexts (if axis is not 0)

  • Decryptor: given neither provider nor encryptor will just turn x into a numpy array, which for our numpyapi implementation means turning cyphertexts into plaintexts and plaintexts stay plaintexts

  • Rotator: given a cyphertext-x and a provider or encryptor will decrypt x and re-encrypt using the new provider on the desired axis.

property parameters

Get parameters to for the encryption provider.

property provider

Get encryption provider to be parameterised for encryption.

property sum_axis

Get the desired axis to be summed between rotation.

update()

Do nothing as encryption has no deep-learning parameterisation.

updates()

Do nothing as encryption has no deep-learning parameterisation.