Skip to content

Commit 5c811e8

Browse files
committed
Move Sinsemilla primitive impl into sinsemilla crate
1 parent 7df93fd commit 5c811e8

File tree

8 files changed

+25
-14729
lines changed

8 files changed

+25
-14729
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

halo2_gadgets/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ lazy_static = "1"
3131
pasta_curves = "0.5"
3232
proptest = { version = "1.0.0", optional = true }
3333
rand = "0.8"
34+
sinsemilla = { git = "https://github.com/zcash/sinsemilla.git", rev = "1a68e4ab13285729f644e72335325c9b4d6d469b" }
3435
subtle = "2.3"
3536
uint = "0.9.2" # MSRV 1.56.1
3637

@@ -40,6 +41,7 @@ plotters = { version = "0.3.0", default-features = false, optional = true }
4041
[dev-dependencies]
4142
criterion = "0.3"
4243
proptest = "1.0.0"
44+
sinsemilla = { git = "https://github.com/zcash/sinsemilla.git", rev = "1a68e4ab13285729f644e72335325c9b4d6d469b", features = ["test-dependencies"] }
4345

4446
[target.'cfg(unix)'.dev-dependencies]
4547
inferno = ">=0.11, <0.11.5" # MSRV 1.59
@@ -56,7 +58,10 @@ test-dev-graph = [
5658
"plotters/bitmap_encoder",
5759
"plotters/ttf",
5860
]
59-
test-dependencies = ["proptest"]
61+
test-dependencies = [
62+
"proptest",
63+
"sinsemilla/test-dependencies",
64+
]
6065

6166
# In-development features
6267
# See https://zcash.github.io/halo2/dev/features.html

halo2_gadgets/src/sinsemilla.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use std::fmt::Debug;
1616
pub mod chip;
1717
pub mod merkle;
1818
mod message;
19-
pub mod primitives;
19+
20+
pub use ::sinsemilla as primitives;
2021

2122
/// The set of circuit instructions required to use the [`Sinsemilla`](https://zcash.github.io/halo2/design/gadgets/sinsemilla.html) gadget.
2223
/// This trait is bounded on two constant parameters: `K`, the number of bits

halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ where
147147
.collect();
148148

149149
let hasher_S = pallas::Point::hash_to_curve(S_PERSONALIZATION);
150-
let S = |chunk: &[bool]| hasher_S(&lebs2ip_k(chunk).to_le_bytes());
150+
let S = |chunk: &[bool]| {
151+
hasher_S(
152+
&lebs2ip_k(chunk.try_into().expect("correct length")).to_le_bytes(),
153+
)
154+
};
151155

152156
// We can use complete addition here because it differs from
153157
// incomplete addition with negligible probability.
@@ -249,6 +253,7 @@ where
249253
let words: Value<Vec<u32>> = bitstring.map(|bitstring| {
250254
bitstring
251255
.chunks_exact(sinsemilla::K)
256+
.map(|chunk| chunk.try_into().expect("correct length"))
252257
.map(lebs2ip_k)
253258
.collect()
254259
});

halo2_gadgets/src/sinsemilla/merkle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ pub mod tests {
322322
(sibling, &node)
323323
};
324324

325-
use crate::sinsemilla::primitives as sinsemilla;
326325
let merkle_crh =
327326
sinsemilla::HashDomain::from_Q(TestHashDomain.Q().into());
328327

0 commit comments

Comments
 (0)