ExpandedSpendingKey::proof_generation_key(), visibility tweaks
This commit is contained in:
parent
9ae5a9d624
commit
80db0ae2f9
|
@ -15,7 +15,7 @@ use fpe::ff1::{BinaryNumeralString, FF1};
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
jubjub::{edwards, FixedGenerators, JubjubEngine, JubjubParams, ToUniform, Unknown},
|
jubjub::{edwards, FixedGenerators, JubjubEngine, JubjubParams, ToUniform, Unknown},
|
||||||
primitives::{Diversifier, PaymentAddress, ViewingKey},
|
primitives::{Diversifier, PaymentAddress, ProofGenerationKey, ViewingKey},
|
||||||
};
|
};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use zcash_primitives::JUBJUB;
|
use zcash_primitives::JUBJUB;
|
||||||
|
@ -42,7 +42,7 @@ fn prf_expand_vec(sk: &[u8], ts: &[&[u8]]) -> Blake2bResult {
|
||||||
|
|
||||||
/// An outgoing viewing key
|
/// An outgoing viewing key
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
struct OutgoingViewingKey([u8; 32]);
|
pub struct OutgoingViewingKey([u8; 32]);
|
||||||
|
|
||||||
impl OutgoingViewingKey {
|
impl OutgoingViewingKey {
|
||||||
fn derive_child(&self, i_l: &[u8]) -> Self {
|
fn derive_child(&self, i_l: &[u8]) -> Self {
|
||||||
|
@ -55,15 +55,15 @@ impl OutgoingViewingKey {
|
||||||
/// A Sapling expanded spending key
|
/// A Sapling expanded spending key
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ExpandedSpendingKey<E: JubjubEngine> {
|
pub struct ExpandedSpendingKey<E: JubjubEngine> {
|
||||||
ask: E::Fs,
|
pub ask: E::Fs,
|
||||||
nsk: E::Fs,
|
nsk: E::Fs,
|
||||||
ovk: OutgoingViewingKey,
|
ovk: OutgoingViewingKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Sapling full viewing key
|
/// A Sapling full viewing key
|
||||||
pub struct FullViewingKey<E: JubjubEngine> {
|
pub struct FullViewingKey<E: JubjubEngine> {
|
||||||
vk: ViewingKey<E>,
|
pub vk: ViewingKey<E>,
|
||||||
ovk: OutgoingViewingKey,
|
pub ovk: OutgoingViewingKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: JubjubEngine> ExpandedSpendingKey<E> {
|
impl<E: JubjubEngine> ExpandedSpendingKey<E> {
|
||||||
|
@ -76,6 +76,15 @@ impl<E: JubjubEngine> ExpandedSpendingKey<E> {
|
||||||
ExpandedSpendingKey { ask, nsk, ovk }
|
ExpandedSpendingKey { ask, nsk, ovk }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn proof_generation_key(&self, params: &E::Params) -> ProofGenerationKey<E> {
|
||||||
|
ProofGenerationKey {
|
||||||
|
ak: params
|
||||||
|
.generator(FixedGenerators::SpendingKeyGenerator)
|
||||||
|
.mul(self.ask, params),
|
||||||
|
nsk: self.nsk,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn derive_child(&self, i_l: &[u8]) -> Self {
|
fn derive_child(&self, i_l: &[u8]) -> Self {
|
||||||
let mut ask = E::Fs::to_uniform(prf_expand(i_l, &[0x13]).as_bytes());
|
let mut ask = E::Fs::to_uniform(prf_expand(i_l, &[0x13]).as_bytes());
|
||||||
let mut nsk = E::Fs::to_uniform(prf_expand(i_l, &[0x14]).as_bytes());
|
let mut nsk = E::Fs::to_uniform(prf_expand(i_l, &[0x14]).as_bytes());
|
||||||
|
|
Loading…
Reference in New Issue