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" ]
|
rustdoc-args = [ "--html-in-header", "katex-header.html" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
aes = "0.6"
|
||||||
blake2b_simd = "0.5"
|
blake2b_simd = "0.5"
|
||||||
ff = "0.9"
|
ff = "0.9"
|
||||||
|
fpe = "0.4"
|
||||||
group = "0.9"
|
group = "0.9"
|
||||||
halo2 = { git = "https://github.com/zcash/halo2.git", branch = "main" }
|
halo2 = { git = "https://github.com/zcash/halo2.git", branch = "main" }
|
||||||
nonempty = "0.6"
|
nonempty = "0.6"
|
||||||
|
|
10
src/keys.rs
10
src/keys.rs
|
@ -3,6 +3,8 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
use aes::Aes256;
|
||||||
|
use fpe::ff1::{BinaryNumeralString, FF1};
|
||||||
use group::GroupEncoding;
|
use group::GroupEncoding;
|
||||||
use halo2::{arithmetic::FieldExt, pasta::pallas};
|
use halo2::{arithmetic::FieldExt, pasta::pallas};
|
||||||
use subtle::CtOption;
|
use subtle::CtOption;
|
||||||
|
@ -176,8 +178,12 @@ impl DiversifierKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the diversifier at the given index.
|
/// Returns the diversifier at the given index.
|
||||||
pub fn get(&self, _: impl Into<DiversifierIndex>) -> Diversifier {
|
pub fn get(&self, j: impl Into<DiversifierIndex>) -> Diversifier {
|
||||||
todo!()
|
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