Compare commits

...

45 commits

Author SHA1 Message Date
5349498737
Merge pull request 'Upgrade to GHC 9.6.5' (#84) from rav001 into master
Reviewed-on: #84
2024-07-01 21:07:52 +00:00
812ff0aa70
Upgrade to GHC 9.6.5 2024-07-01 16:05:33 -05:00
874db2907e
Performance enhancement for transaction creation 2024-05-16 10:42:44 -05:00
4165cab701
Merge branch 'dev040' 2024-05-13 14:25:46 -05:00
9dddb42bb3
Merge pull request 'Implement fee calculator' (#81) from rav001 into dev040
Reviewed-on: #81
2024-05-08 18:51:34 +00:00
148abd95d0
Implement fee calculator 2024-05-08 13:49:39 -05:00
4ca5d07d1c
Merge pull request 'Fix bug in Orchard witness calculation' (#80) from rav001 into dev040
Reviewed-on: #80
2024-05-07 20:21:19 +00:00
37b485288d
Fix bug in Orchard witness calculation 2024-05-07 15:19:54 -05:00
302a2f87fa
Merge pull request 'Remove debugging' (#79) from rav001 into dev040
Reviewed-on: #79
2024-05-07 17:17:29 +00:00
2108f46afa
Remove debugging 2024-05-07 12:13:54 -05:00
22c0fe3749
Merge pull request 'Transaction creation updates' (#78) from rav001 into dev040
Reviewed-on: #78
2024-05-02 19:59:25 +00:00
1e31bb73c2
Update Rust debugging 2024-05-02 14:55:24 -05:00
c583451c83
Update debugging 2024-05-02 14:30:59 -05:00
6a632d45c1
Change error messaging 2024-05-02 14:07:54 -05:00
31c5cda65a
Improve error message 2024-05-02 13:38:12 -05:00
d5e17afc99
Debugging parameters 2024-05-02 13:34:26 -05:00
c7f2bca2c4
Remove ovk from transaction creation 2024-05-02 12:48:30 -05:00
2d14ef6b22
Update to use commitment trees for anchors 2024-05-02 12:35:36 -05:00
652e95c361
Improve error messaging 2024-05-02 12:10:53 -05:00
c144a6d624
Add more debugging to Rust 2024-05-02 07:31:01 -05:00
5fd33e7e43
Add debuggin for create transaction 2024-05-02 07:22:12 -05:00
8dbcf58a93
Merge pull request 'Fix typo in constructor' (#77) from rav001 into dev040
Reviewed-on: #77
2024-05-01 21:15:50 +00:00
bea4d2f071
Fix typo in constructor 2024-05-01 16:14:41 -05:00
61a35a034b
Merge pull request 'Add transparent key derivation' (#76) from rav001 into dev040
Reviewed-on: #76
2024-05-01 19:30:48 +00:00
bc074d0386
Add transparent key derivation 2024-05-01 14:24:18 -05:00
4a48769eeb
Merge pull request 'Add functionality for transaction creation' (#75) from rav001 into dev040
Reviewed-on: #75
2024-05-01 14:14:40 +00:00
6b391ef7d2
Merge branch 'dev040' into rav001 2024-05-01 14:14:28 +00:00
787cf40629
Add functionality for transaction creation 2024-05-01 09:12:58 -05:00
91707e13c2
Merge pull request 'Add Read instance to Rseed' (#74) from rav001 into dev040
Reviewed-on: #74
2024-05-01 00:17:18 +00:00
26a79443a7
Add Read instance to Rseed 2024-04-30 19:14:30 -05:00
c9f13643e4
Merge pull request 'Implement transaction creation' (#73) from rav001 into dev040
Reviewed-on: #73
2024-04-30 21:56:10 +00:00
ad9e2f074d
Implement transaction creation 2024-04-30 16:54:15 -05:00
f456332454
Merge pull request 'Upgrade of Rust crates' (#72) from rav001 into dev040
Reviewed-on: #72
2024-04-29 15:31:41 +00:00
201df05e9b
Merge branch 'dev040' into rav001 2024-04-29 10:29:09 -05:00
8901d97c64
Upgrade of Zcash Rust crates 2024-04-29 10:27:45 -05:00
619c80c816
Merge pull request 'Add witness update functionality' (#71) from rav001 into dev040
Reviewed-on: #71
2024-04-26 01:00:18 +00:00
24ae69cddb
Merge branch 'dev040' into rav001 2024-04-26 01:00:01 +00:00
af9806d72d
Add witness update functionality 2024-04-25 19:56:29 -05:00
00400c433d
Merge pull request 'Update note position calculation' (#70) from rav001 into dev040
Reviewed-on: #70
2024-04-24 22:28:05 +00:00
b74cd5f354
Update note position calculation 2024-04-24 16:04:56 -05:00
586cb4646c
Merge pull request 'Fix Sapling spend parsing' (#69) from rav001 into dev040
Reviewed-on: #69
2024-04-24 17:02:40 +00:00
6cf5d85c0b
Merge branch 'dev040' into rav001 2024-04-24 12:01:13 -05:00
f4612a7310
Merge pull request 'rvv040' (#67) from rvv040 into dev040
Reviewed-on: #67
2024-04-24 17:00:41 +00:00
3296909c82
Fix Sapling spend parsing 2024-04-24 11:57:00 -05:00
11a951f62a Add a new line character at the start of the script 2024-01-17 18:10:53 -05:00
15 changed files with 1428 additions and 282 deletions

View file

@ -5,18 +5,89 @@ 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.6.2.1]
### Changed
- Modified the parsing of raw transactions for shielded outputs
- Upgraded to GHC 9.6.5
## [0.6.2.0]
### Changed
- Performance enhancement for transaction creation
## [0.6.1.1]
### Added
- Type for transaction creation errors
- Types for Sapling circuit parameters
- Function to create transaction
- Function to derive distinct transparent spending keys
### Changed
- Add `Read` instance for `Rseed`
## [0.6.1.0]
### Added
- Function to create a raw transaction
- New types for transaction creation:
- `Rseed`
- `TransparentTxSpend`
- `SaplingTxSpend`
- `OrchardTxSpend`
- `OutgoingNote`
- Rust crates:
- `secp256k1`
- `jubjub`
- `rand_core`
### Changed
- `DecodedNote` type now includes a field for `rho` and one for `rseed`
## [0.6.0.0]
### Added
- Rust crates:
- `sapling-crypto` 0.1.3
### Changed
- Modified handling of `ShieldedOutput`s based on new Rust crates
- Upgraded Rust crates:
- `orchard` to 0.7.1
- `zcash_primitives` to 0.14.0
- `zcash_client_backend` to 0.11.1
## [0.5.5.4]
### Added
- Functions to update Sapling witnesses.
- Functions to update Orchard witnesses.
## [0.5.5.3] ## [0.5.5.3]
### Added ### Added
- Added unction to generate an ExchangeAddress in Human Readable Format Using a TransparentAddress in HRF - Added function to generate an `ExchangeAddress` in Human Readable Format Using a `TransparentAddress` in HRF
`encodeExchangeAddress` a function to create a ExchangeAddress in HRF - `encodeExchangeAddress` a function to create a `ExchangeAddress` in HRF
`decodeExchangeAddress` a function to obtaina a TransparentAddress object from an ExchangeAddress in HRF - `decodeExchangeAddress` a function to obtain a `TransparentAddress` object from an `ExchangeAddress` in HRF
- Added new type ExchangeAddress - Added new type `ExchangeAddress`
### Fixed ### Fixed
- Orchard note nullifier calculation - Orchard note nullifier calculation
- Sapling spend field parsing
## [0.5.5.2] ## [0.5.5.2]

View file

@ -1,6 +1,6 @@
packages: ./*.cabal packages: ./*.cabal
with-compiler: ghc-9.4.8 with-compiler: ghc-9.6.5
source-repository-package source-repository-package
type: git type: git

View file

@ -1,40 +1,40 @@
active-repositories: hackage.haskell.org:merge active-repositories: hackage.haskell.org:merge
constraints: any.Cabal ==3.8.1.0, constraints: any.Cabal ==3.10.3.0,
any.Cabal-syntax ==3.8.1.0, any.Cabal-syntax ==3.10.3.0,
any.HUnit ==1.6.2.0, any.HUnit ==1.6.2.0,
any.OneTuple ==0.4.1.1, any.OneTuple ==0.4.2,
any.QuickCheck ==2.14.3, any.QuickCheck ==2.14.3,
QuickCheck -old-random +templatehaskell, QuickCheck -old-random +templatehaskell,
any.StateVar ==1.2.2, any.StateVar ==1.2.2,
any.aeson ==2.2.1.0, any.aeson ==2.2.3.0,
aeson +ordered-keymap, aeson +ordered-keymap,
any.alex ==3.5.1.0, any.alex ==3.5.1.0,
any.ansi-terminal ==1.1, any.ansi-terminal ==1.1.1,
ansi-terminal -example, ansi-terminal -example,
any.ansi-terminal-types ==1.1, any.ansi-terminal-types ==1.1,
any.appar ==0.1.8, any.appar ==0.1.8,
any.array ==0.5.4.0, any.array ==0.5.6.0,
any.asn1-encoding ==0.9.6, any.asn1-encoding ==0.9.6,
any.asn1-parse ==0.9.5, any.asn1-parse ==0.9.5,
any.asn1-types ==0.3.4, any.asn1-types ==0.3.4,
any.assoc ==1.1, any.assoc ==1.1.1,
assoc +tagged, assoc -tagged,
any.async ==2.2.5, any.async ==2.2.5,
async -bench, async -bench,
any.attoparsec ==0.14.4, any.attoparsec ==0.14.4,
attoparsec -developer, attoparsec -developer,
any.attoparsec-aeson ==2.2.0.1, any.attoparsec-aeson ==2.2.2.0,
any.base ==4.17.2.1, any.base ==4.18.2.1,
any.base-orphans ==0.9.1, any.base-orphans ==0.9.2,
any.base16 ==1.0, any.base16 ==1.0,
any.base16-bytestring ==1.0.2.0, any.base16-bytestring ==1.0.2.0,
any.base58-bytestring ==0.1.0, any.base58-bytestring ==0.1.0,
any.base64-bytestring ==1.2.1.0, any.base64-bytestring ==1.2.1.0,
any.basement ==0.0.16, any.basement ==0.0.16,
any.bifunctors ==5.6.1, any.bifunctors ==5.6.2,
bifunctors +tagged, bifunctors +tagged,
any.binary ==0.8.9.1, any.binary ==0.8.9.1,
any.binary-orphans ==1.0.4.1, any.binary-orphans ==1.0.5,
any.bitvec ==1.1.5.0, any.bitvec ==1.1.5.0,
bitvec +simd, bitvec +simd,
any.blaze-builder ==0.4.2.3, any.blaze-builder ==0.4.2.3,
@ -50,6 +50,7 @@ constraints: any.Cabal ==3.8.1.0,
cborg +optimize-gmp, cborg +optimize-gmp,
any.cereal ==0.5.8.3, any.cereal ==0.5.8.3,
cereal -bytestring-builder, cereal -bytestring-builder,
any.character-ps ==0.1,
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,
@ -59,10 +60,10 @@ constraints: any.Cabal ==3.8.1.0,
any.contravariant ==1.5.5, any.contravariant ==1.5.5,
contravariant +semigroups +statevar +tagged, contravariant +semigroups +statevar +tagged,
any.cookie ==0.5.0, any.cookie ==0.5.0,
any.crypton ==0.34, any.crypton ==1.0.0,
crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes, crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes,
any.crypton-connection ==0.3.2, any.crypton-connection ==0.4.1,
any.crypton-x509 ==1.7.6, any.crypton-x509 ==1.7.7,
any.crypton-x509-store ==1.6.9, any.crypton-x509-store ==1.6.9,
any.crypton-x509-system ==1.6.7, any.crypton-x509-system ==1.6.7,
any.crypton-x509-validation ==1.6.12, any.crypton-x509-validation ==1.6.12,
@ -73,49 +74,47 @@ constraints: any.Cabal ==3.8.1.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.2, any.data-fix ==0.3.3,
any.deepseq ==1.4.8.0, any.deepseq ==1.4.8.1,
any.directory ==1.3.7.1, any.directory ==1.3.8.4,
any.distributive ==0.6.2.1, any.distributive ==0.6.2.1,
distributive +semigroups +tagged, distributive +semigroups +tagged,
any.dlist ==1.0, any.dlist ==1.0,
dlist -werror, dlist -werror,
any.entropy ==0.4.1.10, any.entropy ==0.4.1.10,
entropy -donotgetentropy, entropy -donotgetentropy,
any.envy ==2.1.2.0, any.envy ==2.1.3.0,
any.exceptions ==0.10.5, any.exceptions ==0.10.7,
any.filepath ==1.4.2.2, any.filepath ==1.4.300.1,
any.foldable1-classes-compat ==0.1,
foldable1-classes-compat +tagged,
any.foreign-rust ==0.1.0, any.foreign-rust ==0.1.0,
any.generically ==0.1.1, any.generically ==0.1.1,
any.generics-sop ==0.5.1.4, any.generics-sop ==0.5.1.4,
any.ghc-bignum ==1.3, any.ghc-bignum ==1.3,
any.ghc-boot-th ==9.4.8, any.ghc-boot-th ==9.6.5,
any.ghc-prim ==0.9.1, any.ghc-prim ==0.10.0,
any.half ==0.3.1, any.half ==0.3.1,
any.happy ==1.20.1.1, any.happy ==1.20.1.1,
any.hashable ==1.4.3.0, any.hashable ==1.4.7.0,
hashable +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,
any.haskoin-core ==1.0.4, any.haskoin-core ==1.1.0,
any.hexstring ==0.12.1.0, any.hexstring ==0.12.1.0,
any.hourglass ==0.2.12, any.hourglass ==0.2.12,
any.hsc2hs ==0.68.10, any.hsc2hs ==0.68.10,
hsc2hs -in-ghc-tree, hsc2hs -in-ghc-tree,
any.hspec ==2.11.7, any.hspec ==2.11.9,
any.hspec-core ==2.11.7, any.hspec-core ==2.11.9,
any.hspec-discover ==2.11.7, any.hspec-discover ==2.11.9,
any.hspec-expectations ==0.8.4, any.hspec-expectations ==0.8.4,
any.http-client ==0.7.16, 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.8.3,
http-conduit +aeson, http-conduit +aeson,
any.http-types ==0.12.4, any.http-types ==0.12.4,
any.indexed-traversable ==0.1.3, any.indexed-traversable ==0.1.4,
any.indexed-traversable-instances ==0.1.1.2, any.indexed-traversable-instances ==0.1.2,
any.integer-conversion ==0.1.0.1, any.integer-conversion ==0.1.1,
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,
@ -126,19 +125,21 @@ constraints: any.Cabal ==3.8.1.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.17.0,
any.mtl ==2.2.2, any.mtl ==2.3.1,
any.murmur3 ==1.0.5, any.murmur3 ==1.0.5,
any.network ==3.1.4.0, any.network ==3.2.1.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,
any.old-time ==1.1.0.4, any.old-time ==1.1.0.4,
any.os-string ==2.0.6,
any.parsec ==3.1.16.1, any.parsec ==3.1.16.1,
any.pem ==0.2.4, any.pem ==0.2.4,
any.pretty ==1.1.3.6, any.pretty ==1.1.3.6,
any.primitive ==0.9.0.0, any.primitive ==0.9.0.0,
any.process ==1.6.18.0, any.process ==1.6.19.0,
any.quickcheck-io ==0.2.0, any.quickcheck-io ==0.2.0,
any.quickcheck-transformer ==0.3.1.2,
any.random ==1.2.1.2, any.random ==1.2.1.2,
any.regex-base ==0.94.0.2, any.regex-base ==0.94.0.2,
any.regex-compat ==0.95.2.1, any.regex-compat ==0.95.2.1,
@ -147,12 +148,12 @@ constraints: any.Cabal ==3.8.1.0,
any.resourcet ==1.3.0, any.resourcet ==1.3.0,
any.rts ==1.0.2, any.rts ==1.0.2,
any.safe ==0.3.21, any.safe ==0.3.21,
any.scientific ==0.3.7.0, any.scientific ==0.3.8.0,
scientific -bytestring-builder -integer-simple, scientific -integer-simple,
any.secp256k1-haskell ==1.1.0, any.secp256k1-haskell ==1.2.0,
any.semialign ==1.3, any.semialign ==1.3.1,
semialign +semigroupoids, semialign +semigroupoids,
any.semigroupoids ==6.0.0.1, any.semigroupoids ==6.0.1,
semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers, semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers,
any.serialise ==0.2.6.1, any.serialise ==0.2.6.1,
serialise +newtime15, serialise +newtime15,
@ -168,40 +169,39 @@ constraints: any.Cabal ==3.8.1.0,
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,
any.template-haskell ==2.19.0.0, any.template-haskell ==2.20.0.0,
any.text ==2.0.2, any.text ==2.0.2,
any.text-iso8601 ==0.1, any.text-iso8601 ==0.1.1,
any.text-short ==0.1.5, any.text-short ==0.1.6,
text-short -asserts, text-short -asserts,
any.tf-random ==0.5, any.tf-random ==0.5,
any.th-abstraction ==0.6.0.0, any.th-abstraction ==0.7.0.0,
any.th-compat ==0.1.4, any.th-compat ==0.1.5,
any.these ==1.2, any.these ==1.2.1,
any.time ==1.12.2, any.time ==1.12.2,
any.time-compat ==1.9.6.1, any.time-compat ==1.9.7,
time-compat -old-locale, any.tls ==2.1.0,
any.tls ==2.0.1,
tls -devel, tls -devel,
any.transformers ==0.5.6.2, 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.11.1,
any.unix ==2.7.3, any.unix ==2.8.4.0,
any.unix-time ==0.4.12, any.unix-time ==0.4.15,
any.unliftio-core ==0.2.1.0, any.unliftio-core ==0.2.1.0,
any.unordered-containers ==0.2.20, any.unordered-containers ==0.2.20,
unordered-containers -debug, unordered-containers -debug,
any.utf8-string ==1.0.2, any.utf8-string ==1.0.2,
any.uuid-types ==1.0.5.1, any.uuid-types ==1.0.6,
any.vector ==0.13.1.0, any.vector ==0.13.1.0,
vector +boundschecks -internalchecks -unsafechecks -wall, vector +boundschecks -internalchecks -unsafechecks -wall,
any.vector-algorithms ==0.9.0.1, any.vector-algorithms ==0.9.0.2,
vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks, vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
any.vector-stream ==0.1.0.1, any.vector-stream ==0.1.0.1,
any.void ==0.7.3, any.void ==0.7.3,
void -safe, void -safe,
any.wide-word ==0.1.6.0, any.wide-word ==0.1.6.0,
any.witherable ==0.4.2, any.witherable ==0.5,
any.zlib ==0.7.0.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-03-06T20:26:39Z index-state: hackage.haskell.org 2024-07-01T20:28:56Z

6
configure vendored
View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
echo -e "\n"
echo "export PKG_CONFIG_PATH=$HOME/.local/share/zcash-haskell:\$PKG_CONFIG_PATH" | tee -a ~/.bashrc echo "export PKG_CONFIG_PATH=$(pwd)/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug:\$PKG_CONFIG_PATH" | tee -a ~/.bashrc
echo "export LD_LIBRARY_PATH=$HOME/.local/share/zcash-haskell:\$LD_LIBRARY_PATH" | tee -a ~/.bashrc echo "export LD_LIBRARY_PATH=$(pwd)/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug:\$LD_LIBRARY_PATH" | tee -a ~/.bashrc
source ~/.bashrc source ~/.bashrc

View file

@ -88,6 +88,27 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"
[[package]]
name = "bellman"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171"
dependencies = [
"bitvec",
"blake2s_simd",
"byteorder",
"crossbeam-channel",
"ff",
"group",
"lazy_static",
"log",
"num_cpus",
"pairing",
"rand_core",
"rayon",
"subtle",
]
[[package]] [[package]]
name = "bincode" name = "bincode"
version = "1.3.3" version = "1.3.3"
@ -297,6 +318,12 @@ 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"
@ -468,6 +495,15 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "document-features"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95"
dependencies = [
"litrs",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.8.1" version = "1.8.1"
@ -673,6 +709,19 @@ 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"
@ -711,9 +760,9 @@ dependencies = [
[[package]] [[package]]
name = "incrementalmerkletree" name = "incrementalmerkletree"
version = "0.5.0" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "361c467824d4d9d4f284be4b2608800839419dccc4d4608f28345237fe354623" checksum = "eb1872810fb725b06b8c153dde9e86f3ec26747b9b60096da7a869883b549cbe"
dependencies = [ dependencies = [
"either", "either",
] ]
@ -766,6 +815,15 @@ 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"
@ -807,6 +865,12 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
[[package]]
name = "litrs"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.19" version = "0.4.19"
@ -935,9 +999,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "orchard" name = "orchard"
version = "0.6.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d31e68534df32024dcc89a8390ec6d7bef65edd87d91b45cfb481a2eb2d77c5" checksum = "1fb255c3ffdccd3c84fe9ebed72aef64fdc72e6a3e4180dd411002d47abaad42"
dependencies = [ dependencies = [
"aes", "aes",
"bitvec", "bitvec",
@ -959,6 +1023,8 @@ dependencies = [
"subtle", "subtle",
"tracing", "tracing",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_spec",
"zip32",
] ]
[[package]] [[package]]
@ -1218,6 +1284,19 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "redjubjub"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a60db2c3bc9c6fd1e8631fee75abc008841d27144be744951d6b9b75f9b569c"
dependencies = [
"rand_core",
"reddsa",
"serde",
"thiserror",
"zeroize",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.3.5" version = "0.3.5"
@ -1262,6 +1341,30 @@ 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]]
name = "ripemd"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f"
dependencies = [
"digest 0.10.7",
]
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.20" version = "0.37.20"
@ -1285,9 +1388,13 @@ dependencies = [
"f4jumble", "f4jumble",
"haskell-ffi", "haskell-ffi",
"incrementalmerkletree", "incrementalmerkletree",
"jubjub",
"nonempty", "nonempty",
"orchard", "orchard",
"proc-macro2", "proc-macro2",
"rand_core",
"sapling-crypto",
"secp256k1",
"zcash_address 0.2.0", "zcash_address 0.2.0",
"zcash_client_backend", "zcash_client_backend",
"zcash_note_encryption", "zcash_note_encryption",
@ -1295,12 +1402,62 @@ dependencies = [
"zip32", "zip32",
] ]
[[package]]
name = "sapling-crypto"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f4270033afcb0c74c5c7d59c73cfd1040367f67f224fe7ed9a919ae618f1b7"
dependencies = [
"aes",
"bellman",
"bitvec",
"blake2b_simd",
"blake2s_simd",
"bls12_381",
"byteorder",
"document-features",
"ff",
"fpe",
"group",
"hex",
"incrementalmerkletree",
"jubjub",
"lazy_static",
"memuse",
"rand",
"rand_core",
"redjubjub",
"subtle",
"tracing",
"zcash_note_encryption",
"zcash_spec",
"zip32",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "secp256k1"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894"
dependencies = [
"secp256k1-sys",
]
[[package]]
name = "secp256k1-sys"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "secrecy" name = "secrecy"
version = "0.8.0" version = "0.8.0"
@ -1356,9 +1513,9 @@ dependencies = [
[[package]] [[package]]
name = "shardtree" name = "shardtree"
version = "0.1.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19f96dde3a8693874f7e7c53d95616569b4009379a903789efbd448f4ea9cc7" checksum = "dbf20c7a2747d9083092e3a3eeb9a7ed75577ae364896bebbc5e0bdcd4e97735"
dependencies = [ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"either", "either",
@ -1577,6 +1734,12 @@ 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"
@ -1589,6 +1752,70 @@ 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"
@ -1600,6 +1827,28 @@ 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"
@ -1701,24 +1950,27 @@ dependencies = [
[[package]] [[package]]
name = "zcash_client_backend" name = "zcash_client_backend"
version = "0.10.0" version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6a382af39be9ee5a3788157145c404b7cd19acc440903f6c34b09fb44f0e991" checksum = "001ec65dc2828ee648dc6d29f0944d7a877fe68ad06e001a203c11770ab1b3d4"
dependencies = [ dependencies = [
"base64", "base64",
"bech32 0.9.1", "bech32 0.9.1",
"bls12_381", "bls12_381",
"bs58 0.5.0", "bs58 0.5.0",
"crossbeam-channel", "crossbeam-channel",
"document-features",
"group", "group",
"hex", "hex",
"incrementalmerkletree", "incrementalmerkletree",
"memuse", "memuse",
"nom", "nom",
"orchard", "nonempty",
"percent-encoding", "percent-encoding",
"prost", "prost",
"rand_core",
"rayon", "rayon",
"sapling-crypto",
"secrecy", "secrecy",
"shardtree", "shardtree",
"subtle", "subtle",
@ -1728,8 +1980,10 @@ dependencies = [
"which", "which",
"zcash_address 0.3.1", "zcash_address 0.3.1",
"zcash_encoding", "zcash_encoding",
"zcash_keys",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_primitives", "zcash_primitives",
"zip32",
] ]
[[package]] [[package]]
@ -1742,6 +1996,29 @@ dependencies = [
"nonempty", "nonempty",
] ]
[[package]]
name = "zcash_keys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f22d3407fdd6992b49f037f23862ab376be6013be6f2d0bc85948a635edc1f5"
dependencies = [
"bech32 0.9.1",
"bls12_381",
"bs58 0.5.0",
"document-features",
"group",
"memuse",
"nonempty",
"rand_core",
"sapling-crypto",
"subtle",
"tracing",
"zcash_address 0.3.1",
"zcash_encoding",
"zcash_primitives",
"zip32",
]
[[package]] [[package]]
name = "zcash_note_encryption" name = "zcash_note_encryption"
version = "0.4.0" version = "0.4.0"
@ -1757,35 +2034,49 @@ dependencies = [
[[package]] [[package]]
name = "zcash_primitives" name = "zcash_primitives"
version = "0.13.0" 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 = "d17e4c94ca8d69d2fcf2be97522da5732a580eb2125cda3b150761952f8df8e6" checksum = "9070e084570bb78aed4f8d71fd6254492e62c87a5d01e084183980e98117092d"
dependencies = [ dependencies = [
"aes", "aes",
"bip0039", "bip0039",
"bitvec",
"blake2b_simd", "blake2b_simd",
"blake2s_simd",
"bls12_381",
"byteorder", "byteorder",
"document-features",
"equihash", "equihash",
"ff", "ff",
"fpe", "fpe",
"group", "group",
"hdwallet",
"hex", "hex",
"incrementalmerkletree", "incrementalmerkletree",
"jubjub", "jubjub",
"lazy_static",
"memuse", "memuse",
"nonempty", "nonempty",
"orchard", "orchard",
"rand", "rand",
"rand_core", "rand_core",
"redjubjub",
"ripemd",
"sapling-crypto",
"secp256k1",
"sha2 0.10.6", "sha2 0.10.6",
"subtle", "subtle",
"tracing",
"zcash_address 0.3.1", "zcash_address 0.3.1",
"zcash_encoding", "zcash_encoding",
"zcash_note_encryption", "zcash_note_encryption",
"zcash_spec",
"zip32",
]
[[package]]
name = "zcash_spec"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7a3bf58b673cb3dacd8ae09ba345998923a197ab0da70d6239d8e8838949e9b"
dependencies = [
"blake2b_simd",
] ]
[[package]] [[package]]
@ -1810,9 +2101,9 @@ dependencies = [
[[package]] [[package]]
name = "zip32" name = "zip32"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d724a63be4dfb50b7f3617e542984e22e4b4a5b8ca5de91f55613152885e6b22" checksum = "4226d0aee9c9407c27064dfeec9d7b281c917de3374e1e5a2e2cfad9e09de19e"
dependencies = [ dependencies = [
"blake2b_simd", "blake2b_simd",
"memuse", "memuse",

View file

@ -11,14 +11,18 @@ 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.6.0" orchard = "0.7.1"
zcash_note_encryption = "0.4.0" zcash_note_encryption = "0.4.0"
zcash_primitives = "0.13.0" zcash_primitives = { version = "0.14.0", features = ["transparent-inputs"]}
zcash_client_backend = "0.10.0" zcash_client_backend = "0.11.1"
sapling-crypto = "0.1.3"
zip32 = "0.1.0" zip32 = "0.1.0"
proc-macro2 = "1.0.66" proc-macro2 = "1.0.66"
nonempty = "0.7.0" nonempty = "0.7.0"
incrementalmerkletree = "0.5.0" incrementalmerkletree = "0.5.0"
secp256k1 = "0.26.0"
jubjub = "0.10.0"
rand_core = { version = "0.6.4", features = ["getrandom"]}
[features] [features]

File diff suppressed because it is too large Load diff

View file

@ -96,7 +96,7 @@ import ZcashHaskell.Types
{# fun unsafe rust_wrapper_sapling_note_decrypt_v2 as rustWrapperSaplingNoteDecode {# fun unsafe rust_wrapper_sapling_note_decrypt_v2 as rustWrapperSaplingNoteDecode
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'& , toBorshVar* `ShieldedOutput'&
, getVarBuffer `Buffer DecodedNote'& , getVarBuffer `Buffer DecodedNote'&
} }
-> `()' -> `()'
@ -104,7 +104,7 @@ import ZcashHaskell.Types
{# fun unsafe rust_wrapper_sapling_esk_decrypt as rustWrapperSaplingDecodeEsk {# fun unsafe rust_wrapper_sapling_esk_decrypt as rustWrapperSaplingDecodeEsk
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'& , toBorshVar* `ShieldedOutput'&
, `Bool' , `Bool'
, `Bool' , `Bool'
, `Word64' , `Word64'
@ -138,7 +138,7 @@ import ZcashHaskell.Types
#} #}
{# fun unsafe rust_wrapper_tx_parse as rustWrapperTxParse {# fun unsafe rust_wrapper_tx_parse as rustWrapperTxParse
{ toBorshVar* `BS.ByteString'& { toBorshVar* `BS.ByteString'&
, getVarBuffer `Buffer [BS.ByteString]'& , getVarBuffer `Buffer [ShieldedOutput]'&
} }
-> `()' -> `()'
#} #}
@ -259,3 +259,36 @@ import ZcashHaskell.Types
} }
-> `Word64' -> `Word64'
#} #}
{# fun unsafe rust_wrapper_update_sapling_witness as rustWrapperUpdateSaplingWitness
{ toBorshVar* `BS.ByteString'&
, toBorshVar* `[BS.ByteString]'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_update_orchard_witness as rustWrapperUpdateOrchardWitness
{ toBorshVar* `BS.ByteString'&
, toBorshVar* `[BS.ByteString]'&
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}
{# fun unsafe rust_wrapper_create_transaction as rustWrapperCreateTx
{ toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'&
, toBorshVar* `[TransparentTxSpend]'&
, toBorshVar* `[SaplingTxSpend]'&
, toBorshVar* `[OrchardTxSpend]'&
, toBorshVar* `[OutgoingNote]'&
, toBorshVar* `BS.ByteString'&
, toBorshVar* `BS.ByteString'&
, `Bool'
, `Word64'
, `Bool'
, getVarBuffer `Buffer HexString'&
}
-> `()'
#}

View file

@ -28,6 +28,7 @@ import C.Zcash
, rustWrapperReadOrchardWitness , rustWrapperReadOrchardWitness
, rustWrapperUADecode , rustWrapperUADecode
, rustWrapperUfvkDecode , rustWrapperUfvkDecode
, rustWrapperUpdateOrchardWitness
) )
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
@ -219,3 +220,9 @@ getOrchardWitness tree =
getOrchardNotePosition :: OrchardWitness -> Integer getOrchardNotePosition :: OrchardWitness -> Integer
getOrchardNotePosition = getOrchardNotePosition =
fromIntegral . rustWrapperReadOrchardPosition . hexBytes . orchWit fromIntegral . rustWrapperReadOrchardPosition . hexBytes . orchWit
updateOrchardWitness :: OrchardWitness -> [HexString] -> OrchardWitness
updateOrchardWitness wit cmus =
OrchardWitness $
withPureBorshVarBuffer $
rustWrapperUpdateOrchardWitness (toBytes $ orchWit wit) (map toBytes cmus)

View file

@ -18,11 +18,11 @@
module ZcashHaskell.Sapling where module ZcashHaskell.Sapling where
import C.Zcash import C.Zcash
( rustWrapperIsShielded ( rustWrapperDecodeSaplingAddress
, rustWrapperIsShielded
, rustWrapperReadSaplingCommitmentTree , rustWrapperReadSaplingCommitmentTree
, rustWrapperReadSaplingPosition , rustWrapperReadSaplingPosition
, rustWrapperReadSaplingWitness , rustWrapperReadSaplingWitness
, rustWrapperDecodeSaplingAddress
, rustWrapperSaplingCheck , rustWrapperSaplingCheck
, rustWrapperSaplingChgPaymentAddress , rustWrapperSaplingChgPaymentAddress
, rustWrapperSaplingDecodeEsk , rustWrapperSaplingDecodeEsk
@ -31,12 +31,13 @@ import C.Zcash
, rustWrapperSaplingSpendingkey , rustWrapperSaplingSpendingkey
, rustWrapperSaplingVkDecode , rustWrapperSaplingVkDecode
, rustWrapperTxParse , rustWrapperTxParse
, rustWrapperUpdateSaplingWitness
) )
import Data.Aeson 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 qualified Data.Text as T
import Data.HexString (HexString(..), fromText, hexString, toBytes, toText) import Data.HexString (HexString(..), fromText, hexString, toBytes, toText)
import qualified Data.Text as T
import Data.Word import Data.Word
import Foreign.Rust.Marshall.Variable import Foreign.Rust.Marshall.Variable
( withPureBorshVarBuffer ( withPureBorshVarBuffer
@ -49,7 +50,7 @@ import ZcashHaskell.Utils (decodeBech32, encodeBech32, encodeBech32m)
isValidShieldedAddress :: BS.ByteString -> Bool isValidShieldedAddress :: BS.ByteString -> Bool
isValidShieldedAddress = rustWrapperIsShielded isValidShieldedAddress = rustWrapperIsShielded
getShieldedOutputs :: HexString -> [BS.ByteString] getShieldedOutputs :: HexString -> [ShieldedOutput]
getShieldedOutputs t = withPureBorshVarBuffer $ rustWrapperTxParse $ toBytes t getShieldedOutputs t = withPureBorshVarBuffer $ rustWrapperTxParse $ toBytes t
serializeShieldedOutput :: ShieldedOutput -> BS.ByteString serializeShieldedOutput :: ShieldedOutput -> BS.ByteString
@ -75,7 +76,7 @@ matchSaplingAddress :: BS.ByteString -> BS.ByteString -> Bool
matchSaplingAddress = rustWrapperSaplingCheck matchSaplingAddress = rustWrapperSaplingCheck
-- | Attempt to decode the given raw tx with the given Sapling viewing key -- | Attempt to decode the given raw tx with the given Sapling viewing key
decodeSaplingOutput :: BS.ByteString -> BS.ByteString -> Maybe DecodedNote decodeSaplingOutput :: BS.ByteString -> ShieldedOutput -> Maybe DecodedNote
decodeSaplingOutput key out = decodeSaplingOutput key out =
case a_value decodedAction of case a_value decodedAction of
0 -> Nothing 0 -> Nothing
@ -94,12 +95,35 @@ instance FromJSON RawTxResponse where
c <- obj .: "confirmations" c <- obj .: "confirmations"
b <- obj .: "blocktime" b <- obj .: "blocktime"
sSpend <- obj .: "vShieldedSpend" sSpend <- obj .: "vShieldedSpend"
sOut <- obj .: "vShieldedOutput"
case o of case o of
Nothing -> Nothing ->
pure $ RawTxResponse i h sSpend (getShieldedOutputs h) [] ht c b pure $
RawTxResponse
i
h
sSpend
(if not (null (sOut :: [Object]))
then getShieldedOutputs h
else [])
[]
ht
c
b
Just o' -> do Just o' -> do
a <- o' .: "actions" a <- o' .: "actions"
pure $ RawTxResponse i h sSpend (getShieldedOutputs h) a ht c b pure $
RawTxResponse
i
h
sSpend
(if not (null sOut)
then getShieldedOutputs h
else [])
a
ht
c
b
-- | Attempt to decode the given raw tx with the given Sapling spending key -- | Attempt to decode the given raw tx with the given Sapling spending key
decodeSaplingOutputEsk :: decodeSaplingOutputEsk ::
@ -118,7 +142,7 @@ decodeSaplingOutputEsk key out znet scope pos =
withPureBorshVarBuffer $ withPureBorshVarBuffer $
rustWrapperSaplingDecodeEsk rustWrapperSaplingDecodeEsk
(getBytes key) (getBytes key)
(serializeShieldedOutput out) out
(scope == External) (scope == External)
(znet == MainNet) (znet == MainNet)
(fromIntegral pos) (fromIntegral pos)
@ -192,12 +216,17 @@ getSaplingNotePosition :: SaplingWitness -> Integer
getSaplingNotePosition = getSaplingNotePosition =
fromIntegral . rustWrapperReadSaplingPosition . hexBytes . sapWit fromIntegral . rustWrapperReadSaplingPosition . hexBytes . sapWit
updateSaplingWitness :: SaplingWitness -> [HexString] -> SaplingWitness
updateSaplingWitness wit cmus =
SaplingWitness $
withPureBorshVarBuffer $
rustWrapperUpdateSaplingWitness (toBytes $ sapWit wit) (map toBytes cmus)
-- | Encode a SaplingReceiver into HRF text -- | Encode a SaplingReceiver into HRF text
encodeSaplingAddress :: ZcashNet -> SaplingReceiver -> Maybe T.Text encodeSaplingAddress :: ZcashNet -> SaplingReceiver -> Maybe T.Text
encodeSaplingAddress net sr = do encodeSaplingAddress net sr = do
case net of case net of
MainNet -> MainNet -> Just $ encodeBech32 (C.pack sapPaymentAddressHrp) (getBytes sr)
Just $ encodeBech32 (C.pack sapPaymentAddressHrp) (getBytes sr)
TestNet -> TestNet ->
Just $ encodeBech32 (C.pack sapTestPaymentAddressHrp) (getBytes sr) Just $ encodeBech32 (C.pack sapTestPaymentAddressHrp) (getBytes sr)
@ -214,10 +243,10 @@ decodeSaplingAddress sapling_address = do
if BS.length sa > 1 if BS.length sa > 1
then do then do
let sa0 = BS.unpack sa let sa0 = BS.unpack sa
Just $ SaplingAddress (getNetId (take 1 sa0)) Just $
$ SaplingReceiver (BS.pack (drop 1 sa0)) SaplingAddress (getNetId (take 1 sa0)) $
SaplingReceiver (BS.pack (drop 1 sa0))
else Nothing else Nothing
where where
sa = sa =
withPureBorshVarBuffer $ withPureBorshVarBuffer $ rustWrapperDecodeSaplingAddress sapling_address
rustWrapperDecodeSaplingAddress sapling_address

View file

@ -21,8 +21,8 @@ import Crypto.Secp256k1
import qualified Data.ByteArray as BA import qualified Data.ByteArray as BA
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import Data.ByteString.Base58 (bitcoinAlphabet, decodeBase58, encodeBase58) import Data.ByteString.Base58 (bitcoinAlphabet, decodeBase58, encodeBase58)
import Data.Char (chr)
import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString.Char8 as BC
import Data.Char (chr)
import Data.HexString import Data.HexString
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
@ -31,6 +31,7 @@ import Haskoin.Address (Address(..))
import qualified Haskoin.Crypto.Hash as H import qualified Haskoin.Crypto.Hash as H
import Haskoin.Crypto.Keys.Extended import Haskoin.Crypto.Keys.Extended
import ZcashHaskell.Types import ZcashHaskell.Types
-- ( AccountId -- ( AccountId
-- , CoinType(..) -- , CoinType(..)
-- , Scope(..) -- , Scope(..)
@ -44,7 +45,7 @@ import ZcashHaskell.Types
-- , getTransparentPrefix -- , getTransparentPrefix
-- , getValue -- , getValue
-- ) -- )
import ZcashHaskell.Utils( encodeBech32m, decodeBech32 ) import ZcashHaskell.Utils (decodeBech32, encodeBech32m)
-- | Required for `TransparentReceiver` encoding and decoding -- | Required for `TransparentReceiver` encoding and decoding
sha256 :: BS.ByteString -> BS.ByteString sha256 :: BS.ByteString -> BS.ByteString
@ -100,7 +101,22 @@ genTransparentReceiver i scope xprvk = do
ScriptAddress j -> return $ TransparentReceiver P2SH $ fromBinary j ScriptAddress j -> return $ TransparentReceiver P2SH $ fromBinary j
_anyOtherKind -> throwIO $ userError "Unsupported transparent address type" _anyOtherKind -> throwIO $ userError "Unsupported transparent address type"
-- } decode a Transparent Address in HRF and return a TransparentAddress object -- | Generate a transparent receiver
genTransparentSecretKey ::
Int -- ^ The index of the address to be created
-> Scope -- ^ `External` for wallet addresses or `Internal` for change addresses
-> XPrvKey -- ^ The transparent private key
-> IO TransparentSpendingKey
genTransparentSecretKey i scope xprvk = do
ioCtx <- createContext
let s =
case scope of
External -> 0
Internal -> 1
let path = Deriv :/ s :/ fromIntegral i :: DerivPath
return $ derivePath ioCtx path xprvk
-- | decode a Transparent Address in HRF and return a TransparentAddress object
decodeTransparentAddress :: BS.ByteString -> Maybe TransparentAddress decodeTransparentAddress :: BS.ByteString -> Maybe TransparentAddress
decodeTransparentAddress taddress = do decodeTransparentAddress taddress = do
if BS.length taddress < 34 if BS.length taddress < 34
@ -127,21 +143,29 @@ decodeTransparentAddress taddress = do
189 -> 189 ->
Just $ Just $
TransparentAddress MainNet $ TransparentAddress MainNet $
TransparentReceiver P2SH (fromRawBytes transparentReceiver) TransparentReceiver
P2SH
(fromRawBytes transparentReceiver)
186 -> 186 ->
Just $ Just $
TransparentAddress TestNet $ TransparentAddress TestNet $
TransparentReceiver P2SH (fromRawBytes transparentReceiver) TransparentReceiver
P2SH
(fromRawBytes transparentReceiver)
184 -> 184 ->
Just $ Just $
TransparentAddress MainNet $ TransparentAddress MainNet $
TransparentReceiver P2PKH (fromRawBytes transparentReceiver) TransparentReceiver
P2PKH
(fromRawBytes transparentReceiver)
_ -> Nothing _ -> Nothing
29 -> 29 ->
if sb == 37 if sb == 37
then Just $ then Just $
TransparentAddress TestNet $ TransparentAddress TestNet $
TransparentReceiver P2PKH (fromRawBytes transparentReceiver) TransparentReceiver
P2PKH
(fromRawBytes transparentReceiver)
else Nothing else Nothing
_ -> Nothing _ -> Nothing
@ -180,7 +204,9 @@ decodeExchangeAddress ex = do
if hr == tTest if hr == tTest
then Just $ then Just $
ExchangeAddress TestNet $ ExchangeAddress TestNet $
TransparentReceiver P2PKH (fromRawBytes transparentReceiver) TransparentReceiver
P2PKH
(fromRawBytes transparentReceiver)
else Nothing else Nothing
else Nothing else Nothing
else Nothing else Nothing

View file

@ -259,7 +259,7 @@ data RawTxResponse = RawTxResponse
{ rt_id :: !HexString { rt_id :: !HexString
, rt_hex :: !HexString , rt_hex :: !HexString
, rt_shieldedSpends :: ![ShieldedSpend] , rt_shieldedSpends :: ![ShieldedSpend]
, rt_shieldedOutputs :: ![BS.ByteString] , rt_shieldedOutputs :: ![ShieldedOutput]
, rt_orchardActions :: ![OrchardAction] , rt_orchardActions :: ![OrchardAction]
, rt_blockheight :: !Integer , rt_blockheight :: !Integer
, rt_confirmations :: !Integer , rt_confirmations :: !Integer
@ -484,8 +484,7 @@ instance ToBytes SaplingReceiver where
getBytes (SaplingReceiver s) = s getBytes (SaplingReceiver s) = s
data SaplingAddress = SaplingAddress data SaplingAddress = SaplingAddress
{ { net_type :: !ZcashNet
net_type :: !ZcashNet
, sa_receiver :: !SaplingReceiver , sa_receiver :: !SaplingReceiver
} deriving (Eq, Prelude.Show, Read) } deriving (Eq, Prelude.Show, Read)
@ -639,11 +638,83 @@ data DecodedNote = DecodedNote
, a_recipient :: !BS.ByteString -- ^ The recipient Orchard receiver. , a_recipient :: !BS.ByteString -- ^ The recipient Orchard receiver.
, a_memo :: !BS.ByteString -- ^ The decoded shielded memo field. , a_memo :: !BS.ByteString -- ^ The decoded shielded memo field.
, a_nullifier :: !HexString -- ^ The calculated nullifier , a_nullifier :: !HexString -- ^ The calculated nullifier
, a_rho :: !BS.ByteString
, a_rseed :: !Rseed
} 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)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct DecodedNote deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct DecodedNote
data Rseed = Rseed
{ rs_kind :: !Word8
, rs_bytes :: !BS.ByteString
} deriving stock (Eq, Prelude.Show, GHC.Generic, Read)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct Rseed
data TransparentTxSpend = TransparentTxSpend
{ ts_sk :: !BS.ByteString
, ts_utxo :: !RawOutPoint
, ts_coin :: !RawTxOut
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct TransparentTxSpend
data SaplingTxSpend = SaplingTxSpend
{ ss_sk :: !BS.ByteString
, ss_note :: !DecodedNote
, ss_iw :: !BS.ByteString
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct SaplingTxSpend
data OrchardTxSpend = OrchardTxSpend
{ ss_sk :: !BS.ByteString
, ss_note :: !DecodedNote
, ss_iw :: !BS.ByteString
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OrchardTxSpend
data OutgoingNote = OutgoingNote
{ on_kind :: !Word8
, on_key :: !BS.ByteString
, on_recipient :: !BS.ByteString
, on_amt :: !Word64
, on_memo :: !BS.ByteString
, on_chg :: !Bool
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct OutgoingNote
newtype SaplingSpendParams = SaplingSpendParams
{ sapSParams :: BS.ByteString
} deriving newtype (Eq, Prelude.Show, Read)
newtype SaplingOutputParams = SaplingOutputParams
{ sapOParams :: BS.ByteString
} deriving newtype (Eq, Prelude.Show, Read)
data TxError
= InsufficientFunds
| ChangeRequired
| Fee
| Balance
| TransparentBuild
| SaplingBuild
| OrchardBuild
| OrchardSpend
| OrchardRecipient
| SaplingBuilderNotAvailable
| OrchardBuilderNotAvailable
| ZHError
deriving (Eq, Prelude.Show, Read)
-- * Classes -- * Classes
-- | Class to represent types with a bytestring representation -- | Class to represent types with a bytestring representation
class ToBytes a where class ToBytes a where

View file

@ -19,8 +19,9 @@ module ZcashHaskell.Utils where
import C.Zcash import C.Zcash
( rustWrapperBech32Decode ( rustWrapperBech32Decode
, rustWrapperBech32mEncode
, rustWrapperBech32Encode , rustWrapperBech32Encode
, rustWrapperBech32mEncode
, rustWrapperCreateTx
, rustWrapperF4Jumble , rustWrapperF4Jumble
, rustWrapperF4UnJumble , rustWrapperF4UnJumble
, rustWrapperTxRead , rustWrapperTxRead
@ -31,7 +32,7 @@ import Data.Aeson
import Data.Binary.Get import Data.Binary.Get
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import Data.HexString (HexString(..)) import Data.HexString (HexString(..), toBytes)
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 Foreign.Rust.Marshall.Variable import Foreign.Rust.Marshall.Variable
@ -121,3 +122,54 @@ readZebraTransaction hex =
where where
rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex
createTransaction ::
Maybe SaplingCommitmentTree -- ^ to obtain the Sapling anchor
-> Maybe OrchardCommitmentTree -- ^ to obtain the Orchard anchor
-> [TransparentTxSpend] -- ^ the list of transparent notes to spend
-> [SaplingTxSpend] -- ^ the list of Sapling notes to spend
-> [OrchardTxSpend] -- ^ the list of Orchard notes to spend
-> [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
-> Int -- ^ target block height
-> Bool -- ^ True to build, False to estimate fee
-> Either TxError HexString
createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oParams znet bh build =
processResult $! txResult
where
processResult :: HexString -> Either TxError HexString
processResult input =
if BS.length (hexBytes input) > 1
then Right input
else case head (BS.unpack $ hexBytes input) of
0 -> Left InsufficientFunds
1 -> Left ChangeRequired
2 -> Left Fee
3 -> Left Balance
4 -> Left TransparentBuild
5 -> Left SaplingBuild
6 -> Left OrchardBuild
7 -> Left OrchardSpend
8 -> Left OrchardRecipient
9 -> Left SaplingBuilderNotAvailable
10 -> Left OrchardBuilderNotAvailable
_ -> Left ZHError
txResult =
withPureBorshVarBuffer $
rustWrapperCreateTx
(case sapAnchor of
Nothing -> "0"
Just sA -> toBytes $ sapTree sA)
(case orchAnchor of
Nothing -> "0"
Just oA -> toBytes $ orchTree oA)
tSpend
sSpend
oSpend
outgoing
(sapSParams sParams)
(sapOParams oParams)
(znet == MainNet)
(fromIntegral bh)
build

File diff suppressed because one or more lines are too long

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.5.5.3 version: 0.6.2.1
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
@ -58,7 +58,7 @@ library
, binary , binary
, text , text
, haskoin-core , haskoin-core
, secp256k1-haskell , secp256k1-haskell >= 1.1
, utf8-string , utf8-string
build-tool-depends: build-tool-depends:
c2hs:c2hs c2hs:c2hs