diff --git a/Cargo.lock b/Cargo.lock index fb51f811..429b1bca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,7 +197,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" dependencies = [ - "sha2", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -390,7 +390,7 @@ dependencies = [ "curve25519-dalek", "rand_core 0.5.1", "serde", - "sha2", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] @@ -1511,6 +1511,17 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "sha2" +version = "0.8.1" +source = "git+https://github.com/ZcashFoundation/hashes?branch=expose-utils#a968a8db2bffae75fbb31596897be9088ddbb821" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + [[package]] name = "sha2" version = "0.8.1" @@ -2070,7 +2081,7 @@ dependencies = [ "ripemd160", "secp256k1", "serde", - "sha2", + "sha2 0.8.1 (git+https://github.com/ZcashFoundation/hashes?branch=expose-utils)", "thiserror", "x25519-dalek", ] diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index 107fd779..fef5908d 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -17,12 +17,13 @@ lazy_static = "1.4.0" ripemd160 = "0.8.0" secp256k1 = { version = "0.17.2", features = ["serde"] } serde = { version = "1", features = ["serde_derive"] } -sha2 = "0.8" +# sha2 = "0.8" thiserror = "1" x25519-dalek = "0.6" # ZF deps -redjubjub = "0.1" ed25519-zebra = "0.2" +redjubjub = "0.1" +sha2 = {git="https://github.com/ZcashFoundation/hashes", branch = "expose-utils", features=["utils"]} [dev-dependencies] proptest = "0.9" diff --git a/zebra-chain/src/keys/sprout.rs b/zebra-chain/src/keys/sprout.rs index 0740502f..15139c76 100644 --- a/zebra-chain/src/keys/sprout.rs +++ b/zebra-chain/src/keys/sprout.rs @@ -16,14 +16,25 @@ use proptest::{array, collection::vec, prelude::*}; #[cfg(test)] use proptest_derive::Arbitrary; +use sha2::sha256_utils::compress256; + use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}; +/// Our root secret key of the Sprout key derivation tree. +/// /// All other Sprout key types derive from the SpendingKey value. -pub struct SpendingKey; +/// Actually 252 bits. +pub struct SpendingKey(pub [u8; 32]); /// Derived from a _SpendingKey_. pub type ReceivingKey = x25519_dalek::StaticSecret; +impl From for ReceivingKey { + fn from(spending_key: SpendingKey) -> ReceivingKey { + ReceivingKey::from(spending_key.0) + } +} + /// Derived from a _SpendingKey_. #[derive(Copy, Clone, Eq, PartialEq)] pub struct PayingKey(pub [u8; 32]);