Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tfhe): add missing overloads #70

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,14 @@
function {f}(euint{i} a, euint{j} b) internal view returns (euint{k}) {{
return euint{k}.wrap(Impl.{f}(euint{i}.unwrap(a), euint{j}.unwrap(b)));
}}

function {f}(euint{i} a, uint{j} b) internal view returns (euint{k}) {{
return euint{k}.wrap(Impl.{f}(euint{i}.unwrap(a), euint{j}.unwrap(asEuint{j}(b))));
}}

function {f}(uint{i} a, euint{j} b) internal view returns (euint{k}) {{
return euint{k}.wrap(Impl.{f}(euint{i}.unwrap(asEuint{i}(a)), euint{j}.unwrap(b)));
}}
"""

to_print_no_scalar_cast_a = """
Expand Down
114 changes: 114 additions & 0 deletions lib/TFHE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,44 @@ library TFHE {
return euint8.wrap(Impl.and(euint8.unwrap(a), euint8.unwrap(b)));
}

function and(euint8 a, uint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.and(euint8.unwrap(a), euint8.unwrap(asEuint8(b))));
}

function and(uint8 a, euint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.and(euint8.unwrap(asEuint8(a)), euint8.unwrap(b)));
}

function or(euint8 a, euint8 b) internal view returns (euint8) {
return euint8.wrap(Impl.or(euint8.unwrap(a), euint8.unwrap(b)));
}

function or(euint8 a, uint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.or(euint8.unwrap(a), euint8.unwrap(asEuint8(b))));
}

function or(uint8 a, euint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.or(euint8.unwrap(asEuint8(a)), euint8.unwrap(b)));
}

function xor(euint8 a, euint8 b) internal view returns (euint8) {
return euint8.wrap(Impl.xor(euint8.unwrap(a), euint8.unwrap(b)));
}

function xor(euint8 a, uint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.xor(euint8.unwrap(a), euint8.unwrap(asEuint8(b))));
}

function xor(uint8 a, euint8 b) internal view returns (euint8) {
return
euint8.wrap(Impl.xor(euint8.unwrap(asEuint8(a)), euint8.unwrap(b)));
}

function shl(euint8 a, euint8 b) internal view returns (euint8) {
return euint8.wrap(Impl.shl(euint8.unwrap(a), euint8.unwrap(b), false));
}
Expand Down Expand Up @@ -1019,14 +1049,56 @@ library TFHE {
return euint16.wrap(Impl.and(euint16.unwrap(a), euint16.unwrap(b)));
}

function and(euint16 a, uint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.and(euint16.unwrap(a), euint16.unwrap(asEuint16(b)))
);
}

function and(uint16 a, euint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.and(euint16.unwrap(asEuint16(a)), euint16.unwrap(b))
);
}

function or(euint16 a, euint16 b) internal view returns (euint16) {
return euint16.wrap(Impl.or(euint16.unwrap(a), euint16.unwrap(b)));
}

function or(euint16 a, uint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.or(euint16.unwrap(a), euint16.unwrap(asEuint16(b)))
);
}

function or(uint16 a, euint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.or(euint16.unwrap(asEuint16(a)), euint16.unwrap(b))
);
}

function xor(euint16 a, euint16 b) internal view returns (euint16) {
return euint16.wrap(Impl.xor(euint16.unwrap(a), euint16.unwrap(b)));
}

function xor(euint16 a, uint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.xor(euint16.unwrap(a), euint16.unwrap(asEuint16(b)))
);
}

function xor(uint16 a, euint16 b) internal view returns (euint16) {
return
euint16.wrap(
Impl.xor(euint16.unwrap(asEuint16(a)), euint16.unwrap(b))
);
}

function shl(euint16 a, euint16 b) internal view returns (euint16) {
return
euint16.wrap(Impl.shl(euint16.unwrap(a), euint16.unwrap(b), false));
Expand Down Expand Up @@ -2014,14 +2086,56 @@ library TFHE {
return euint32.wrap(Impl.and(euint32.unwrap(a), euint32.unwrap(b)));
}

function and(euint32 a, uint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.and(euint32.unwrap(a), euint32.unwrap(asEuint32(b)))
);
}

function and(uint32 a, euint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.and(euint32.unwrap(asEuint32(a)), euint32.unwrap(b))
);
}

function or(euint32 a, euint32 b) internal view returns (euint32) {
return euint32.wrap(Impl.or(euint32.unwrap(a), euint32.unwrap(b)));
}

function or(euint32 a, uint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.or(euint32.unwrap(a), euint32.unwrap(asEuint32(b)))
);
}

function or(uint32 a, euint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.or(euint32.unwrap(asEuint32(a)), euint32.unwrap(b))
);
}

function xor(euint32 a, euint32 b) internal view returns (euint32) {
return euint32.wrap(Impl.xor(euint32.unwrap(a), euint32.unwrap(b)));
}

function xor(euint32 a, uint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.xor(euint32.unwrap(a), euint32.unwrap(asEuint32(b)))
);
}

function xor(uint32 a, euint32 b) internal view returns (euint32) {
return
euint32.wrap(
Impl.xor(euint32.unwrap(asEuint32(a)), euint32.unwrap(b))
);
}

function shl(euint32 a, euint32 b) internal view returns (euint32) {
return
euint32.wrap(Impl.shl(euint32.unwrap(a), euint32.unwrap(b), false));
Expand Down