Merge pull request #311 from str4d/zcash_client_sqlite-0.2.1

zcash_client_sqlite: Read rcm correctly from data DB after Canopy
This commit is contained in:
str4d 2020-10-24 12:37:32 +01:00 committed by GitHub
commit ee15eea3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 16 deletions

View File

@ -0,0 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.2.1] - 2020-10-24
### Fixed
- `transact::create_to_address` now correctly reconstructs notes from the data
DB after Canopy activation (zcash/librustzcash#311). This is critcal to correct
operation of spends after Canopy.

View File

@ -1,7 +1,7 @@
[package]
name = "zcash_client_sqlite"
description = "An SQLite-based Zcash light client"
version = "0.2.0"
version = "0.2.1"
authors = [
"Jack Grigg <jack@z.cash>",
]

View File

@ -6,7 +6,7 @@ use std::convert::TryInto;
use std::path::Path;
use zcash_client_backend::{address::RecipientAddress, encoding::encode_extended_full_viewing_key};
use zcash_primitives::{
consensus::{self, NetworkUpgrade},
consensus,
keys::OutgoingViewingKey,
merkle_tree::{IncrementalWitness, MerklePath},
note_encryption::Memo,
@ -228,21 +228,18 @@ pub fn create_to_address<DB: AsRef<Path>, P: consensus::Parameters>(
let note_value: i64 = row.get(1)?;
let rseed = {
let d: Vec<_> = row.get(2)?;
let rcm_bytes: Vec<_> = row.get(2)?;
if params.is_nu_active(NetworkUpgrade::Canopy, height) {
let mut r = [0u8; 32];
r.copy_from_slice(&d[..]);
Rseed::AfterZip212(r)
} else {
let r = jubjub::Fr::from_repr(
d[..]
.try_into()
.map_err(|_| Error(ErrorKind::InvalidNote))?,
)
.ok_or(Error(ErrorKind::InvalidNote))?;
Rseed::BeforeZip212(r)
}
// We store rcm directly in the data DB, regardless of whether the note
// used a v1 or v2 note plaintext, so for the purposes of spending let's
// pretend this is a pre-ZIP 212 note.
let rcm = jubjub::Fr::from_repr(
rcm_bytes[..]
.try_into()
.map_err(|_| Error(ErrorKind::InvalidNote))?,
)
.ok_or(Error(ErrorKind::InvalidNote))?;
Rseed::BeforeZip212(rcm)
};
let from = extfvk.fvk.vk.to_payment_address(diversifier).unwrap();