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]]
|
||||
name = "orchard"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fb255c3ffdccd3c84fe9ebed72aef64fdc72e6a3e4180dd411002d47abaad42"
|
||||
source = "git+https://github.com/zcash/orchard?rev=e74879dd0ad0918f4ffe0826e03905cd819981bd#e74879dd0ad0918f4ffe0826e03905cd819981bd"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"bitvec",
|
||||
|
|
|
@ -120,3 +120,6 @@ zip32 = "0.1"
|
|||
lto = true
|
||||
panic = 'abort'
|
||||
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()
|
||||
.enumerate()
|
||||
.flat_map(move |(index, action)| {
|
||||
let domain = OrchardDomain::for_nullifier(*action.nullifier());
|
||||
let domain = OrchardDomain::for_action(action);
|
||||
let account = account;
|
||||
try_note_decryption(&domain, &ivk_external, action)
|
||||
.map(|ret| (ret, TransferType::Incoming))
|
||||
|
|
|
@ -624,7 +624,7 @@ where
|
|||
self.orchard.add_outputs(
|
||||
block_hash,
|
||||
txid,
|
||||
|action| OrchardDomain::for_nullifier(action.nullifier()),
|
||||
|action| OrchardDomain::for_compact_action(action),
|
||||
&tx.actions
|
||||
.iter()
|
||||
.enumerate()
|
||||
|
@ -888,7 +888,7 @@ where
|
|||
index: i,
|
||||
}
|
||||
})?;
|
||||
Ok((OrchardDomain::for_nullifier(action.nullifier()), action))
|
||||
Ok((OrchardDomain::for_compact_action(&action), action))
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
batch_runners
|
||||
|
|
|
@ -77,7 +77,6 @@ use super::BlockDb;
|
|||
#[cfg(feature = "orchard")]
|
||||
use {
|
||||
group::ff::{Field, PrimeField},
|
||||
orchard::note_encryption::{OrchardDomain, OrchardNoteEncryption},
|
||||
pasta_curves::pallas,
|
||||
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.
|
||||
#[cfg(feature = "orchard")]
|
||||
fn compact_orchard_action<R: RngCore + CryptoRng>(
|
||||
nullifier: orchard::note::Nullifier,
|
||||
nf_old: orchard::note::Nullifier,
|
||||
recipient: orchard::Address,
|
||||
value: NonNegativeAmount,
|
||||
ovk: Option<orchard::keys::OutgoingViewingKey>,
|
||||
rng: &mut R,
|
||||
) -> (CompactOrchardAction, orchard::Note) {
|
||||
let rseed = {
|
||||
loop {
|
||||
let mut bytes = [0; 32];
|
||||
rng.fill_bytes(&mut bytes);
|
||||
let rseed = orchard::note::RandomSeed::from_bytes(bytes, &nullifier);
|
||||
if rseed.is_some().into() {
|
||||
break rseed.unwrap();
|
||||
}
|
||||
}
|
||||
};
|
||||
let note = orchard::Note::from_parts(
|
||||
use zcash_note_encryption::ShieldedOutput;
|
||||
|
||||
let (compact_action, note) = orchard::note_encryption::testing::fake_compact_action(
|
||||
rng,
|
||||
nf_old,
|
||||
recipient,
|
||||
orchard::value::NoteValue::from_raw(value.into_u64()),
|
||||
nullifier,
|
||||
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();
|
||||
ovk,
|
||||
);
|
||||
|
||||
(
|
||||
CompactOrchardAction {
|
||||
nullifier: nullifier.to_bytes().to_vec(),
|
||||
cmx: cmx.to_bytes().to_vec(),
|
||||
ephemeral_key,
|
||||
ciphertext: enc_ciphertext.as_ref()[..52].to_vec(),
|
||||
nullifier: compact_action.nullifier().to_bytes().to_vec(),
|
||||
cmx: compact_action.cmx().to_bytes().to_vec(),
|
||||
ephemeral_key: compact_action.ephemeral_key().0.to_vec(),
|
||||
ciphertext: compact_action.enc_ciphertext().as_ref()[..52].to_vec(),
|
||||
},
|
||||
note,
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use incrementalmerkletree::Position;
|
||||
use orchard::{
|
||||
keys::Diversifier,
|
||||
note::{Note, Nullifier, RandomSeed},
|
||||
note::{Note, Nullifier, RandomSeed, Rho},
|
||||
};
|
||||
use rusqlite::{named_params, params, Connection, Row};
|
||||
|
||||
|
@ -121,7 +121,7 @@ fn to_spendable_note<P: consensus::Parameters>(
|
|||
|
||||
let rho = {
|
||||
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()))
|
||||
}?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue