mirror of https://github.com/zcash/orchard.git
Implement ZIP 32 diversifier derivation
This commit is contained in:
parent
f0779792bc
commit
ceac39d74e
|
@ -19,8 +19,10 @@ publish = false
|
|||
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
|
||||
|
||||
[dependencies]
|
||||
aes = "0.6"
|
||||
blake2b_simd = "0.5"
|
||||
ff = "0.9"
|
||||
fpe = "0.4"
|
||||
group = "0.9"
|
||||
halo2 = { git = "https://github.com/zcash/halo2.git", branch = "main" }
|
||||
nonempty = "0.6"
|
||||
|
|
10
src/keys.rs
10
src/keys.rs
|
@ -3,6 +3,8 @@
|
|||
use std::convert::TryInto;
|
||||
use std::mem;
|
||||
|
||||
use aes::Aes256;
|
||||
use fpe::ff1::{BinaryNumeralString, FF1};
|
||||
use group::GroupEncoding;
|
||||
use halo2::{arithmetic::FieldExt, pasta::pallas};
|
||||
use subtle::CtOption;
|
||||
|
@ -176,8 +178,12 @@ impl DiversifierKey {
|
|||
}
|
||||
|
||||
/// Returns the diversifier at the given index.
|
||||
pub fn get(&self, _: impl Into<DiversifierIndex>) -> Diversifier {
|
||||
todo!()
|
||||
pub fn get(&self, j: impl Into<DiversifierIndex>) -> Diversifier {
|
||||
let ff = FF1::<Aes256>::new(&self.0, 2).expect("valid radix");
|
||||
let enc = ff
|
||||
.encrypt(&[], &BinaryNumeralString::from_bytes_le(&j.into().0[..]))
|
||||
.unwrap();
|
||||
Diversifier(enc.to_bytes_le().try_into().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue