google / heir

A compiler for homomorphic encryption
https://heir.dev/
Apache License 2.0
285 stars 40 forks source link

bgv: Add a plaintext type and plaintext-ciphertext ops #100

Closed asraa closed 5 months ago

asraa commented 1 year ago

We need to add a bgv plaintext type:

def Plaintext : BGV_Type<"Plaintext", "plaintext"> {
  let summary = "A type for BGV plaintext";

  let description = [{
    A type for BGV plaintext.
  }];

  let parameters = (ins
    BGVRingAttrArray:$rings,
  );

  let assemblyFormat = "`<` `rings` = $rings `>`";
}

That also likely needs to hold on to plaintext bits. (see https://github.com/google/heir/issues/99)

Which would enable representation of muls, or other ops that can occur between ciphertext and plaintext:

def BGV_MulPlaintextOp : BGV_Op<"mul_plaintext"> {
  let summary = "Multiplication by a plaintext element.";

  let arguments = (ins
    Ciphertext:$x,
    Plaintext:$y
  );

  let results = (outs
    Ciphertext:$output
  );
}

This can even be an input to a trivial encryption.

github-actions[bot] commented 7 months ago

This issue has 1 outstanding TODOs:

This comment was autogenerated by todo-backlinks