Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

feat(acvm): Directive for sorting networks #77

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
some comments
guipublic committed Feb 7, 2023
commit dc04e89f7c4a147800e2f021291519fefca85ab8
2 changes: 1 addition & 1 deletion acir/src/circuit/directives.rs
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ pub enum Directive {
},

// Sort directive, using a sorting network
// This directive is used to generate the values of the control bits for the sorting network such that its outputs are properly sorted accroding to sort_by
// This directive is used to generate the values of the control bits for the sorting network such that its outputs are properly sorted according to sort_by
PermutationSort {
inputs: Vec<Vec<Expression>>, // Array of tuples to sort
tuple: u32, // tuple size; if 1 then inputs is a single array [a0,a1,..], if 2 then inputs=[(a0,b0),..] is [a0,b0,a1,b1,..], etc..
2 changes: 2 additions & 0 deletions acvm/src/pwg/sorting.rs
Original file line number Diff line number Diff line change
@@ -157,6 +157,7 @@ impl SortingNetwork {
}

// Computes the control bits of the sorting network which transform inputs into outputs
// implementation is based on https://www.mdpi.com/2227-7080/10/1/16
pub fn route(inputs: Vec<FieldElement>, outputs: Vec<FieldElement>) -> Vec<bool> {
assert_eq!(inputs.len(), outputs.len());
match inputs.len() {
@@ -292,6 +293,7 @@ mod test {
result
}

// returns the number of switches in the network
pub fn switch_nb(n: usize) -> usize {
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
let mut s = 0;
for i in 0..n {