Skip to content

Commit

Permalink
Simplifying the hash interface; wrap up Poseidon.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaker committed Jan 30, 2024
1 parent 8ada768 commit 5825dac
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 333 deletions.
104 changes: 10 additions & 94 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ log = "0.4.20"
# optional dependencies
ark-ff = {version="0.4.0", optional=true}
ark-ec = {version="0.4.0", optional=true}
ark-serialize = {version="0.4.2", optional=true}
ark-crypto-primitives = {version="0.4.0", optional=true}
ark-serialize = {version="0.4.2", optional=true, features=["std"]}
curve25519-dalek = {version="4.0.0", optional=true, features=["group"]}
# anemoi = {git = "https://github.com/anemoi-hash/anemoi-rust", optional=true}
group = {version="0.13.0", optional=true}
ark-bls12-381 = {version="0.4.0", optional=true}

[features]
default = []
ark = ["dep:ark-ff", "dep:ark-ec", "dep:ark-serialize", "dep:ark-crypto-primitives", "dep:ark-bls12-381"]
ark = ["dep:ark-ff", "dep:ark-ec", "dep:ark-serialize", "dep:ark-bls12-381"]
group = ["dep:group", "dep:curve25519-dalek"]
# anemoi = ["dep:anemoi"]

Expand Down
103 changes: 0 additions & 103 deletions src/hash/anemoi.rs

This file was deleted.

29 changes: 29 additions & 0 deletions src/hash/index.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
macro_rules! impl_index {
($idx: ty, $struct: ident, $i: tt, Output = $output: ty, Params = [$($type:ident : $trait:ident),*], Constants = $($constgen:ident),*) => {
impl<$($type: $trait,)* $(const $constgen: usize,)*> core::ops::Index<$idx> for $struct<$($type,)* $($constgen,)*> {
type Output = $output;

fn index(&self, index: $idx) -> &Self::Output {
&self.$i[index]
}
}

impl<$($type: $trait,)* $(const $constgen: usize,)*> core::ops::IndexMut<$idx> for $struct<$($type,)* $($constgen,)*> {

fn index_mut(&mut self, index: $idx) -> &mut Self::Output {
&mut self.$i[index]
}
}
};
}

macro_rules! impl_indexing {
($struct: ident, $field: tt, Output = $output: ty, Params = [$($type:ident : $trait:ident),*], Constants = [$($constgen:ident),*]) => {
crate::hash::index::impl_index!(usize, $struct, $field, Output = $output, Params = [$($type : $trait),*], Constants = $($constgen),*);
crate::hash::index::impl_index!(core::ops::RangeTo<usize>, $struct, $field, Output = [$output], Params = [$($type : $trait),*], Constants = $($constgen),*);
crate::hash::index::impl_index!(core::ops::Range<usize>, $struct, $field, Output = [$output], Params = [$($type : $trait),*], Constants = $($constgen),*);
crate::hash::index::impl_index!(core::ops::RangeFrom<usize>, $struct, $field, Output = [$output], Params = [$($type : $trait),*], Constants = $($constgen),*);
}
}

pub(crate) use {impl_index, impl_indexing};
Loading

0 comments on commit 5825dac

Please sign in to comment.