A Fully Homomorphic String library written in Rust using Zama's tfhe-rs.
The binary given is not meant for production use but rather a proof of concept on how a FHE String library would work. The program takes as cli arguments the string, pattern, n, from and to and runs all supported algorithms and compares their results with the standard string library in Rust. It outputs the time it took as well as if the results match.
The supported string functions are the following:
contains
with clear / encrypted patternends_with
with clear pattern / encrypted patterneq_ignore_case
find
with clear pattern / encrypted patternis_empty
len
repeat
with clear / encrypted number of repetitionsreplace
with clear pattern / encrypted patternreplacen
with clear pattern / encrypted patternrfind
with clear pattern / encrypted patternrsplit
with clear pattern / encrypted patternrsplit_once
with clear pattern / encrypted patternrsplitn
with clear pattern / encrypted patternrsplit_terminator
with clear pattern / encrypted patternsplit
with clear pattern / encrypted patternsplit_ascii_whitespace
split_inclusive
with clear pattern / encrypted patternsplit_terminator
with clear pattern / encrypted patternsplitn
with clear pattern / encrypted patternstarts_with
with clear pattern / encrypted patternstrip_prefix
with clear pattern / encrypted patternstrip_suffix
with clear pattern / encrypted patternto_lowercase
to_uppercase
trim
trim_end
trim_start
+
(concatenation)- Comparisons between strings
>=
,<=
,!=
,==
cargo b --release
$ fhestring --string "hello" --pattern "ello" --n 1 --from "ello" --to "_llo"
$ fhestring --help
Finished release [optimized] target(s) in 0.08s
Running `target/release/fhestring --help`
A FHE string implementation using tfhe-rs
Usage: fhestring --string <STRING> --pattern <PATTERN> --n <N> --from <FROM> --to <TO>
Options:
-s, --string <STRING> The string to do the processing on
-p, --pattern <PATTERN> The pattern for the algoritmhs that need it
-n, --n <N> The number of times to make an operation for the algoritmhs that need it
-f, --from <FROM> What will be replaced (for replace algorithms)
-t, --to <TO> What will replace it (for replace algorithms)
-h, --help Print help
-V, --version Print version