diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-01-09 14:43:31 +0200 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-01-09 14:43:31 +0200 |
| commit | c5cc00e84ab366b57c80ed7804c398ea7ecefc98 (patch) | |
| tree | f9172d00918c4f52fa2b19f97b3dab0a8747e0bf /guests | |
| parent | 0d400d4c400928af565cb8de39556a2170846da1 (diff) | |
| download | zkVMs-benchmarks-c5cc00e84ab366b57c80ed7804c398ea7ecefc98.tar zkVMs-benchmarks-c5cc00e84ab366b57c80ed7804c398ea7ecefc98.tar.gz zkVMs-benchmarks-c5cc00e84ab366b57c80ed7804c398ea7ecefc98.zip | |
feat(guests): Add graph_coloring program
Diffstat (limited to 'guests')
| -rw-r--r-- | guests/graph_coloring/Cargo.toml | 7 | ||||
| -rw-r--r-- | guests/graph_coloring/src/lib.rs | 28 |
2 files changed, 35 insertions, 0 deletions
diff --git a/guests/graph_coloring/Cargo.toml b/guests/graph_coloring/Cargo.toml new file mode 100644 index 0000000..180ec35 --- /dev/null +++ b/guests/graph_coloring/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "zkp" +version = "0.1.0" +edition = "2021" + +[dependencies] +guests_macro = { version = "0.1.0", path = "../../guests_macro" } diff --git a/guests/graph_coloring/src/lib.rs b/guests/graph_coloring/src/lib.rs new file mode 100644 index 0000000..2feef7f --- /dev/null +++ b/guests/graph_coloring/src/lib.rs @@ -0,0 +1,28 @@ +const VERTICES: usize = 010; + +#[guests_macro::proving_entrypoint] +pub fn start( + graph: Vec<Vec<bool>>, + colors: u32, + coloring: Vec<Vec<u32>>, +) -> bool { + // Does it use the correct amount of colors? + let mut max_color = coloring[0][1]; + for nc in &coloring { + if nc[1] > max_color { + max_color = nc[1]; + } + } + + let mut ret = max_color + 1 == colors; + + // Is coloring correct? + for i in 0..VERTICES { + for j in 0..VERTICES { + // graph[i][j] -> coloring[i] != coloring[j] + ret = ret & (! graph[i][j] | (coloring[i][1] != coloring[j][1])); + } + } + + ret +} |
