Skip to main content

matSHEEP

This library is a programmatic interface in python to generate a circuit for the bigger and more useful SHEEP library.

The library has a few data types :

  • variables - A single bit (Could also be used as a normal scalar)

  • enc_vec - One dimensional bit vector (Could be used a one dimensional vector of any data type)

  • enc_mat - Two dimensional bit matrix (Could be used a one dimensional vector of any data type)

  • enc_tensor3 - Three dimensional bit tensor.

To create a circuit, the basic class to inherit is mini_mod in mathsheep.interactions. To add more components, you can use self.add(component) inside the create function as shown below.:

class oneb_adder(mini_mod):
     def __init__(self, name, inputs, outputs, nb=None,
                     randomize_temps=1, carry=True):
          mini_mod.__init__(self, name, inputs, outputs)
          self.create(...)

     def create(self, ...):
           self.add(..)

Two types of components can be added.

  • Assignments (from matSHEEP.interactions)

    • mono_assign

      • alias

      • negate

    • bi_assign

      • xor

      • and

      • or

      • constand

    • tri_assign

      • mux

  • Other mini_mods

There are a few predefined mini_mods. They can be found in

  • matSHEEP.reusable_modules
    • oneb_adder - Add two bits

    • nb_adder - Adders x and y with incoming carrt where input is [cin x y]

    • nb_adder_xy - Adds x and y with input = (x, y)

    • compare_cp - Compares ciphertext with plaintext with input = (c,p)

  • matSHEEP.functions
    • reduce_add - Counts the number of ones in a bit vector.

  • matSHEEP.nn_layer
    • sign_fn

    • linear_layer_1d - Inner Product of a weight vector with encrypted bit vector followed by a sign function.

    • linear_layer - Inner Product of a weight matrix with an encrypted bit vector followed by a sign function.

    • conv_layer - A convolution Layer. (Look at examples)

  • matSHEEP.vector_ops
    • vec_mono_op_cond - Takes a plaintext cond vector, a plaintext tuple ass_types containing only alias and negate as values and an encrypted bit vector input. It outputs an encrypted bit vector where the ith position has the ass_types[cond[idx]] operation applied on input[idx].

    • Similar operation for matrix and tensor.

You can also visualize the circuits you create. test.sheep is a circuit file.:

import sys
import matSHEEP.create_graph as cg
complete_node = cg.get_circuit_graph('./test.sheep')
ng = cg.networkx_graph(complete_node)
ng.draw()

And you can get

https://raw.githubusercontent.com/amartya18x/matSHEEP/master/images/LL4.png

gFor more high level operations and results using layers of Neural Networks visit this markdown

Metadata

Release files for matSHEEP 1.56

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matSHEEP 1.56
File Size Uploaded
matSHEEP-1.56.tar.gz 164.3 kB Details

Release files / matSHEEP-1.56.tar.gz

Download URL matSHEEP-1.56.tar.gz
Size 164.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8a0b2c41c465abd9df1ec6e0ab2c8651086610813083c1ec57a863088112de39
BLAKE2b-256 checksum
How to use checksums
9a5ad0530d69f0e6ea091bf5d733beae94eb3e39289d473824bba008a400a8d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.56 This release

1 release file

1.55

1 release file

1.54

1 release file

1.53

1 release file

1.52

1 release file

1.51

1 release file

1.6

1 release file

1.5

1 release file

1.4.53

1 release file

1.4.52

1 release file

1.4.51

1 release file

1.4.7

1 release file

1.4.6

1 release file

1.4.5

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.2.0

1 release file

0.1.82

1 release file

0.1.81

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page