Merge pull request #1264 from nuttycom/orchard_rho
zcash_client_sqlite: Update to make use of `orchard::note::Rho`
This commit is contained in:
commit
a788fc9318
|
@ -1476,8 +1476,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orchard"
|
name = "orchard"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/zcash/orchard?rev=e74879dd0ad0918f4ffe0826e03905cd819981bd#e74879dd0ad0918f4ffe0826e03905cd819981bd"
|
||||||
checksum = "1fb255c3ffdccd3c84fe9ebed72aef64fdc72e6a3e4180dd411002d47abaad42"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"bitvec",
|
"bitvec",
|
||||||
|
|
|
@ -120,3 +120,6 @@ zip32 = "0.1"
|
||||||
lto = true
|
lto = true
|
||||||
panic = 'abort'
|
panic = 'abort'
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
orchard = { git = "https://github.com/zcash/orchard", rev = "e74879dd0ad0918f4ffe0826e03905cd819981bd" }
|
||||||
|
|
|
@ -185,7 +185,7 @@ pub fn decrypt_transaction<'a, P: consensus::Parameters, AccountId: Copy>(
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.flat_map(move |(index, action)| {
|
.flat_map(move |(index, action)| {
|
||||||
let domain = OrchardDomain::for_nullifier(*action.nullifier());
|
let domain = OrchardDomain::for_action(action);
|
||||||
let account = account;
|
let account = account;
|
||||||
try_note_decryption(&domain, &ivk_external, action)
|
try_note_decryption(&domain, &ivk_external, action)
|
||||||
.map(|ret| (ret, TransferType::Incoming))
|
.map(|ret| (ret, TransferType::Incoming))
|
||||||
|
|
|
@ -624,7 +624,7 @@ where
|
||||||
self.orchard.add_outputs(
|
self.orchard.add_outputs(
|
||||||
block_hash,
|
block_hash,
|
||||||
txid,
|
txid,
|
||||||
|action| OrchardDomain::for_nullifier(action.nullifier()),
|
|action| OrchardDomain::for_compact_action(action),
|
||||||
&tx.actions
|
&tx.actions
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -888,7 +888,7 @@ where
|
||||||
index: i,
|
index: i,
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
Ok((OrchardDomain::for_nullifier(action.nullifier()), action))
|
Ok((OrchardDomain::for_compact_action(&action), action))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?,
|
.collect::<Result<Vec<_>, _>>()?,
|
||||||
batch_runners
|
batch_runners
|
||||||
|
|
|
@ -77,7 +77,6 @@ use super::BlockDb;
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
use {
|
use {
|
||||||
group::ff::{Field, PrimeField},
|
group::ff::{Field, PrimeField},
|
||||||
orchard::note_encryption::{OrchardDomain, OrchardNoteEncryption},
|
|
||||||
pasta_curves::pallas,
|
pasta_curves::pallas,
|
||||||
zcash_client_backend::proto::compact_formats::CompactOrchardAction,
|
zcash_client_backend::proto::compact_formats::CompactOrchardAction,
|
||||||
};
|
};
|
||||||
|
@ -1095,40 +1094,28 @@ fn compact_sapling_output<P: consensus::Parameters, R: RngCore + CryptoRng>(
|
||||||
/// Returns the `CompactOrchardAction` and the new note.
|
/// Returns the `CompactOrchardAction` and the new note.
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
fn compact_orchard_action<R: RngCore + CryptoRng>(
|
fn compact_orchard_action<R: RngCore + CryptoRng>(
|
||||||
nullifier: orchard::note::Nullifier,
|
nf_old: orchard::note::Nullifier,
|
||||||
recipient: orchard::Address,
|
recipient: orchard::Address,
|
||||||
value: NonNegativeAmount,
|
value: NonNegativeAmount,
|
||||||
ovk: Option<orchard::keys::OutgoingViewingKey>,
|
ovk: Option<orchard::keys::OutgoingViewingKey>,
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
) -> (CompactOrchardAction, orchard::Note) {
|
) -> (CompactOrchardAction, orchard::Note) {
|
||||||
let rseed = {
|
use zcash_note_encryption::ShieldedOutput;
|
||||||
loop {
|
|
||||||
let mut bytes = [0; 32];
|
let (compact_action, note) = orchard::note_encryption::testing::fake_compact_action(
|
||||||
rng.fill_bytes(&mut bytes);
|
rng,
|
||||||
let rseed = orchard::note::RandomSeed::from_bytes(bytes, &nullifier);
|
nf_old,
|
||||||
if rseed.is_some().into() {
|
|
||||||
break rseed.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let note = orchard::Note::from_parts(
|
|
||||||
recipient,
|
recipient,
|
||||||
orchard::value::NoteValue::from_raw(value.into_u64()),
|
orchard::value::NoteValue::from_raw(value.into_u64()),
|
||||||
nullifier,
|
ovk,
|
||||||
rseed,
|
);
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let encryptor = OrchardNoteEncryption::new(ovk, note, *MemoBytes::empty().as_array());
|
|
||||||
let cmx = orchard::note::ExtractedNoteCommitment::from(note.commitment());
|
|
||||||
let ephemeral_key = OrchardDomain::epk_bytes(encryptor.epk()).0.to_vec();
|
|
||||||
let enc_ciphertext = encryptor.encrypt_note_plaintext();
|
|
||||||
|
|
||||||
(
|
(
|
||||||
CompactOrchardAction {
|
CompactOrchardAction {
|
||||||
nullifier: nullifier.to_bytes().to_vec(),
|
nullifier: compact_action.nullifier().to_bytes().to_vec(),
|
||||||
cmx: cmx.to_bytes().to_vec(),
|
cmx: compact_action.cmx().to_bytes().to_vec(),
|
||||||
ephemeral_key,
|
ephemeral_key: compact_action.ephemeral_key().0.to_vec(),
|
||||||
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
ciphertext: compact_action.enc_ciphertext().as_ref()[..52].to_vec(),
|
||||||
},
|
},
|
||||||
note,
|
note,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use incrementalmerkletree::Position;
|
use incrementalmerkletree::Position;
|
||||||
use orchard::{
|
use orchard::{
|
||||||
keys::Diversifier,
|
keys::Diversifier,
|
||||||
note::{Note, Nullifier, RandomSeed},
|
note::{Note, Nullifier, RandomSeed, Rho},
|
||||||
};
|
};
|
||||||
use rusqlite::{named_params, params, Connection, Row};
|
use rusqlite::{named_params, params, Connection, Row};
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ fn to_spendable_note<P: consensus::Parameters>(
|
||||||
|
|
||||||
let rho = {
|
let rho = {
|
||||||
let rho_bytes: [u8; 32] = row.get(5)?;
|
let rho_bytes: [u8; 32] = row.get(5)?;
|
||||||
Option::from(Nullifier::from_bytes(&rho_bytes))
|
Option::from(Rho::from_bytes(&rho_bytes))
|
||||||
.ok_or_else(|| SqliteClientError::CorruptedData("Invalid rho.".to_string()))
|
.ok_or_else(|| SqliteClientError::CorruptedData("Invalid rho.".to_string()))
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue