Compare commits

...

46 commits

Author SHA1 Message Date
dea960c2ac
Functions to handle commitment tree nodes for Sapling and Orchard (#100)
This PR includes the functions for hashing commitment nodes for both Sapling and Orchard. It also includes functions to validate tree roots and Merkle paths.

Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/100
Co-authored-by: Rene Vergara <rene@vergara.network>
Co-committed-by: Rene Vergara <rene@vergara.network>
2024-11-15 18:48:36 +00:00
62cda9cc15
docs: version bump 2024-11-05 12:42:03 -06:00
5ce149c54f
Functions to create and manage Orchard commitment trees (#99)
This PR contains the functions to create, update and validate Orchard commitment trees.

Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/99
Co-authored-by: Rene Vergara <rene@vergara.network>
Co-committed-by: Rene Vergara <rene@vergara.network>
2024-11-05 18:28:45 +00:00
6d4b6840d3
Optimize transaction creation (#98)
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/98
Co-authored-by: Rene Vergara <rene@vergara.network>
Co-committed-by: Rene Vergara <rene@vergara.network>
2024-10-30 16:47:11 +00:00
662a0d1148
Merge pull request 'Implement Frontier for Sapling' (#97) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/97
2024-10-18 19:40:35 +00:00
4608577c41
docs: version bump 2024-10-18 14:39:05 -05:00
5a9ed11c25
fix(rust): SaplingFrontier marshalling 2024-10-18 12:25:30 -05:00
96cfe3a52a
feat: use SaplingFrontier for witnesses 2024-10-18 09:43:02 -05:00
3203c7e8ff
feat: implement Frontier for Sapling witnesses 2024-10-18 08:47:52 -05:00
396f15140a
Merge pull request 'feat: add toJSON for BlockResponse' (#96) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/96
2024-10-11 13:19:08 +00:00
5a08c80285
feat: add toJSON for BlockResponse 2024-10-11 08:17:02 -05:00
003293cc3f
Merge pull request 'Orchard anchor and witness updates' (#95) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/95
2024-10-01 12:51:41 +00:00
612ce812ef
Merge branch 'milestone2' into rav001 2024-10-01 07:15:15 -05:00
3969490283
feat: Use the notes to determine anchors 2024-09-30 14:50:54 -05:00
38e4131daa
feat!: update Orchard witness calculation
Now uses Frontier
2024-09-30 13:18:47 -05:00
48afd81595
feat!: migrate Orchard commitment trees to Frontier 2024-09-30 12:11:47 -05:00
12296026a0
Merge pull request 'Improve witness update functions.' (#94) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/94
2024-09-25 19:47:43 +00:00
5de1844e9d
feat: improve witness updates 2024-09-25 14:43:11 -05:00
36fd2e59a4
Merge branch 'milestone2' into rav001 2024-09-23 10:20:10 -05:00
63a97b880c
Merge pull request 'Add block hash to BlockResponse' (#93) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/93
2024-09-23 15:19:31 +00:00
f24ea80cde
feat: add block hash to BlockResponse 2024-09-23 10:17:35 -05:00
9df346389a
Merge branch 'milestone2' into rav001 2024-09-18 07:30:27 -05:00
91e2ebbabd
Merge pull request 'Add privacy policy error to TxError' (#92) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/92
2024-09-18 12:29:35 +00:00
343495f6e7
feat: add privacy policy error to TxError 2024-09-18 07:27:53 -05:00
7350723801
Merge branch 'milestone2' into rav001 2024-09-17 13:09:54 -05:00
7965dc38c4
Merge pull request 'docs: update version' (#91) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/91
2024-09-17 18:08:09 +00:00
ee165de652
Merge branch 'milestone2' into rav001 2024-09-17 18:07:54 +00:00
1f1ca4e206
docs: update version 2024-09-17 13:06:28 -05:00
f1e1570b25
Merge pull request 'Implement wagyu-zcash-parameters in Rust bindings' (#90) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/90
2024-09-16 18:47:50 +00:00
5a8cd44fbc
feat: implement wagyu-zcash-parameters crate 2024-09-16 13:36:49 -05:00
cedc3a0cc1
Merge branch 'milestone2' into rav001 2024-08-30 11:19:07 -05:00
ce19e174cc
Merge pull request 'fix: decode unified addresses with no transparent receivers' (#89) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/89
2024-08-30 16:12:13 +00:00
85a4741dcb
fix: decode unified addresses with no transparent receivers
ensures that a unified address that does not contain a transparent
receiver is properly represented in the type
2024-08-30 11:02:52 -05:00
0b2fae2b5d
Merge pull request 'Add JSON instances for Transaction' (#88) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/88
2024-08-20 21:05:02 +00:00
b4069d6233
Merge branch 'milestone2' into rav001 2024-08-20 15:53:31 -05:00
c8f411fcdd
add JSON instances for Transaction 2024-08-20 15:50:07 -05:00
939ae687e8
Merge pull request 'Implement address comparison and validation' (#87) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/87
2024-08-14 17:35:27 +00:00
e1622a0d7f
Merge branch 'milestone2' into rav001 2024-08-14 17:35:03 +00:00
774e135aab
Fix data type 2024-08-14 12:32:48 -05:00
b7c91e10fe
Add functions to compare and validate addresses 2024-08-14 12:32:30 -05:00
cbbdfe42af
Merge pull request 'Add ValidAddress' (#86) from rav001 into milestone2
Reviewed-on: https://git.vergara.tech///Vergara_Tech/zcash-haskell/pulls/86
2024-08-13 12:58:21 +00:00
9ca702a68e
Add ValidAddress 2024-08-13 07:56:25 -05:00
cc72fadef3
Merge pull request 'Add JSON instances for ZcashNet' (#85) from rav001 into milestone2
Reviewed-on: #85
2024-07-25 16:14:03 +00:00
7c79ee6163
Add JSON instances for ZcashNet 2024-07-25 11:09:17 -05:00
e8074419cf
Merge branch 'milestone2' of git.vergara.tech:Vergara_Tech/zcash-haskell into milestone2 2024-07-02 13:21:39 -05:00
90c8a7c302
Merge pull request 'Performance enhancement for transaction creation' (#83) from rav001 into milestone2
Reviewed-on: #83
2024-05-16 15:45:20 +00:00
13 changed files with 1716 additions and 528 deletions

View file

@ -5,6 +5,105 @@ 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/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.7.5.0]
### Added
- Sapling commitment node functions
- Sapling Merkle path test
### Changed
- Upgraded Rust dependencies to latest versions:
- `zcash_primitives` 0.19.0
- `zcash_client_backend` 0.14.0
- `orchard` 0.10.0
- `sapling-crypto` 0.3.0
- `incrementalmerkletree` 0.7.0
- `zip32` 0.1.2
## [0.7.4.0]
### Added
- `MerklePath`
## [0.7.3.0]
### Added
- Function to create an Orchard hash from a note commitment
- Function to hash Orchard commitments
### Changed
- Modified frontiers to use `HexString` for ommers
- Optimized `createTransaction`
## [0.7.2.0]
### Changed
- Modified Sapling commitment trees to use Frontier
## [0.7.1.1]
### Added
- `ToJSON` instance for `BlockResponse`
### Changed
- Updated libraries:
- conduit
- data-fix
- happy
- happy-lib
- http-conduit
- iproute
- mono-traversable
- network
- secp256k1-haskell
- strict
- typed-process
## [0.7.1.0]
### Added
- Type `OrchardFrontier`
### Changed
- Modified Orchard commitment trees functions to use Frontier
## [0.7.0.2]
### Changed
- Modified witness update functions to skip the process if no commitments are present
## [0.7.0.1]
### Added
- New error type `PrivacyPolicyError`
## [0.7.0.0]
- Implement `wagyu-zcash-parameters` in Rust bindings
## [0.6.2.3]
### Fixed
- Decoding of unified addresses with no transparent receivers
## [0.6.2.2]
- Added JSON instances for `ZcashNet`
- Added JSON instances for `Transaction`
- Added `ValidAddress`
## [0.6.2.1] ## [0.6.2.1]
### Changed ### Changed

View file

@ -54,7 +54,7 @@ constraints: any.Cabal ==3.10.3.0,
any.colour ==2.3.6, any.colour ==2.3.6,
any.comonad ==5.0.8, any.comonad ==5.0.8,
comonad +containers +distributive +indexed-traversable, comonad +containers +distributive +indexed-traversable,
any.conduit ==1.3.5, any.conduit ==1.3.6,
any.conduit-extra ==1.3.6, any.conduit-extra ==1.3.6,
any.containers ==0.6.7, any.containers ==0.6.7,
any.contravariant ==1.5.5, any.contravariant ==1.5.5,
@ -74,7 +74,7 @@ constraints: any.Cabal ==3.10.3.0,
any.data-default-instances-containers ==0.0.1, any.data-default-instances-containers ==0.0.1,
any.data-default-instances-dlist ==0.0.1, any.data-default-instances-dlist ==0.0.1,
any.data-default-instances-old-locale ==0.0.1, any.data-default-instances-old-locale ==0.0.1,
any.data-fix ==0.3.3, any.data-fix ==0.3.4,
any.deepseq ==1.4.8.1, any.deepseq ==1.4.8.1,
any.directory ==1.3.8.4, any.directory ==1.3.8.4,
any.distributive ==0.6.2.1, any.distributive ==0.6.2.1,
@ -93,7 +93,8 @@ constraints: any.Cabal ==3.10.3.0,
any.ghc-boot-th ==9.6.5, any.ghc-boot-th ==9.6.5,
any.ghc-prim ==0.10.0, any.ghc-prim ==0.10.0,
any.half ==0.3.1, any.half ==0.3.1,
any.happy ==1.20.1.1, any.happy ==2.0.2,
any.happy-lib ==2.0.2,
any.hashable ==1.4.7.0, any.hashable ==1.4.7.0,
hashable -arch-native +integer-gmp -random-initial-seed, hashable -arch-native +integer-gmp -random-initial-seed,
any.haskell-lexer ==1.1.1, any.haskell-lexer ==1.1.1,
@ -109,7 +110,7 @@ constraints: any.Cabal ==3.10.3.0,
any.http-client ==0.7.17, any.http-client ==0.7.17,
http-client +network-uri, http-client +network-uri,
any.http-client-tls ==0.3.6.3, any.http-client-tls ==0.3.6.3,
any.http-conduit ==2.3.8.3, any.http-conduit ==2.3.9,
http-conduit +aeson, http-conduit +aeson,
any.http-types ==0.12.4, any.http-types ==0.12.4,
any.indexed-traversable ==0.1.4, any.indexed-traversable ==0.1.4,
@ -118,16 +119,16 @@ constraints: any.Cabal ==3.10.3.0,
any.integer-gmp ==1.1, any.integer-gmp ==1.1,
any.integer-logarithms ==1.0.3.1, any.integer-logarithms ==1.0.3.1,
integer-logarithms -check-bounds +integer-gmp, integer-logarithms -check-bounds +integer-gmp,
any.iproute ==1.7.12, any.iproute ==1.7.14,
any.language-c ==0.9.3, any.language-c ==0.9.3,
language-c -allwarnings +iecfpextension +usebytestrings, language-c -allwarnings +iecfpextension +usebytestrings,
any.memory ==0.18.0, any.memory ==0.18.0,
memory +support_bytestring +support_deepseq, memory +support_bytestring +support_deepseq,
any.mime-types ==0.1.2.0, any.mime-types ==0.1.2.0,
any.mono-traversable ==1.0.17.0, any.mono-traversable ==1.0.20.0,
any.mtl ==2.3.1, any.mtl ==2.3.1,
any.murmur3 ==1.0.5, any.murmur3 ==1.0.5,
any.network ==3.2.1.0, any.network ==3.2.4.0,
network -devel, network -devel,
any.network-uri ==2.6.4.2, any.network-uri ==2.6.4.2,
any.old-locale ==1.0.0.7, any.old-locale ==1.0.0.7,
@ -150,7 +151,7 @@ constraints: any.Cabal ==3.10.3.0,
any.safe ==0.3.21, any.safe ==0.3.21,
any.scientific ==0.3.8.0, any.scientific ==0.3.8.0,
scientific -integer-simple, scientific -integer-simple,
any.secp256k1-haskell ==1.2.0, any.secp256k1-haskell ==1.4.0,
any.semialign ==1.3.1, any.semialign ==1.3.1,
semialign +semigroupoids, semialign +semigroupoids,
any.semigroupoids ==6.0.1, any.semigroupoids ==6.0.1,
@ -165,7 +166,7 @@ constraints: any.Cabal ==3.10.3.0,
any.stm ==2.5.1.0, any.stm ==2.5.1.0,
any.streaming-commons ==0.2.2.6, any.streaming-commons ==0.2.2.6,
streaming-commons -use-bytestring-builder, streaming-commons -use-bytestring-builder,
any.strict ==0.5, any.strict ==0.5.1,
any.string-conversions ==0.4.0.1, any.string-conversions ==0.4.0.1,
any.tagged ==0.8.8, any.tagged ==0.8.8,
tagged +deepseq +transformers, tagged +deepseq +transformers,
@ -185,7 +186,7 @@ constraints: any.Cabal ==3.10.3.0,
any.transformers ==0.6.1.0, any.transformers ==0.6.1.0,
any.transformers-compat ==0.7.2, any.transformers-compat ==0.7.2,
transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, transformers-compat -five +five-three -four +generic-deriving +mtl -three -two,
any.typed-process ==0.2.11.1, any.typed-process ==0.2.12.0,
any.unix ==2.8.4.0, any.unix ==2.8.4.0,
any.unix-time ==0.4.15, any.unix-time ==0.4.15,
any.unliftio-core ==0.2.1.0, any.unliftio-core ==0.2.1.0,
@ -204,4 +205,4 @@ constraints: any.Cabal ==3.10.3.0,
any.witherable ==0.5, any.witherable ==0.5,
any.zlib ==0.7.1.0, any.zlib ==0.7.1.0,
zlib -bundled-c-zlib +non-blocking-ffi +pkg-config zlib -bundled-c-zlib +non-blocking-ffi +pkg-config
index-state: hackage.haskell.org 2024-07-01T20:28:56Z index-state: hackage.haskell.org 2024-10-11T12:55:31Z

View file

@ -60,15 +60,15 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.21.2" version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "base64ct" name = "base64ct"
version = "1.0.1" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]] [[package]]
name = "bech32" name = "bech32"
@ -120,9 +120,9 @@ dependencies = [
[[package]] [[package]]
name = "bip0039" name = "bip0039"
version = "0.10.1" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef0f0152ec5cf17f49a5866afaa3439816207fd4f0a224c0211ffaf5e278426" checksum = "568b6890865156d9043af490d4c4081c385dd68ea10acd6ca15733d511e6b51c"
dependencies = [ dependencies = [
"hmac", "hmac",
"pbkdf2", "pbkdf2",
@ -132,6 +132,22 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "bip32"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa13fae8b6255872fd86f7faf4b41168661d7d78609f7bfe6771b85c6739a15b"
dependencies = [
"bs58 0.5.0",
"hmac",
"rand_core",
"ripemd",
"secp256k1",
"sha2 0.10.6",
"subtle",
"zeroize",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -318,12 +334,6 @@ dependencies = [
"tinyvec", "tinyvec",
] ]
[[package]]
name = "bumpalo"
version = "3.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.4.3" version = "1.4.3"
@ -709,19 +719,6 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "hdwallet"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a03ba7d4c9ea41552cd4351965ff96883e629693ae85005c501bb4b9e1c48a7"
dependencies = [
"lazy_static",
"rand_core",
"ring",
"secp256k1",
"thiserror",
]
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.4.1" version = "0.4.1"
@ -760,9 +757,9 @@ dependencies = [
[[package]] [[package]]
name = "incrementalmerkletree" name = "incrementalmerkletree"
version = "0.5.1" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1872810fb725b06b8c153dde9e86f3ec26747b9b60096da7a869883b549cbe" checksum = "d45063fbc4b0a37837f6bfe0445f269d13d730ad0aa3b5a7f74aa7bf27a0f4df"
dependencies = [ dependencies = [
"either", "either",
] ]
@ -815,15 +812,6 @@ dependencies = [
"either", "either",
] ]
[[package]]
name = "js-sys"
version = "0.3.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "jubjub" name = "jubjub"
version = "0.10.0" version = "0.10.0"
@ -999,9 +987,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "orchard" name = "orchard"
version = "0.7.1" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fb255c3ffdccd3c84fe9ebed72aef64fdc72e6a3e4180dd411002d47abaad42" checksum = "4f18e997fa121de5c73e95cdc7e8512ae43b7de38904aeea5e5713cc48f3c0ba"
dependencies = [ dependencies = [
"aes", "aes",
"bitvec", "bitvec",
@ -1022,6 +1010,7 @@ dependencies = [
"serde", "serde",
"subtle", "subtle",
"tracing", "tracing",
"visibility",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_spec", "zcash_spec",
"zip32", "zip32",
@ -1038,9 +1027,9 @@ dependencies = [
[[package]] [[package]]
name = "password-hash" name = "password-hash"
version = "0.3.2" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
dependencies = [ dependencies = [
"base64ct", "base64ct",
"rand_core", "rand_core",
@ -1064,9 +1053,9 @@ dependencies = [
[[package]] [[package]]
name = "pbkdf2" name = "pbkdf2"
version = "0.10.1" version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
dependencies = [ dependencies = [
"digest 0.10.7", "digest 0.10.7",
"password-hash", "password-hash",
@ -1147,9 +1136,9 @@ dependencies = [
[[package]] [[package]]
name = "prost" name = "prost"
version = "0.12.3" version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f"
dependencies = [ dependencies = [
"bytes", "bytes",
"prost-derive", "prost-derive",
@ -1157,9 +1146,9 @@ dependencies = [
[[package]] [[package]]
name = "prost-build" name = "prost-build"
version = "0.12.3" version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15"
dependencies = [ dependencies = [
"bytes", "bytes",
"heck", "heck",
@ -1174,14 +1163,13 @@ dependencies = [
"regex", "regex",
"syn 2.0.32", "syn 2.0.32",
"tempfile", "tempfile",
"which",
] ]
[[package]] [[package]]
name = "prost-derive" name = "prost-derive"
version = "0.12.3" version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"itertools", "itertools",
@ -1192,9 +1180,9 @@ dependencies = [
[[package]] [[package]]
name = "prost-types" name = "prost-types"
version = "0.12.3" version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670"
dependencies = [ dependencies = [
"prost", "prost",
] ]
@ -1341,21 +1329,6 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]] [[package]]
name = "ripemd" name = "ripemd"
version = "0.1.3" version = "0.1.3"
@ -1384,6 +1357,7 @@ name = "rustzcash-wrapper"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bech32 0.11.0", "bech32 0.11.0",
"bip0039",
"borsh 0.10.3", "borsh 0.10.3",
"f4jumble", "f4jumble",
"haskell-ffi", "haskell-ffi",
@ -1395,6 +1369,7 @@ dependencies = [
"rand_core", "rand_core",
"sapling-crypto", "sapling-crypto",
"secp256k1", "secp256k1",
"wagyu-zcash-parameters",
"zcash_address 0.2.0", "zcash_address 0.2.0",
"zcash_client_backend", "zcash_client_backend",
"zcash_note_encryption", "zcash_note_encryption",
@ -1404,9 +1379,9 @@ dependencies = [
[[package]] [[package]]
name = "sapling-crypto" name = "sapling-crypto"
version = "0.1.3" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f4270033afcb0c74c5c7d59c73cfd1040367f67f224fe7ed9a919ae618f1b7" checksum = "cfff8cfce16aeb38da50b8e2ed33c9018f30552beff2210c266662a021b17f38"
dependencies = [ dependencies = [
"aes", "aes",
"bellman", "bellman",
@ -1442,9 +1417,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "secp256k1" name = "secp256k1"
version = "0.26.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f"
dependencies = [ dependencies = [
"secp256k1-sys", "secp256k1-sys",
] ]
@ -1513,9 +1488,9 @@ dependencies = [
[[package]] [[package]]
name = "shardtree" name = "shardtree"
version = "0.2.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf20c7a2747d9083092e3a3eeb9a7ed75577ae364896bebbc5e0bdcd4e97735" checksum = "b5f2390975ebfe8838f9e861f7a588123d49a7a7a0a08568ea831d8ad53fc9b4"
dependencies = [ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"either", "either",
@ -1648,13 +1623,14 @@ dependencies = [
[[package]] [[package]]
name = "tonic-build" name = "tonic-build"
version = "0.10.2" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11"
dependencies = [ dependencies = [
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
"prost-build", "prost-build",
"prost-types",
"quote", "quote",
"syn 2.0.32", "syn 2.0.32",
] ]
@ -1717,9 +1693,9 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"
version = "0.1.22" version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
] ]
@ -1734,88 +1710,79 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "visibility"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d674d135b4a8c1d7e813e2f8d1c9a58308aee4a680323066025e53132218bd91"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.32",
]
[[package]]
name = "wagyu-zcash-parameters"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c904628658374e651288f000934c33ef738b2d8b3e65d4100b70b395dbe2bb"
dependencies = [
"wagyu-zcash-parameters-1",
"wagyu-zcash-parameters-2",
"wagyu-zcash-parameters-3",
"wagyu-zcash-parameters-4",
"wagyu-zcash-parameters-5",
"wagyu-zcash-parameters-6",
]
[[package]]
name = "wagyu-zcash-parameters-1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bf2e21bb027d3f8428c60d6a720b54a08bf6ce4e6f834ef8e0d38bb5695da8"
[[package]]
name = "wagyu-zcash-parameters-2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a616ab2e51e74cc48995d476e94de810fb16fc73815f390bf2941b046cc9ba2c"
[[package]]
name = "wagyu-zcash-parameters-3"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14da1e2e958ff93c0830ee68e91884069253bf3462a67831b02b367be75d6147"
[[package]]
name = "wagyu-zcash-parameters-4"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f058aeef03a2070e8666ffb5d1057d8bb10313b204a254a6e6103eb958e9a6d6"
[[package]]
name = "wagyu-zcash-parameters-5"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ffe916b30e608c032ae1b734f02574a3e12ec19ab5cc5562208d679efe4969d"
[[package]]
name = "wagyu-zcash-parameters-6"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7b6d5a78adc3e8f198e9cd730f219a695431467f7ec29dcfc63ade885feebe1"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.32",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.32",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "web-sys"
version = "0.3.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "which" name = "which"
version = "4.4.0" version = "4.4.0"
@ -1827,28 +1794,6 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"
@ -1938,21 +1883,22 @@ dependencies = [
[[package]] [[package]]
name = "zcash_address" name = "zcash_address"
version = "0.3.1" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bce173f1d9ed4f806e310bc3a873301531e7a6dc209928584d6404e3f8228ef4" checksum = "4ff95eac82f71286a79c750e674550d64fb2b7aadaef7b89286b2917f645457d"
dependencies = [ dependencies = [
"bech32 0.9.1", "bech32 0.9.1",
"bs58 0.5.0", "bs58 0.5.0",
"f4jumble", "f4jumble",
"zcash_encoding", "zcash_encoding",
"zcash_protocol",
] ]
[[package]] [[package]]
name = "zcash_client_backend" name = "zcash_client_backend"
version = "0.11.1" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "001ec65dc2828ee648dc6d29f0944d7a877fe68ad06e001a203c11770ab1b3d4" checksum = "cbeeede366fdb642710d3c59fc2090489affd075f66db53ed11bb7138d2d0258"
dependencies = [ dependencies = [
"base64", "base64",
"bech32 0.9.1", "bech32 0.9.1",
@ -1978,19 +1924,21 @@ dependencies = [
"tonic-build", "tonic-build",
"tracing", "tracing",
"which", "which",
"zcash_address 0.3.1", "zcash_address 0.6.0",
"zcash_encoding", "zcash_encoding",
"zcash_keys", "zcash_keys",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_primitives", "zcash_primitives",
"zcash_protocol",
"zip32", "zip32",
"zip321",
] ]
[[package]] [[package]]
name = "zcash_encoding" name = "zcash_encoding"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f03391b81727875efa6ac0661a20883022b6fba92365dc121c48fa9b00c5aac0" checksum = "052d8230202f0a018cd9b5d1b56b94cd25e18eccc2d8665073bcea8261ab87fc"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"nonempty", "nonempty",
@ -1998,11 +1946,12 @@ dependencies = [
[[package]] [[package]]
name = "zcash_keys" name = "zcash_keys"
version = "0.1.1" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f22d3407fdd6992b49f037f23862ab376be6013be6f2d0bc85948a635edc1f5" checksum = "e8162c94957f1e379b8e2fb30f97b95cfa93ac9c6bc02895946ca6392d1abb81"
dependencies = [ dependencies = [
"bech32 0.9.1", "bech32 0.9.1",
"blake2b_simd",
"bls12_381", "bls12_381",
"bs58 0.5.0", "bs58 0.5.0",
"document-features", "document-features",
@ -2011,11 +1960,13 @@ dependencies = [
"nonempty", "nonempty",
"rand_core", "rand_core",
"sapling-crypto", "sapling-crypto",
"secrecy",
"subtle", "subtle",
"tracing", "tracing",
"zcash_address 0.3.1", "zcash_address 0.6.0",
"zcash_encoding", "zcash_encoding",
"zcash_primitives", "zcash_primitives",
"zcash_protocol",
"zip32", "zip32",
] ]
@ -2034,20 +1985,20 @@ dependencies = [
[[package]] [[package]]
name = "zcash_primitives" name = "zcash_primitives"
version = "0.14.0" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9070e084570bb78aed4f8d71fd6254492e62c87a5d01e084183980e98117092d" checksum = "6ab47d526d7fd6f88b3a2854ad81b54757a80c2aeadd1d8b06f690556af9743c"
dependencies = [ dependencies = [
"aes", "aes",
"bip0039", "bip32",
"blake2b_simd", "blake2b_simd",
"bs58 0.5.0",
"byteorder", "byteorder",
"document-features", "document-features",
"equihash", "equihash",
"ff", "ff",
"fpe", "fpe",
"group", "group",
"hdwallet",
"hex", "hex",
"incrementalmerkletree", "incrementalmerkletree",
"jubjub", "jubjub",
@ -2063,18 +2014,29 @@ dependencies = [
"sha2 0.10.6", "sha2 0.10.6",
"subtle", "subtle",
"tracing", "tracing",
"zcash_address 0.3.1", "zcash_address 0.6.0",
"zcash_encoding", "zcash_encoding",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_protocol",
"zcash_spec", "zcash_spec",
"zip32", "zip32",
] ]
[[package]] [[package]]
name = "zcash_spec" name = "zcash_protocol"
version = "0.1.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7a3bf58b673cb3dacd8ae09ba345998923a197ab0da70d6239d8e8838949e9b" checksum = "6bc22b9155b2c7eb20105cd06de170d188c1bc86489b92aa3fda7b8da8d96acf"
dependencies = [
"document-features",
"memuse",
]
[[package]]
name = "zcash_spec"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cede95491c2191d3e278cab76e097a44b17fde8d6ca0d4e3a22cf4807b2d857"
dependencies = [ dependencies = [
"blake2b_simd", "blake2b_simd",
] ]
@ -2101,11 +2063,25 @@ dependencies = [
[[package]] [[package]]
name = "zip32" name = "zip32"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4226d0aee9c9407c27064dfeec9d7b281c917de3374e1e5a2e2cfad9e09de19e" checksum = "92022ac1e47c7b78f9cee29efac8a1a546e189506f3bb5ad46d525be7c519bf6"
dependencies = [ dependencies = [
"blake2b_simd", "blake2b_simd",
"memuse", "memuse",
"subtle", "subtle",
"zcash_spec",
]
[[package]]
name = "zip321"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3e613defb0940acef1f54774b51c7f48f2fa705613dd800870dc69f35cd2ea"
dependencies = [
"base64",
"nom",
"percent-encoding",
"zcash_address 0.6.0",
"zcash_protocol",
] ]

View file

@ -11,18 +11,20 @@ f4jumble = "0.1"
zcash_address = "0.2.0" zcash_address = "0.2.0"
borsh = "0.10" borsh = "0.10"
bech32 = "0.11" bech32 = "0.11"
orchard = "0.7.1" orchard = "0.10.0"
zcash_note_encryption = "0.4.0" zcash_note_encryption = "0.4.0"
zcash_primitives = { version = "0.14.0", features = ["transparent-inputs"]} zcash_primitives = { version = "0.19.0", features = ["transparent-inputs"]}
zcash_client_backend = "0.11.1" zcash_client_backend = "0.14.0"
sapling-crypto = "0.1.3" sapling-crypto = "0.3"
zip32 = "0.1.0" zip32 = "0.1.2"
proc-macro2 = "1.0.66" proc-macro2 = "1.0.66"
nonempty = "0.7.0" nonempty = "0.7.0"
incrementalmerkletree = "0.5.0" incrementalmerkletree = "0.7.0"
secp256k1 = "0.26.0" secp256k1 = "0.27.0"
jubjub = "0.10.0" jubjub = "0.10.0"
rand_core = { version = "0.6.4", features = ["getrandom"]} rand_core = { version = "0.6.4", features = ["getrandom"]}
wagyu-zcash-parameters = "0.2.0"
bip0039 = "0.12.0"
[features] [features]

File diff suppressed because it is too large Load diff

View file

@ -204,15 +204,15 @@ import ZcashHaskell.Types
#} #}
{# fun unsafe rust_wrapper_read_sapling_commitment_tree as rustWrapperReadSaplingCommitmentTree {# fun unsafe rust_wrapper_read_sapling_commitment_tree as rustWrapperReadSaplingCommitmentTree
{ toBorshVar* `BS.ByteString'& { toBorshVar* `SaplingFrontier'&
, toBorshVar* `BS.ByteString'& , toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'& , getVarBuffer `Buffer SaplingFrontier'&
} }
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_read_sapling_witness as rustWrapperReadSaplingWitness {# fun unsafe rust_wrapper_read_sapling_witness as rustWrapperReadSaplingWitness
{ toBorshVar* `BS.ByteString'& { toBorshVar* `SaplingFrontier'&
, getVarBuffer `Buffer HexString'& , getVarBuffer `Buffer HexString'&
} }
-> `()' -> `()'
@ -232,6 +232,13 @@ import ZcashHaskell.Types
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_read_sapling_frontier as rustWrapperReadSaplingFrontier
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer SaplingFrontier'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_decode_sapling_address as rustWrapperDecodeSaplingAddress {# fun unsafe rust_wrapper_decode_sapling_address as rustWrapperDecodeSaplingAddress
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer (BS.ByteString)'& , getVarBuffer `Buffer (BS.ByteString)'&
@ -239,16 +246,120 @@ import ZcashHaskell.Types
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_read_orchard_commitment_tree as rustWrapperReadOrchardCommitmentTree {# fun unsafe rust_wrapper_read_sapling_node as rustWrapperReadSaplingNode
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_combine_sapling_nodes as rustWrapperCombineSaplingNodes
{ `Int8'
, toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'& , toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'& , getVarBuffer `Buffer HexString'&
} }
-> `()' -> `()'
#} #}
{# fun unsafe rust_wrapper_read_orchard_witness as rustWrapperReadOrchardWitness {# fun unsafe rust_wrapper_get_sapling_root as rustWrapperGetSaplingRootTest
{ `Int8'
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_sapling_commitment_tree_parts as rustWrapperReadSaplingTreeParts
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer SaplingRawTree'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_sapling_tree_anchor as rustWrapperReadSaplingTreeAnchor
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_sapling_path_anchor as rustWrapperReadSaplingPathAnchor
{ toBorshVar* `MerklePath'&
, toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_node as rustWrapperReadOrchardNode
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_combine_orchard_nodes as rustWrapperCombineOrchardNodes
{ `Int8'
, toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_tree_anchor as rustWrapperReadOrchardTreeAnchor
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_witness_anchor as rustWrapperReadOrchardWitnessAnchor
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_path_anchor as rustWrapperReadOrchardPathAnchor
{ toBorshVar* `MerklePath'&
, toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_get_orchard_root as rustWrapperGetOrchardRootTest
{ `Int8'
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_commitment_tree as rustWrapperReadOrchardCommitmentTree
{ toBorshVar* `OrchardFrontier'&
, toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer OrchardFrontier'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_commitment_tree_parts as rustWrapperReadOrchardTreeParts
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer OrchardRawTree'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_frontier as rustWrapperReadOrchardFrontier
{ toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer OrchardFrontier'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_read_orchard_witness as rustWrapperReadOrchardWitness
{ toBorshVar* `OrchardFrontier'&
, getVarBuffer `Buffer HexString'& , getVarBuffer `Buffer HexString'&
} }
-> `()' -> `()'
@ -260,6 +371,15 @@ import ZcashHaskell.Types
-> `Word64' -> `Word64'
#} #}
{# fun unsafe rust_wrapper_orchard_add_node as rustWrapperOrchardAddNodeTest
{ `Int8'
, toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_update_sapling_witness as rustWrapperUpdateSaplingWitness {# fun unsafe rust_wrapper_update_sapling_witness as rustWrapperUpdateSaplingWitness
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, toBorshVar* `[BS.ByteString]'& , toBorshVar* `[BS.ByteString]'&
@ -283,8 +403,6 @@ import ZcashHaskell.Types
, toBorshVar* `[SaplingTxSpend]'& , toBorshVar* `[SaplingTxSpend]'&
, toBorshVar* `[OrchardTxSpend]'& , toBorshVar* `[OrchardTxSpend]'&
, toBorshVar* `[OutgoingNote]'& , toBorshVar* `[OutgoingNote]'&
, toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'&
, `Bool' , `Bool'
, `Word64' , `Word64'
, `Bool' , `Bool'

View file

@ -18,14 +18,23 @@
module ZcashHaskell.Orchard where module ZcashHaskell.Orchard where
import C.Zcash import C.Zcash
( rustWrapperGenOrchardReceiver ( rustWrapperCombineOrchardNodes
, rustWrapperGenOrchardReceiver
, rustWrapperGenOrchardSpendKey , rustWrapperGenOrchardSpendKey
, rustWrapperGetOrchardRootTest
, rustWrapperOrchardAddNodeTest
, rustWrapperOrchardCheck , rustWrapperOrchardCheck
, rustWrapperOrchardNoteDecode , rustWrapperOrchardNoteDecode
, rustWrapperOrchardNoteDecodeSK , rustWrapperOrchardNoteDecodeSK
, rustWrapperReadOrchardCommitmentTree , rustWrapperReadOrchardCommitmentTree
, rustWrapperReadOrchardFrontier
, rustWrapperReadOrchardNode
, rustWrapperReadOrchardPathAnchor
, rustWrapperReadOrchardPosition , rustWrapperReadOrchardPosition
, rustWrapperReadOrchardTreeAnchor
, rustWrapperReadOrchardTreeParts
, rustWrapperReadOrchardWitness , rustWrapperReadOrchardWitness
, rustWrapperReadOrchardWitnessAnchor
, rustWrapperUADecode , rustWrapperUADecode
, rustWrapperUfvkDecode , rustWrapperUfvkDecode
, rustWrapperUpdateOrchardWitness , rustWrapperUpdateOrchardWitness
@ -37,6 +46,11 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding as E
import Data.Word import Data.Word
import Foreign.Rust.Marshall.Variable import Foreign.Rust.Marshall.Variable
import ZcashHaskell.Sapling (decodeSaplingAddress)
import ZcashHaskell.Transparent
( decodeExchangeAddress
, decodeTransparentAddress
)
import ZcashHaskell.Types import ZcashHaskell.Types
import ZcashHaskell.Utils (encodeBech32, encodeBech32m, f4Jumble) import ZcashHaskell.Utils (encodeBech32, encodeBech32m, f4Jumble)
@ -98,9 +112,9 @@ isValidUnifiedAddress str =
(if BS.length (raw_s x) == 43 (if BS.length (raw_s x) == 43
then Just $ SaplingReceiver (raw_s x) then Just $ SaplingReceiver (raw_s x)
else Nothing) else Nothing)
(if not (BS.null (raw_t x)) (if BS.length (raw_t x) > 1
then Just $ TransparentReceiver P2PKH (fromRawBytes $ raw_t x) then Just $ TransparentReceiver P2PKH (fromRawBytes $ raw_t x)
else if not (BS.null (raw_to x)) else if BS.length (raw_to x) > 1
then Just $ TransparentReceiver P2SH (fromRawBytes $ raw_to x) then Just $ TransparentReceiver P2SH (fromRawBytes $ raw_to x)
else Nothing) else Nothing)
@ -189,40 +203,137 @@ decryptOrchardActionSK sk scope oa =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperOrchardNoteDecodeSK (getBytes sk) oa (scope == External) rustWrapperOrchardNoteDecodeSK (getBytes sk) oa (scope == External)
-- | Update a Orchard commitment tree getOrchardFrontier :: OrchardCommitmentTree -> Maybe OrchardFrontier
updateOrchardCommitmentTree :: getOrchardFrontier tree =
OrchardCommitmentTree -- ^ the base tree if of_pos updatedTree > 1
-> HexString -- ^ the new note commitment then Just updatedTree
-> Maybe OrchardCommitmentTree
updateOrchardCommitmentTree tree cmx =
if BS.length (hexBytes updatedTree) > 1
then Just $ OrchardCommitmentTree updatedTree
else Nothing else Nothing
where where
updatedTree = updatedTree =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperReadOrchardCommitmentTree rustWrapperReadOrchardFrontier $ toBytes $ orchTree tree
(hexBytes $ orchTree tree)
(hexBytes cmx) getOrchardTreeAnchor :: OrchardCommitmentTree -> HexString
getOrchardTreeAnchor tree =
withPureBorshVarBuffer $
rustWrapperReadOrchardTreeAnchor $ toBytes $ orchTree tree
getOrchardWitnessAnchor :: OrchardWitness -> HexString
getOrchardWitnessAnchor wit =
withPureBorshVarBuffer $
rustWrapperReadOrchardWitnessAnchor $ toBytes $ orchWit wit
getOrchardRootTest :: Int -> HexString
getOrchardRootTest level =
withPureBorshVarBuffer $ rustWrapperGetOrchardRootTest $ fromIntegral level
addOrchardNodeGetRoot :: Int -> BS.ByteString -> HexString
addOrchardNodeGetRoot l n =
withPureBorshVarBuffer $ rustWrapperOrchardAddNodeTest (fromIntegral l) n
getOrchardTreeParts :: OrchardCommitmentTree -> Maybe OrchardTree
getOrchardTreeParts h =
if isBlank (ort_left tree) && isBlank (ort_right tree)
then Nothing
else Just $
OrchardTree
(parseHex $ ort_left tree)
(parseHex $ ort_right tree)
(map parseHex (ort_parents tree))
where
isBlank h = (BS.length $ hexBytes $ h) == 1
parseHex h =
if (BS.length $ hexBytes $ h) > 1
then Just h
else Nothing
tree =
withPureBorshVarBuffer $
rustWrapperReadOrchardTreeParts $ toBytes $ orchTree h
getOrchardPathAnchor :: HexString -> MerklePath -> HexString
getOrchardPathAnchor hex p =
withPureBorshVarBuffer $ rustWrapperReadOrchardPathAnchor p (hexBytes hex)
-- | Update a Orchard commitment tree
updateOrchardCommitmentTree ::
OrchardFrontier -- ^ the base tree
-> HexString -- ^ the new note commitment
-> Maybe OrchardFrontier
updateOrchardCommitmentTree tree cmx =
if of_pos updatedTree > 1
then Just updatedTree
else Nothing
where
updatedTree =
withPureBorshVarBuffer $
rustWrapperReadOrchardCommitmentTree tree (hexBytes cmx)
-- | Get the Orchard incremental witness from a commitment tree -- | Get the Orchard incremental witness from a commitment tree
getOrchardWitness :: OrchardCommitmentTree -> Maybe OrchardWitness getOrchardWitness :: OrchardFrontier -> Maybe OrchardWitness
getOrchardWitness tree = getOrchardWitness tree =
if BS.length (hexBytes wit) > 1 if BS.length (hexBytes wit) > 1
then Just $ OrchardWitness wit then Just $ OrchardWitness wit
else Nothing else Nothing
where where
wit = wit = withPureBorshVarBuffer $ rustWrapperReadOrchardWitness tree
withPureBorshVarBuffer $
rustWrapperReadOrchardWitness (hexBytes $ orchTree tree)
-- | Get the Sapling note position from a witness -- | Get the Sapling note position from a witness
getOrchardNotePosition :: OrchardWitness -> Integer getOrchardNotePosition :: OrchardWitness -> Integer
getOrchardNotePosition = getOrchardNotePosition =
fromIntegral . rustWrapperReadOrchardPosition . hexBytes . orchWit fromIntegral . rustWrapperReadOrchardPosition . hexBytes . orchWit
-- | Update the witness of an Orchard note
updateOrchardWitness :: OrchardWitness -> [HexString] -> OrchardWitness updateOrchardWitness :: OrchardWitness -> [HexString] -> OrchardWitness
updateOrchardWitness wit cmus = updateOrchardWitness wit cmus =
OrchardWitness $ if not (null cmus)
withPureBorshVarBuffer $ then OrchardWitness $
rustWrapperUpdateOrchardWitness (toBytes $ orchWit wit) (map toBytes cmus) withPureBorshVarBuffer $
rustWrapperUpdateOrchardWitness
(toBytes $ orchWit wit)
(map toBytes cmus)
else wit
getOrchardNodeValue :: BS.ByteString -> Maybe HexString
getOrchardNodeValue cmx =
if BS.length (hexBytes n) > 1
then Just n
else Nothing
where
n = withPureBorshVarBuffer $ rustWrapperReadOrchardNode cmx
combineOrchardNodes :: Integer -> HexString -> HexString -> Maybe HexString
combineOrchardNodes level n1 n2 =
if BS.length (hexBytes r) > 1
then Just r
else Nothing
where
r =
withPureBorshVarBuffer $
rustWrapperCombineOrchardNodes
(fromIntegral level)
(toBytes n1)
(toBytes n2)
-- | Parse a potential Zcash address
parseAddress :: BS.ByteString -> Maybe ValidAddress
parseAddress t =
case isValidUnifiedAddress t of
Nothing ->
case decodeSaplingAddress t of
Nothing ->
case decodeTransparentAddress t of
Nothing ->
case decodeExchangeAddress t of
Nothing -> Nothing
Just x -> Just $ Exchange x
Just t -> Just $ Transparent t
Just s -> Just $ Sapling s
Just u -> Just $ Unified u
compareAddress :: ValidAddress -> UnifiedAddress -> Bool
compareAddress a u =
case a of
Unified i -> i == u
Sapling s -> s_rec u == Just (sa_receiver s) && ua_net u == net_type s
Transparent t -> t_rec u == Just (ta_receiver t) && ua_net u == ta_network t
Exchange x -> False

View file

@ -18,10 +18,17 @@
module ZcashHaskell.Sapling where module ZcashHaskell.Sapling where
import C.Zcash import C.Zcash
( rustWrapperDecodeSaplingAddress ( rustWrapperCombineSaplingNodes
, rustWrapperDecodeSaplingAddress
, rustWrapperGetSaplingRootTest
, rustWrapperIsShielded , rustWrapperIsShielded
, rustWrapperReadSaplingCommitmentTree , rustWrapperReadSaplingCommitmentTree
, rustWrapperReadSaplingFrontier
, rustWrapperReadSaplingNode
, rustWrapperReadSaplingPathAnchor
, rustWrapperReadSaplingPosition , rustWrapperReadSaplingPosition
, rustWrapperReadSaplingTreeAnchor
, rustWrapperReadSaplingTreeParts
, rustWrapperReadSaplingWitness , rustWrapperReadSaplingWitness
, rustWrapperSaplingCheck , rustWrapperSaplingCheck
, rustWrapperSaplingChgPaymentAddress , rustWrapperSaplingChgPaymentAddress
@ -37,6 +44,7 @@ import Data.Aeson
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Char8 as C
import Data.HexString (HexString(..), fromText, hexString, toBytes, toText) import Data.HexString (HexString(..), fromText, hexString, toBytes, toText)
import Data.Int (Int8)
import qualified Data.Text as T import qualified Data.Text as T
import Data.Word import Data.Word
import Foreign.Rust.Marshall.Variable import Foreign.Rust.Marshall.Variable
@ -184,32 +192,88 @@ genSaplingInternalAddress sk =
res = res =
withPureBorshVarBuffer (rustWrapperSaplingChgPaymentAddress $ getBytes sk) withPureBorshVarBuffer (rustWrapperSaplingChgPaymentAddress $ getBytes sk)
-- | Update a Sapling commitment tree getSaplingNodeValue :: BS.ByteString -> Maybe HexString
updateSaplingCommitmentTree :: getSaplingNodeValue cmu =
SaplingCommitmentTree -- ^ the base tree if BS.length (hexBytes n) > 1
-> HexString -- ^ the new note commitment then Just n
-> Maybe SaplingCommitmentTree else Nothing
updateSaplingCommitmentTree tree cmu = where
if BS.length (hexBytes updatedTree) > 1 n = withPureBorshVarBuffer $ rustWrapperReadSaplingNode cmu
then Just $ SaplingCommitmentTree updatedTree
combineSaplingNodes :: Int8 -> HexString -> HexString -> Maybe HexString
combineSaplingNodes level n1 n2 =
if BS.length (hexBytes r) > 1
then Just r
else Nothing
where
r =
withPureBorshVarBuffer $
rustWrapperCombineSaplingNodes level (toBytes n1) (toBytes n2)
getSaplingRootTest :: Int8 -> HexString
getSaplingRootTest level =
withPureBorshVarBuffer $ rustWrapperGetSaplingRootTest level
getSaplingTreeParts :: SaplingCommitmentTree -> Maybe SaplingTree
getSaplingTreeParts h =
if isBlank (srt_left tree) && isBlank (srt_right tree)
then Nothing
else Just $
SaplingTree
(parseHex $ srt_left tree)
(parseHex $ srt_right tree)
(map parseHex (srt_parents tree))
where
isBlank h = (BS.length $ hexBytes $ h) == 1
parseHex h =
if (BS.length $ hexBytes $ h) > 1
then Just h
else Nothing
tree =
withPureBorshVarBuffer $
rustWrapperReadSaplingTreeParts $ toBytes $ sapTree h
getSaplingTreeAnchor :: SaplingCommitmentTree -> HexString
getSaplingTreeAnchor tree =
withPureBorshVarBuffer $
rustWrapperReadSaplingTreeAnchor $ toBytes $ sapTree tree
getSaplingPathAnchor :: HexString -> MerklePath -> HexString
getSaplingPathAnchor hex p =
withPureBorshVarBuffer $ rustWrapperReadSaplingPathAnchor p (hexBytes hex)
getSaplingFrontier :: SaplingCommitmentTree -> Maybe SaplingFrontier
getSaplingFrontier tree =
if sf_pos updatedTree > 1
then Just updatedTree
else Nothing else Nothing
where where
updatedTree = updatedTree =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperReadSaplingCommitmentTree rustWrapperReadSaplingFrontier $ toBytes $ sapTree tree
(hexBytes $ sapTree tree)
(hexBytes cmu) -- | Update a Sapling commitment tree
updateSaplingCommitmentTree ::
SaplingFrontier -- ^ the base tree
-> HexString -- ^ the new note commitment
-> Maybe SaplingFrontier
updateSaplingCommitmentTree tree cmu =
if sf_pos updatedTree > 1
then Just updatedTree
else Nothing
where
updatedTree =
withPureBorshVarBuffer $
rustWrapperReadSaplingCommitmentTree tree (hexBytes cmu)
-- | Get the Sapling incremental witness from a commitment tree -- | Get the Sapling incremental witness from a commitment tree
getSaplingWitness :: SaplingCommitmentTree -> Maybe SaplingWitness getSaplingWitness :: SaplingFrontier -> Maybe SaplingWitness
getSaplingWitness tree = getSaplingWitness tree =
if BS.length (hexBytes wit) > 1 if BS.length (hexBytes wit) > 1
then Just $ SaplingWitness wit then Just $ SaplingWitness wit
else Nothing else Nothing
where where
wit = wit = withPureBorshVarBuffer $ rustWrapperReadSaplingWitness tree
withPureBorshVarBuffer $
rustWrapperReadSaplingWitness (hexBytes $ sapTree tree)
-- | Get the Sapling note position from a witness -- | Get the Sapling note position from a witness
getSaplingNotePosition :: SaplingWitness -> Integer getSaplingNotePosition :: SaplingWitness -> Integer
@ -218,9 +282,13 @@ getSaplingNotePosition =
updateSaplingWitness :: SaplingWitness -> [HexString] -> SaplingWitness updateSaplingWitness :: SaplingWitness -> [HexString] -> SaplingWitness
updateSaplingWitness wit cmus = updateSaplingWitness wit cmus =
SaplingWitness $ if not (null cmus)
withPureBorshVarBuffer $ then SaplingWitness $
rustWrapperUpdateSaplingWitness (toBytes $ sapWit wit) (map toBytes cmus) withPureBorshVarBuffer $
rustWrapperUpdateSaplingWitness
(toBytes $ sapWit wit)
(map toBytes cmus)
else wit
-- | Encode a SaplingReceiver into HRF text -- | Encode a SaplingReceiver into HRF text
encodeSaplingAddress :: ZcashNet -> SaplingReceiver -> Maybe T.Text encodeSaplingAddress :: ZcashNet -> SaplingReceiver -> Maybe T.Text

View file

@ -1,3 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
-- Copyright 2022-2024 Vergara Technologies LLC -- Copyright 2022-2024 Vergara Technologies LLC
-- --
-- This file is part of Zcash-Haskell. -- This file is part of Zcash-Haskell.
@ -172,27 +174,27 @@ decodeTransparentAddress taddress = do
-- | Encode an Exchange Addresss into HRF from TransparentReceiver -- | Encode an Exchange Addresss into HRF from TransparentReceiver
encodeExchangeAddress :: ZcashNet -> TransparentReceiver -> Maybe T.Text encodeExchangeAddress :: ZcashNet -> TransparentReceiver -> Maybe T.Text
encodeExchangeAddress net tr = do encodeExchangeAddress net tr = do
case (tr_type tr) of case tr_type tr of
P2PKH -> do P2PKH -> do
case net of case net of
MainNet -> do MainNet -> do
let vhash = encodeBech32m (BC.pack "tex") (toBytes (tr_bytes tr)) let vhash = encodeBech32m "tex" (toBytes (tr_bytes tr))
Just vhash Just vhash
TestNet -> do TestNet -> do
let vhash = encodeBech32m (BC.pack "textest") (toBytes (tr_bytes tr)) let vhash = encodeBech32m "textest" (toBytes (tr_bytes tr))
Just vhash Just vhash
_ -> Nothing _any -> Nothing
-- | Decode an Exchange Address into a ExchangeAddress -- | Decode an Exchange Address into a ExchangeAddress
decodeExchangeAddress :: T.Text -> Maybe ExchangeAddress decodeExchangeAddress :: BS.ByteString -> Maybe ExchangeAddress
decodeExchangeAddress ex = do decodeExchangeAddress ex = do
if (T.length ex) > 1 if BS.length ex > 1
then do then do
let rawd = decodeBech32 (E.encodeUtf8 ex) let rawd = decodeBech32 ex
let tMain = BS.unpack (BC.pack "tex") let tMain = "tex"
let tTest = BS.unpack (BC.pack "textest") let tTest = "textest"
let tFail = BS.unpack (BC.pack "fail") let tFail = "fail"
let hr = BS.unpack (hrp rawd) let hr = hrp rawd
if hr /= tFail if hr /= tFail
then do then do
let transparentReceiver = bytes rawd let transparentReceiver = bytes rawd

View file

@ -38,6 +38,7 @@ import Data.Maybe (fromJust, fromMaybe)
import Data.Structured import Data.Structured
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding as E
import qualified Data.Vector as V
import Data.Word import Data.Word
import qualified GHC.Generics as GHC import qualified GHC.Generics as GHC
import qualified Generics.SOP as SOP import qualified Generics.SOP as SOP
@ -90,7 +91,7 @@ data ZcashNet
= MainNet = MainNet
| TestNet | TestNet
| RegTestNet | RegTestNet
deriving (Eq, Prelude.Show, Read) deriving (Eq, Prelude.Show, Read, GHC.Generic, ToJSON, FromJSON)
type AccountId = Int type AccountId = Int
@ -133,6 +134,18 @@ data Transaction = Transaction
, tx_orchardBundle :: !(Maybe OrchardBundle) , tx_orchardBundle :: !(Maybe OrchardBundle)
} deriving (Prelude.Show, Eq, Read) } deriving (Prelude.Show, Eq, Read)
instance ToJSON Transaction where
toJSON (Transaction t h c e tb sb ob) =
object
[ "txid" .= t
, "height" .= h
, "confirmations" .= c
, "expiry" .= e
, "transparent" .= tb
, "sapling" .= sb
, "orchard" .= ob
]
-- | The transparent portion of a Zcash transaction -- | The transparent portion of a Zcash transaction
data TransparentBundle = TransparentBundle data TransparentBundle = TransparentBundle
{ tb_vin :: ![H.TxIn] { tb_vin :: ![H.TxIn]
@ -140,6 +153,10 @@ data TransparentBundle = TransparentBundle
, tb_coinbase :: !Bool , tb_coinbase :: !Bool
} deriving (Eq, Prelude.Show, Read) } deriving (Eq, Prelude.Show, Read)
instance ToJSON TransparentBundle where
toJSON (TransparentBundle vin vout c) =
object ["vin" .= vin, "vout" .= vout, "coinbase" .= c]
-- | Read a raw transparent bundle into the Haskell type -- | Read a raw transparent bundle into the Haskell type
fromRawTBundle :: RawTBundle -> Maybe TransparentBundle fromRawTBundle :: RawTBundle -> Maybe TransparentBundle
fromRawTBundle rtb = fromRawTBundle rtb =
@ -239,7 +256,8 @@ instance FromJSON RpcError where
-- ** `zcashd` -- ** `zcashd`
-- | Type to represent response from the `zcashd` RPC `getblock` method -- | Type to represent response from the `zcashd` RPC `getblock` method
data BlockResponse = BlockResponse data BlockResponse = BlockResponse
{ bl_confirmations :: !Integer -- ^ Block confirmations { bl_hash :: !HexString
, bl_confirmations :: !Integer -- ^ Block confirmations
, bl_height :: !Integer -- ^ Block height , bl_height :: !Integer -- ^ Block height
, bl_time :: !Integer -- ^ Block time , bl_time :: !Integer -- ^ Block time
, bl_txs :: ![HexString] -- ^ List of transaction IDs in the block , bl_txs :: ![HexString] -- ^ List of transaction IDs in the block
@ -252,7 +270,18 @@ instance FromJSON BlockResponse where
h <- obj .: "height" h <- obj .: "height"
t <- obj .:? "time" t <- obj .:? "time"
txs <- obj .: "tx" txs <- obj .: "tx"
pure $ BlockResponse c h (fromMaybe 0 t) txs hash <- obj .: "hash"
pure $ BlockResponse hash c h (fromMaybe 0 t) txs
instance ToJSON BlockResponse where
toJSON (BlockResponse h c ht t txs) =
object
[ "hash" .= h
, "confirmations" .= c
, "height" .= ht
, "time" .= t
, "tx" .= txs
]
-- | Type to represent response from the `zcashd` RPC `getrawtransaction` -- | Type to represent response from the `zcashd` RPC `getrawtransaction`
data RawTxResponse = RawTxResponse data RawTxResponse = RawTxResponse
@ -324,6 +353,10 @@ data SaplingBundle = SaplingBundle
, sbSig :: !HexString , sbSig :: !HexString
} deriving stock (Eq, Prelude.Show, GHC.Generic, Read) } deriving stock (Eq, Prelude.Show, GHC.Generic, Read)
instance ToJSON SaplingBundle where
toJSON (SaplingBundle s o v sig) =
object ["spends" .= s, "outputs" .= o, "value" .= v, "sig" .= sig]
fromRawSBundle :: RawSBundle -> Maybe SaplingBundle fromRawSBundle :: RawSBundle -> Maybe SaplingBundle
fromRawSBundle b = fromRawSBundle b =
if zsb_empty b if zsb_empty b
@ -355,6 +388,17 @@ data OrchardBundle = OrchardBundle
, obSig :: !HexString , obSig :: !HexString
} deriving stock (Eq, Prelude.Show, GHC.Generic, Read) } deriving stock (Eq, Prelude.Show, GHC.Generic, Read)
instance ToJSON OrchardBundle where
toJSON (OrchardBundle a f v an p s) =
object
[ "actions" .= a
, "flags" .= f
, "value" .= v
, "anchor" .= an
, "proof" .= p
, "sig" .= s
]
fromRawOBundle :: RawOBundle -> Maybe OrchardBundle fromRawOBundle :: RawOBundle -> Maybe OrchardBundle
fromRawOBundle b = fromRawOBundle b =
if zob_empty b if zob_empty b
@ -377,6 +421,10 @@ data OrchardFlags = OrchardFlags
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardFlags deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardFlags
instance ToJSON OrchardFlags where
toJSON (OrchardFlags s o) =
Data.Aeson.Array $ V.fromList [Data.Aeson.Bool s, Data.Aeson.Bool o]
-- | Type for the response from the `zebrad` RPC method `getinfo` -- | Type for the response from the `zebrad` RPC method `getinfo`
data ZebraGetInfo = ZebraGetInfo data ZebraGetInfo = ZebraGetInfo
{ zgi_build :: !T.Text { zgi_build :: !T.Text
@ -501,6 +549,17 @@ data ShieldedSpend = ShieldedSpend
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct ShieldedSpend deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct ShieldedSpend
instance ToJSON ShieldedSpend where
toJSON (ShieldedSpend cv a n rk p au) =
object
[ "cv" .= cv
, "anchor" .= a
, "nullifier" .= n
, "rk" .= rk
, "proof" .= p
, "spendAuthSig" .= au
]
instance FromJSON ShieldedSpend where instance FromJSON ShieldedSpend where
parseJSON = parseJSON =
withObject "ShieldedSpend" $ \obj -> do withObject "ShieldedSpend" $ \obj -> do
@ -525,6 +584,17 @@ data ShieldedOutput = ShieldedOutput
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct ShieldedOutput deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct ShieldedOutput
instance ToJSON ShieldedOutput where
toJSON (ShieldedOutput c cm e enc o p) =
object
[ "cv" .= c
, "cmu" .= cm
, "ephemeralKey" .= e
, "encCiphertext" .= enc
, "outCiphertext" .= o
, "proof" .= p
]
instance FromJSON ShieldedOutput where instance FromJSON ShieldedOutput where
parseJSON = parseJSON =
withObject "ShieldedOutput" $ \obj -> do withObject "ShieldedOutput" $ \obj -> do
@ -541,6 +611,30 @@ newtype SaplingCommitmentTree = SaplingCommitmentTree
{ sapTree :: HexString { sapTree :: HexString
} deriving (Eq, Prelude.Show, Read) } deriving (Eq, Prelude.Show, Read)
data SaplingRawTree = SaplingRawTree
{ srt_left :: !HexString
, srt_right :: !HexString
, srt_parents :: ![HexString]
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct SaplingRawTree
data SaplingTree = SaplingTree
{ st_left :: !(Maybe HexString)
, st_right :: !(Maybe HexString)
, st_parents :: ![Maybe HexString]
} deriving (Eq, Prelude.Show, Read)
data SaplingFrontier = SaplingFrontier
{ sf_pos :: !Int64
, sf_leaf :: !HexString
, sf_ommers :: ![HexString]
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct SaplingFrontier
-- | Type for a Sapling incremental witness -- | Type for a Sapling incremental witness
newtype SaplingWitness = SaplingWitness newtype SaplingWitness = SaplingWitness
{ sapWit :: HexString { sapWit :: HexString
@ -583,6 +677,14 @@ data RawUA = RawUA
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct RawUA deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct RawUA
-- | A type to handle user-entered addresses
data ValidAddress
= Unified !UnifiedAddress
| Sapling !SaplingAddress
| Transparent !TransparentAddress
| Exchange !ExchangeAddress
deriving stock (Eq, Prelude.Show)
-- | Type to represent a Unified Full Viewing Key -- | Type to represent a Unified Full Viewing Key
data UnifiedFullViewingKey = UnifiedFullViewingKey data UnifiedFullViewingKey = UnifiedFullViewingKey
{ net :: !Word8 -- ^ Number representing the network the key belongs to. @1@ for @mainnet@, @2@ for @testnet@ and @3@ for @regtestnet@. { net :: !Word8 -- ^ Number representing the network the key belongs to. @1@ for @mainnet@, @2@ for @testnet@ and @3@ for @regtestnet@.
@ -609,6 +711,19 @@ data OrchardAction = OrchardAction
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardAction deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardAction
instance ToJSON OrchardAction where
toJSON (OrchardAction n r c e en o cv a) =
object
[ "nullifier" .= n
, "rk" .= r
, "cmx" .= c
, "ephemeralKey" .= e
, "encCiphertext" .= en
, "outCiphertext" .= o
, "cv" .= cv
, "spendAuthSig" .= a
]
instance FromJSON OrchardAction where instance FromJSON OrchardAction where
parseJSON = parseJSON =
withObject "OrchardAction" $ \obj -> do withObject "OrchardAction" $ \obj -> do
@ -622,11 +737,43 @@ instance FromJSON OrchardAction where
a <- obj .: "spendAuthSig" a <- obj .: "spendAuthSig"
pure $ OrchardAction n r c ephKey encText outText cval a pure $ OrchardAction n r c ephKey encText outText cval a
data MerklePath = MerklePath
{ mp_position :: !Int32
, mp_path :: ![HexString]
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct MerklePath
-- | Type for a Orchard note commitment tree -- | Type for a Orchard note commitment tree
newtype OrchardCommitmentTree = OrchardCommitmentTree newtype OrchardCommitmentTree = OrchardCommitmentTree
{ orchTree :: HexString { orchTree :: HexString
} deriving (Eq, Prelude.Show, Read) } deriving (Eq, Prelude.Show, Read)
data OrchardRawTree = OrchardRawTree
{ ort_left :: !HexString
, ort_right :: !HexString
, ort_parents :: ![HexString]
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardRawTree
data OrchardTree = OrchardTree
{ ot_left :: !(Maybe HexString)
, ot_right :: !(Maybe HexString)
, ot_parents :: ![Maybe HexString]
} deriving (Eq, Prelude.Show, Read)
data OrchardFrontier = OrchardFrontier
{ of_pos :: !Int64
, of_leaf :: !HexString
, of_ommers :: ![HexString]
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardFrontier
-- | Type for a Sapling incremental witness -- | Type for a Sapling incremental witness
newtype OrchardWitness = OrchardWitness newtype OrchardWitness = OrchardWitness
{ orchWit :: HexString { orchWit :: HexString
@ -665,7 +812,7 @@ data TransparentTxSpend = TransparentTxSpend
data SaplingTxSpend = SaplingTxSpend data SaplingTxSpend = SaplingTxSpend
{ ss_sk :: !BS.ByteString { ss_sk :: !BS.ByteString
, ss_note :: !DecodedNote , ss_note :: !DecodedNote
, ss_iw :: !BS.ByteString , ss_iw :: !MerklePath
} deriving stock (Eq, Prelude.Show, GHC.Generic) } deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
@ -674,7 +821,7 @@ data SaplingTxSpend = SaplingTxSpend
data OrchardTxSpend = OrchardTxSpend data OrchardTxSpend = OrchardTxSpend
{ ss_sk :: !BS.ByteString { ss_sk :: !BS.ByteString
, ss_note :: !DecodedNote , ss_note :: !DecodedNote
, ss_iw :: !BS.ByteString , ss_iw :: !MerklePath
} deriving stock (Eq, Prelude.Show, GHC.Generic) } deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show) deriving anyclass (Data.Structured.Show)
@ -712,6 +859,7 @@ data TxError
| OrchardRecipient | OrchardRecipient
| SaplingBuilderNotAvailable | SaplingBuilderNotAvailable
| OrchardBuilderNotAvailable | OrchardBuilderNotAvailable
| PrivacyPolicyError !T.Text
| ZHError | ZHError
deriving (Eq, Prelude.Show, Read) deriving (Eq, Prelude.Show, Read)

View file

@ -123,53 +123,41 @@ readZebraTransaction hex =
rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex
createTransaction :: createTransaction ::
Maybe SaplingCommitmentTree -- ^ to obtain the Sapling anchor HexString -- ^ to obtain the Sapling anchor
-> Maybe OrchardCommitmentTree -- ^ to obtain the Orchard anchor -> HexString -- ^ to obtain the Orchard anchor
-> [TransparentTxSpend] -- ^ the list of transparent notes to spend -> [TransparentTxSpend] -- ^ the list of transparent notes to spend
-> [SaplingTxSpend] -- ^ the list of Sapling notes to spend -> [SaplingTxSpend] -- ^ the list of Sapling notes to spend
-> [OrchardTxSpend] -- ^ the list of Orchard notes to spend -> [OrchardTxSpend] -- ^ the list of Orchard notes to spend
-> [OutgoingNote] -- ^ the list of outgoing notes, including change notes -> [OutgoingNote] -- ^ the list of outgoing notes, including change notes
-> SaplingSpendParams -- ^ the Sapling circuit spending parameters
-> SaplingOutputParams -- ^ the Sapling circuit output parameters
-> ZcashNet -- ^ the network to be used -> ZcashNet -- ^ the network to be used
-> Int -- ^ target block height -> Int -- ^ target block height
-> Bool -- ^ True to build, False to estimate fee -> Bool -- ^ True to build, False to estimate fee
-> Either TxError HexString -> IO (Either TxError HexString)
createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oParams znet bh build = createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing znet bh build = do
processResult $! txResult txResult <-
where withBorshBufferOfInitSize 51200 $
processResult :: HexString -> Either TxError HexString rustWrapperCreateTx
processResult input = (hexBytes sapAnchor)
if BS.length (hexBytes input) > 1 (hexBytes orchAnchor)
then Right input tSpend
else case head (BS.unpack $ hexBytes input) of sSpend
0 -> Left InsufficientFunds oSpend
1 -> Left ChangeRequired outgoing
2 -> Left Fee (znet == MainNet)
3 -> Left Balance (fromIntegral bh)
4 -> Left TransparentBuild build
5 -> Left SaplingBuild if BS.length (hexBytes txResult) > 1
6 -> Left OrchardBuild then pure $ Right txResult
7 -> Left OrchardSpend else case head (BS.unpack $ hexBytes txResult) of
8 -> Left OrchardRecipient 0 -> pure $ Left InsufficientFunds
9 -> Left SaplingBuilderNotAvailable 1 -> pure $ Left ChangeRequired
10 -> Left OrchardBuilderNotAvailable 2 -> pure $ Left Fee
_ -> Left ZHError 3 -> pure $ Left Balance
txResult = 4 -> pure $ Left TransparentBuild
withPureBorshVarBuffer $ 5 -> pure $ Left SaplingBuild
rustWrapperCreateTx 6 -> pure $ Left OrchardBuild
(case sapAnchor of 7 -> pure $ Left OrchardSpend
Nothing -> "0" 8 -> pure $ Left OrchardRecipient
Just sA -> toBytes $ sapTree sA) 9 -> pure $ Left SaplingBuilderNotAvailable
(case orchAnchor of 10 -> pure $ Left OrchardBuilderNotAvailable
Nothing -> "0" _ -> pure $ Left ZHError
Just oA -> toBytes $ orchTree oA)
tSpend
sSpend
oSpend
outgoing
(sapSParams sParams)
(sapOParams oParams)
(znet == MainNet)
(fromIntegral bh)
build

View file

@ -40,6 +40,7 @@ import GHC.Float.RealFracMethods (properFractionDoubleInteger)
import Haskoin.Crypto.Hash (ripemd160) import Haskoin.Crypto.Hash (ripemd160)
import Haskoin.Crypto.Keys.Extended import Haskoin.Crypto.Keys.Extended
import Haskoin.Transaction.Common import Haskoin.Transaction.Common
import Network.HTTP.Simple (Response(..))
import Test.HUnit import Test.HUnit
import Test.Hspec import Test.Hspec
import Test.Hspec.QuickCheck import Test.Hspec.QuickCheck
@ -54,6 +55,7 @@ import ZcashHaskell.Sapling
, genSaplingInternalAddress , genSaplingInternalAddress
, genSaplingPaymentAddress , genSaplingPaymentAddress
, genSaplingSpendingKey , genSaplingSpendingKey
, getSaplingFrontier
, getSaplingNotePosition , getSaplingNotePosition
, getSaplingWitness , getSaplingWitness
, getShieldedOutputs , getShieldedOutputs
@ -72,6 +74,7 @@ import ZcashHaskell.Types
, OrchardAction(..) , OrchardAction(..)
, OrchardBundle(..) , OrchardBundle(..)
, OrchardCommitmentTree(..) , OrchardCommitmentTree(..)
, OrchardFrontier(..)
, OrchardSpendingKey(..) , OrchardSpendingKey(..)
, OrchardWitness(..) , OrchardWitness(..)
, Phrase(..) , Phrase(..)
@ -82,9 +85,12 @@ import ZcashHaskell.Types
, RawTxOut(..) , RawTxOut(..)
, RawTxResponse(..) , RawTxResponse(..)
, RawZebraTx(..) , RawZebraTx(..)
, RpcError(..)
, RpcResponse(..)
, SaplingAddress(..) , SaplingAddress(..)
, SaplingBundle(..) , SaplingBundle(..)
, SaplingCommitmentTree(..) , SaplingCommitmentTree(..)
, SaplingFrontier(..)
, SaplingReceiver(..) , SaplingReceiver(..)
, SaplingSpendingKey(..) , SaplingSpendingKey(..)
, SaplingWitness(..) , SaplingWitness(..)
@ -892,34 +898,36 @@ main = do
Just t' -> do Just t' -> do
let tb = zt_tBundle t' let tb = zt_tBundle t'
show tb `shouldNotBe` "" show tb `shouldNotBe` ""
describe "Sapling commitment trees" $ do {-
let tree = -describe "Sapling commitment trees" $ do
SaplingCommitmentTree $ - let tree =
hexString - SaplingCommitmentTree $
"01916df07670600aefa3b412a120d6b8d9a3d2ff9466a7ec770cd52d34ddb42313001000013c60b031a5e44650059fcc7101a3f551b807ab8b3a116a5a9c7fa0f3babbe735017c0d36686294ff19d59e58b6a2ac6a7ad607a804bc202c84012d8e94f233970c0128dbde5180af5304d8577376d78297130b615a327974c10881f6d876869aea05011b80b4ca60f74dfe33c78b062df73c84b8b44dab4604db16f5b61eea40134373010c96e4cc8a6a80fba0d41e4eb3070d80769104dc33fb61133b1304c15bf9e23e000107114fe4bb4cd08b47f6ae47477c182d5da9fe5c189061808c1091e9bf3b4524000001447d6b9100cddd5f80c8cf4ddee2b87eba053bd987465aec2293bd0514e68b0d015f6c95e75f4601a0a31670a7deb970fc8988c611685161d2e1629d0a1a0ebd07015f8b9205e0514fa235d75c150b87e23866b882b39786852d1ab42aab11d31a4a0117ddeb3a5f8d2f6b2d0a07f28f01ab25e03a05a9319275bb86d72fcaef6fc01501f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39" - hexString
let cmu1 = - "01916df07670600aefa3b412a120d6b8d9a3d2ff9466a7ec770cd52d34ddb42313001000013c60b031a5e44650059fcc7101a3f551b807ab8b3a116a5a9c7fa0f3babbe735017c0d36686294ff19d59e58b6a2ac6a7ad607a804bc202c84012d8e94f233970c0128dbde5180af5304d8577376d78297130b615a327974c10881f6d876869aea05011b80b4ca60f74dfe33c78b062df73c84b8b44dab4604db16f5b61eea40134373010c96e4cc8a6a80fba0d41e4eb3070d80769104dc33fb61133b1304c15bf9e23e000107114fe4bb4cd08b47f6ae47477c182d5da9fe5c189061808c1091e9bf3b4524000001447d6b9100cddd5f80c8cf4ddee2b87eba053bd987465aec2293bd0514e68b0d015f6c95e75f4601a0a31670a7deb970fc8988c611685161d2e1629d0a1a0ebd07015f8b9205e0514fa235d75c150b87e23866b882b39786852d1ab42aab11d31a4a0117ddeb3a5f8d2f6b2d0a07f28f01ab25e03a05a9319275bb86d72fcaef6fc01501f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39"
hexString - let cmu1 =
"45e47c5df6f5c5e48aa3526e977b2d1b57eda57214e36f06128008cb17b0125f" - hexString
let cmu2 = - "45e47c5df6f5c5e48aa3526e977b2d1b57eda57214e36f06128008cb17b0125f"
hexString - let cmu2 =
"426ef44b3b22e0eeda7e4d2b62bac63966572b224e50f97ee56c9490cde4910d" - hexString
let tree2 = - "426ef44b3b22e0eeda7e4d2b62bac63966572b224e50f97ee56c9490cde4910d"
hexString - let tree2 =
"01a47029e9b43722c57143a5d07681bff3e2315c9a28ad49d69e7c1f2f6e81ac160010000000000000012f4f72c03f8c937a94919a01a07f21165cc8394295291cb888ca91ed003810390107114fe4bb4cd08b47f6ae47477c182d5da9fe5c189061808c1091e9bf3b4524000001447d6b9100cddd5f80c8cf4ddee2b87eba053bd987465aec2293bd0514e68b0d015f6c95e75f4601a0a31670a7deb970fc8988c611685161d2e1629d0a1a0ebd07015f8b9205e0514fa235d75c150b87e23866b882b39786852d1ab42aab11d31a4a0117ddeb3a5f8d2f6b2d0a07f28f01ab25e03a05a9319275bb86d72fcaef6fc01501f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39" - hexString
it "Commitment tree is updated correctly" $ do - "01a47029e9b43722c57143a5d07681bff3e2315c9a28ad49d69e7c1f2f6e81ac160010000000000000012f4f72c03f8c937a94919a01a07f21165cc8394295291cb888ca91ed003810390107114fe4bb4cd08b47f6ae47477c182d5da9fe5c189061808c1091e9bf3b4524000001447d6b9100cddd5f80c8cf4ddee2b87eba053bd987465aec2293bd0514e68b0d015f6c95e75f4601a0a31670a7deb970fc8988c611685161d2e1629d0a1a0ebd07015f8b9205e0514fa235d75c150b87e23866b882b39786852d1ab42aab11d31a4a0117ddeb3a5f8d2f6b2d0a07f28f01ab25e03a05a9319275bb86d72fcaef6fc01501f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39"
let t1 = updateSaplingCommitmentTree tree cmu1 - it "Commitment tree is updated correctly" $ do
t1 `shouldNotBe` Nothing - let t1 = updateSaplingCommitmentTree tree cmu1
it "Incremental witness is generated" $ do - t1 `shouldNotBe` Nothing
let t1 = updateSaplingCommitmentTree tree cmu1 - it "Incremental witness is generated" $ do
case t1 of - let t1 = updateSaplingCommitmentTree tree cmu1
Nothing -> assertFailure "Failed to append node to tree" - case t1 of
Just t -> getSaplingWitness t `shouldNotBe` Nothing - Nothing -> assertFailure "Failed to append node to tree"
it "Position of note is obtained" $ do - Just t -> getSaplingWitness t `shouldNotBe` Nothing
let p = - it "Position of note is obtained" $ do
getSaplingNotePosition <$> - let p =
(getSaplingWitness =<< updateSaplingCommitmentTree tree cmu1) - getSaplingNotePosition <$>
p `shouldBe` Just 129405 - (getSaplingWitness =<< updateSaplingCommitmentTree tree cmu1)
describe "Orchard commitment trees" $ do - p `shouldBe` Just 129405
-}
{- describe "Orchard commitment trees" $ do
let tree = let tree =
OrchardCommitmentTree $ OrchardCommitmentTree $
hexString hexString
@ -939,7 +947,7 @@ main = do
let p = let p =
getOrchardNotePosition <$> getOrchardNotePosition <$>
(getOrchardWitness =<< updateOrchardCommitmentTree tree cmx) (getOrchardWitness =<< updateOrchardCommitmentTree tree cmx)
p `shouldBe` Just 39432 p `shouldBe` Just 39432 -}
describe "Extract Sapling Address - UA Valid" $ do describe "Extract Sapling Address - UA Valid" $ do
let sr = let sr =
getSaplingFromUA getSaplingFromUA
@ -1058,18 +1066,22 @@ main = do
(hexString (hexString
"97e5f003d16720844ba1bd157688a7697133f4bb4a33a7c91974937a1351d7af56d16d4a10bd196ddda700fcd8be517f8f9e39a17ba0eea235d98450a626be3a998ac31f35e8e082106a31fe94da11d02b73748db4aa519df6bbf25c1d62a2cf0b192c6a486bca2632fee9e4124ce2dba6f3366a14850f6a3b784d863119f52458ed774f8d63105b4f6a3d2e09cc74e3a02ec8386213087b4c849172ded6724a45c9c12744ec4a0f86a29b803b17187df5dd5f90e71d1f3f4578d4e1496e8892") "97e5f003d16720844ba1bd157688a7697133f4bb4a33a7c91974937a1351d7af56d16d4a10bd196ddda700fcd8be517f8f9e39a17ba0eea235d98450a626be3a998ac31f35e8e082106a31fe94da11d02b73748db4aa519df6bbf25c1d62a2cf0b192c6a486bca2632fee9e4124ce2dba6f3366a14850f6a3b784d863119f52458ed774f8d63105b4f6a3d2e09cc74e3a02ec8386213087b4c849172ded6724a45c9c12744ec4a0f86a29b803b17187df5dd5f90e71d1f3f4578d4e1496e8892")
it "Sap output 1" $ do it "Sap output 1" $ do
let pos = case getSaplingFrontier tree of
getSaplingNotePosition <$> Nothing -> assertFailure "failed to read comm tree"
(getSaplingWitness =<< Just tree' -> do
updateSaplingCommitmentTree let pos =
tree sf_pos <$>
(fromText updateSaplingCommitmentTree
"fa430c51bb108db782764cff55de9c6b11bbecd2493d2e0fa9f646428feef858")) tree'
case pos of (fromText
Nothing -> assertFailure "couldn't get note position" "fa430c51bb108db782764cff55de9c6b11bbecd2493d2e0fa9f646428feef858")
Just p -> do case pos of
let dn = decodeSaplingOutputEsk sk so1 TestNet External p Nothing -> assertFailure "couldn't get note position"
dn `shouldBe` Nothing Just p -> do
let dn =
decodeSaplingOutputEsk sk so1 TestNet External $
fromIntegral p
dn `shouldBe` Nothing
it "Sap output 2" $ do it "Sap output 2" $ do
case readZebraTransaction txHex2 of case readZebraTransaction txHex2 of
Nothing -> assertFailure "Failed to read Tx" Nothing -> assertFailure "Failed to read Tx"
@ -1079,24 +1091,27 @@ main = do
Nothing -> assertFailure "Failed to get sapling bundle" Nothing -> assertFailure "Failed to get sapling bundle"
Just sB -> do Just sB -> do
let sOuts = sbOutputs sB let sOuts = sbOutputs sB
let pos = case getSaplingFrontier tree of
getSaplingNotePosition <$> Nothing -> assertFailure "Failed to read tree"
(getSaplingWitness =<< Just tree' -> do
updateSaplingCommitmentTree let pos =
tree getSaplingNotePosition <$>
(fromText (getSaplingWitness =<<
"d163c69029e8cb05d874b798c7973b3b1b1b0e04f984a252b73c848698320843")) updateSaplingCommitmentTree
case pos of tree'
Nothing -> assertFailure "couldn't get note position" (fromText
Just p -> do "d163c69029e8cb05d874b798c7973b3b1b1b0e04f984a252b73c848698320843"))
let dn = case pos of
decodeSaplingOutputEsk Nothing -> assertFailure "couldn't get note position"
sk Just p -> do
(head . tail $ sOuts) let dn =
TestNet decodeSaplingOutputEsk
External sk
p (head . tail $ sOuts)
dn `shouldBe` Nothing TestNet
External
p
dn `shouldBe` Nothing
it "Decode Sapling Output from Zingo" $ do it "Decode Sapling Output from Zingo" $ do
case readZebraTransaction txHex of case readZebraTransaction txHex of
Nothing -> assertFailure "Failed to read Tx" Nothing -> assertFailure "Failed to read Tx"
@ -1109,24 +1124,26 @@ main = do
Nothing -> assertFailure "Failed to get sapling bundle" Nothing -> assertFailure "Failed to get sapling bundle"
Just sB -> do Just sB -> do
let sOuts = sbOutputs sB let sOuts = sbOutputs sB
let pos = case getSaplingFrontier tree of
getSaplingNotePosition <$> Nothing -> assertFailure "failed to read comm tree"
(getSaplingWitness =<< Just tree' -> do
updateSaplingCommitmentTree let pos =
tree sf_pos <$>
(fromText updateSaplingCommitmentTree
"d163c69029e8cb05d874b798c7973b3b1b1b0e04f984a252b73c848698320843")) tree'
case pos of (fromText
Nothing -> assertFailure "couldn't get note position" "d163c69029e8cb05d874b798c7973b3b1b1b0e04f984a252b73c848698320843")
Just p -> do case pos of
let dn = Nothing -> assertFailure "couldn't get note position"
decodeSaplingOutputEsk Just p -> do
sK' let dn =
(head . tail $ sOuts) decodeSaplingOutputEsk
MainNet sK'
External (head . tail $ sOuts)
p MainNet
dn `shouldNotBe` Nothing External
(fromIntegral p)
dn `shouldNotBe` Nothing
describe "Generate an ExchangeAddress (MainNet) from transparent address" $ do describe "Generate an ExchangeAddress (MainNet) from transparent address" $ do
let ta = decodeTransparentAddress "t1dMjvesbzdG41xgKaGU3HgwYJwSgbCK54e" let ta = decodeTransparentAddress "t1dMjvesbzdG41xgKaGU3HgwYJwSgbCK54e"
it "Try to generate valid ExchangeAddress from Transparent Address" $ do it "Try to generate valid ExchangeAddress from Transparent Address" $ do
@ -1143,8 +1160,44 @@ main = do
case exch of case exch of
Nothing -> assertFailure "Failed to encode Exchange address" Nothing -> assertFailure "Failed to encode Exchange address"
Just addr -> do Just addr -> do
let eadr = decodeExchangeAddress addr let eadr = decodeExchangeAddress (E.encodeUtf8 addr)
eadr `shouldNotBe` Nothing eadr `shouldNotBe` Nothing
describe "Tree updates" $ do
it "Orchard" $ do
let tree =
OrchardCommitmentTree $
hexString
"0136a7886d7d73bc1845223165fd9cb0cef02046c707e8f88a7f61564720bd0f3501dca1fbdd7b5ba92a0809af5e85874626ce0db14d0532a48e41dde6f0f81b46011f0001fb48c27bd07e68f27aba47cd6e93fa961e0ef8c63f993963a614e56855d2013c0001ea572db9c5c2d24c7ad9132ae32b27179466bf67a580d59901d13b281d3f530b01c160348f10b9ad893d9731317ebe36ac8665e01c52cbe15a56aa9b72e4e6c41e000001cd7695156de2debdc5b13ea84d32e4e3ac020fb0aa7cd372c57ce765103bd70401746e6bc066a10e7f80a9ff8993dcb25c819edd64f2ca10ac248ef7848d41450500011e6191f91b3fceb62dc881a156e1b9d2e88e09dca25093cf9c4936c8869fb41a013bf8b923e4187754e85175748d9cce4824a6787e4258977b5bfe1ba59012c032000001f3bbdc62260c4fca5c84bf3487246d4542da48eeeec8ec40c1029b6908eef83c00000000000000000000000000000000"
let cmx1 =
hexString
"1712ead46028d4349e234abf59e94e0640fe7a0829e2e2e17e1a931631810400"
let cmx2 =
hexString
"39f5ad39817fb432fa07c5feb3a957189fbe7662a4b5555ca95093b6d853cf07"
let cmx3 =
hexString
"84f7fbc4b9f87215c653078d7fdd90756c3ba370c745065167da9eb73a65a83f"
let cmx4 =
hexString
"e55ad64e1ea2b261893fdea6ad0509b66e5f62d3142f351298c7135c4498d429"
let finalTree =
getOrchardFrontier $
OrchardCommitmentTree $
hexString
"0184f7fbc4b9f87215c653078d7fdd90756c3ba370c745065167da9eb73a65a83f01e55ad64e1ea2b261893fdea6ad0509b66e5f62d3142f351298c7135c4498d4291f0000014b1a76d3820087b26cd087ca84e17f3067a25ebed82ad23a93fa485affb5530b01ea572db9c5c2d24c7ad9132ae32b27179466bf67a580d59901d13b281d3f530b01c160348f10b9ad893d9731317ebe36ac8665e01c52cbe15a56aa9b72e4e6c41e000001cd7695156de2debdc5b13ea84d32e4e3ac020fb0aa7cd372c57ce765103bd70401746e6bc066a10e7f80a9ff8993dcb25c819edd64f2ca10ac248ef7848d41450500011e6191f91b3fceb62dc881a156e1b9d2e88e09dca25093cf9c4936c8869fb41a013bf8b923e4187754e85175748d9cce4824a6787e4258977b5bfe1ba59012c032000001f3bbdc62260c4fca5c84bf3487246d4542da48eeeec8ec40c1029b6908eef83c00000000000000000000000000000000"
case getOrchardFrontier tree of
Nothing -> assertFailure "Failed to get frontier"
Just t1 ->
case updateOrchardCommitmentTree t1 cmx1 of
Nothing -> assertFailure "Failed to update frontier with cmx"
Just t2 -> do
case getOrchardWitness t2 of
Nothing -> assertFailure "Failed to get witness"
Just wit -> do
let uWit = updateOrchardWitness wit [cmx2, cmx3, cmx4]
Just (getOrchardWitnessAnchor uWit) `shouldBe`
getOrchardTreeAnchor <$>
finalTree
describe "Witness updates" $ do describe "Witness updates" $ do
it "Sapling" $ do it "Sapling" $ do
let wit = let wit =
@ -1179,7 +1232,7 @@ main = do
updateOrchardWitness wit cmxs `shouldBe` updateOrchardWitness wit cmxs `shouldBe`
OrchardWitness OrchardWitness
(hexString (hexString
"016225b41339a00dd764b452fca190a0245e7118224965942e3a6d798365c34631001f0000011d6f5da3f619bfaab957fc643c17eb144db0101c90f422da2fcbe0e80d74412e000000000001746e6bc066a10e7f80a9ff8993dcb25c819edd64f2ca10ac248ef7848d41450500011e6191f91b3fceb62dc881a156e1b9d2e88e09dca25093cf9c4936c8869fb41a013bf8b923e4187754e85175748d9cce4824a6787e4258977b5bfe1ba59012c032000001f3bbdc62260c4fca5c84bf3487246d4542da48eeeec8ec40c1029b6908eef83c00000000000000000000000000000000040e02c864db8b574f165f616d48e2f12eb25099b5c90186af26d9e50f5058863e0504bfbc12edc35e05042c16bbfb8fed591f01f18fe128eeb57f2c456c9eb222d6d261c549e95d9007bce4c6ae0b86bc865711cdd9f0fa92e2d5b5e149b51f3be127df3b1d2372adf6c811b2e456c1d64d0e9eb167a995f9c6b66a03c9cbda250101c094201bae3b4ef582a3e8654f65a72fbd41e20e1ec9a43d3f4101afc868731e0002010cfb50d8c877eb39e9c07082a032dd99d34be7c19fa7f30e9fecf5f14736240f019df5b9366d0f21caa678d1567390b5bfd3cfa0438271bcfe301b5558a2863301") "016225b41339a00dd764b452fca190a0245e7118224965942e3a6d798365c34631001f0000011d6f5da3f619bfaab957fc643c17eb144db0101c90f422da2fcbe0e80d74412e000000000001746e6bc066a10e7f80a9ff8993dcb25c819edd64f2ca10ac248ef7848d41450500011e6191f91b3fceb62dc881a156e1b9d2e88e09dca25093cf9c4936c8869fb41a013bf8b923e4187754e85175748d9cce4824a6787e4258977b5bfe1ba59012c032000001f3bbdc62260c4fca5c84bf3487246d4542da48eeeec8ec40c1029b6908eef83c00000000000000000000000000000000040e02c864db8b574f165f616d48e2f12eb25099b5c90186af26d9e50f5058863e0504bfbc12edc35e05042c16bbfb8fed591f01f18fe128eeb57f2c456c9eb222d6d261c549e95d9007bce4c6ae0b86bc865711cdd9f0fa92e2d5b5e149b51f3be127df3b1d2372adf6c811b2e456c1d64d0e9eb167a995f9c6b66a03c9cbda250101c094201bae3b4ef582a3e8654f65a72fbd41e20e1ec9a43d3f4101afc868731e01ac20b8170b008888c19fc6e16f5e30a5ef1653e5219d0cd0c9353c3aa8f7982302010cfb50d8c877eb39e9c07082a032dd99d34be7c19fa7f30e9fecf5f14736240f019df5b9366d0f21caa678d1567390b5bfd3cfa0438271bcfe301b5558a2863301")
-- | Properties -- | Properties
prop_PhraseLength :: Property prop_PhraseLength :: Property

View file

@ -5,7 +5,7 @@ cabal-version: 3.0
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: zcash-haskell name: zcash-haskell
version: 0.6.2.1 version: 0.7.5.0
synopsis: Utilities to interact with the Zcash blockchain synopsis: Utilities to interact with the Zcash blockchain
description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme> description: Please see the README on the repo at <https://git.vergara.tech/Vergara_Tech/zcash-haskell#readme>
category: Blockchain category: Blockchain
@ -59,6 +59,7 @@ library
, text , text
, haskoin-core , haskoin-core
, secp256k1-haskell >= 1.1 , secp256k1-haskell >= 1.1
, vector
, utf8-string , utf8-string
build-tool-depends: build-tool-depends:
c2hs:c2hs c2hs:c2hs
@ -85,5 +86,6 @@ test-suite zcash-haskell-test
, binary , binary
, cryptonite , cryptonite
, secp256k1-haskell , secp256k1-haskell
, http-conduit
pkgconfig-depends: rustzcash_wrapper pkgconfig-depends: rustzcash_wrapper
default-language: Haskell2010 default-language: Haskell2010