-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]Feat/zcash #1366
base: master
Are you sure you want to change the base?
[WIP]Feat/zcash #1366
Conversation
|
||
```cddl | ||
zcash-accounts = { | ||
master-fingerprint: uint32, ; the master fingerprint to identify the wallet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ZIP 32 specifies a 16-byte seed fingerprint: https://zips.z.cash/zip-0032#seed-fingerprints
It's a byte array so endian-independent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to use this seed fingerprint instead.
} | ||
``` | ||
|
||
`zcash-ufvk` describes the UFVK of a Zcash account. Each seed has multiple accounts with different indexes. For index 0, `zcash-ufvk` should contain a BIP32 extended public key with path `M/44'/133'/0'` (transparent) and an Orchard FVK with path `M_orchard/32'/133'/0'` (Orchard). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify that:
-
M
is defined as in https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#master-key-generation -
M_orchard
(we use$m_{\mathsf{Orchard}}$ ) is defined as in https://zips.z.cash/zip-0032#orchard-master-key-generation .
133'
is for mainnet. Like other coins, we use 1'
for testnet as specified in SLIP 44.
Latest protocol is updated in the code base. |
The purpose of I think we'd want to include Sapling components even if it isn't supported for Keystone, because it is needed for other applications of PCZTs. |
rust/pczt/src/protos/pczt.proto
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a proto file. Also added the sapling definitions.
9cda39e
to
90596a9
Compare
images/coin/coinZec.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the barred Z is transparent. I think that's correct in that it should be white in light mode and black in dark mode (see "Horizontal logos" or "Vertical logos" at https://z.cash/press/ ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably not going to work in light mode, because the Zashi logo and name are in white.
13f57a2
to
a809fdc
Compare
515890a
to
ea142af
Compare
6786374
to
65ec54c
Compare
if target.public_key().serialize().to_vec() | ||
!= input.script_pubkey().clone() | ||
{ | ||
return Err(ZcashError::InvalidPczt( | ||
"transparent input script pubkey mismatch".to_string(), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not confirmed the alterations to your vendored code, but if target
here has type bip32::ExtendedPublicKey<secp256k1::PublicKey>
(like it does inside zcash_primitives::legacy::keys::AccountPubKey
) then there is a bug here: you are comparing the serialized public key to the script_pubkey
, but for P2PKH scripts the serialized public key appears in the script_sig
; only its hash is present in script_pubkey
.
match script.address() { | ||
Some(TransparentAddress::PublicKeyHash(hash)) => { | ||
let pubkey = input.bip32_derivation().keys().find(|pubkey| { | ||
return hash[..] == Ripemd160::digest(Sha256::digest(pubkey))[..]; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this check is incorrect:
hash
is the hash of thescript_pubkey
input.bip32_derivation()
contains a map from the encoded public key to its derivation.
This follows PSBT semantics (from BIP 174) where the derivation map lists encoded keys; bip32_derivation
is not a map from script_pubkey
to derivation path. This is because a P2SH script may contain multiple such keys and require multiple signatures. A P2PKH script happens to only contain one, but for symmetry the PCZT format treats it the same way (like PSBT).
match script.address() { | ||
Some(TransparentAddress::PublicKeyHash(hash)) => { | ||
let pubkey = output | ||
.bip32_derivation() | ||
.keys() | ||
.find(|pubkey| hash[..] == Ripemd160::digest(Sha256::digest(pubkey))[..]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similarly incorrect.
if target.public_key().serialize().to_vec() | ||
!= output.script_pubkey().clone() | ||
{ | ||
return Err(ZcashError::InvalidPczt( | ||
"transparent output script pubkey mismatch".to_string(), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similarly incorrect.
Keystone Zcash UR Registries
This protocol is based on the Uniform Resources. It describes the data schemas (UR Registries) used in Zcash integrations.
Introduction
Keystone's QR workflow involves two main steps: linking the wallet and signing data, broken down into three sub-steps:
Two UR Registries are needed for these steps, utilizing the Partially Created Zcash Transaction structure.
Zcash Accounts
Unified Full Viewing Key (UFVK)
UFVK is a standard account expression format in Zcash as per ZIP-316. It consists of:
This protocol focuses on the Transparent and Orchard components.
CDDL for Zcash Accounts
The specification uses CDDL and includes
crypto-hdkey
andcrypto-key-path
specs defined in https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-007-hdkey.md.zcash-ufvk
describes the UFVK of a Zcash account. Each seed has multiple accounts with different indexes. For index 0,zcash-ufvk
should contain a BIP32 extended public key with pathM/44'/133'/0'
(transparent) and an Orchard FVK with pathM_orchard/32'/133'/0'
(Orchard).CDDL for Zcash PCZT