feat: implement wagyu-zcash-parameters
crate
This commit is contained in:
parent
cedc3a0cc1
commit
5a8cd44fbc
7 changed files with 63 additions and 14 deletions
51
librustzcash-wrapper/Cargo.lock
generated
51
librustzcash-wrapper/Cargo.lock
generated
|
@ -1395,6 +1395,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",
|
||||||
|
@ -1746,6 +1747,56 @@ 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 = "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"
|
||||||
|
|
|
@ -23,6 +23,7 @@ incrementalmerkletree = "0.5.0"
|
||||||
secp256k1 = "0.26.0"
|
secp256k1 = "0.26.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"
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -167,6 +167,8 @@ use bech32::{
|
||||||
Bech32m
|
Bech32m
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use wagyu_zcash_parameters::load_sapling_parameters;
|
||||||
|
|
||||||
pub enum RW {}
|
pub enum RW {}
|
||||||
pub const RW: PhantomData<RW> = PhantomData;
|
pub const RW: PhantomData<RW> = PhantomData;
|
||||||
|
|
||||||
|
@ -1637,10 +1639,6 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
||||||
o_input_len: usize,
|
o_input_len: usize,
|
||||||
out_list: *const u8,
|
out_list: *const u8,
|
||||||
out_list_len: usize,
|
out_list_len: usize,
|
||||||
sapspend: *const u8,
|
|
||||||
sapspend_len: usize,
|
|
||||||
sapoutput: *const u8,
|
|
||||||
sapoutput_len: usize,
|
|
||||||
net: bool,
|
net: bool,
|
||||||
bl_height: u32,
|
bl_height: u32,
|
||||||
build: bool,
|
build: bool,
|
||||||
|
@ -1796,10 +1794,11 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if build {
|
if build {
|
||||||
let spend_params_in: Vec<u8> = marshall_from_haskell_var(sapspend, sapspend_len, RW);
|
let (spend_params_in, output_params_in) = load_sapling_parameters();
|
||||||
|
//let spend_params_in: Vec<u8> = marshall_from_haskell_var(sapspend, sapspend_len, RW);
|
||||||
let spend_params_reader = Cursor::new(spend_params_in);
|
let spend_params_reader = Cursor::new(spend_params_in);
|
||||||
let spend_prover = SpendParameters::read(spend_params_reader, false).unwrap();
|
let spend_prover = SpendParameters::read(spend_params_reader, false).unwrap();
|
||||||
let output_params_in: Vec<u8> = marshall_from_haskell_var(sapoutput, sapoutput_len, RW);
|
//let output_params_in: Vec<u8> = marshall_from_haskell_var(sapoutput, sapoutput_len, RW);
|
||||||
let output_params_reader = Cursor::new(output_params_in);
|
let output_params_reader = Cursor::new(output_params_in);
|
||||||
let output_prover = OutputParameters::read(output_params_reader, false).unwrap();
|
let output_prover = OutputParameters::read(output_params_reader, false).unwrap();
|
||||||
let result = if net {
|
let result = if net {
|
||||||
|
|
|
@ -283,8 +283,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'
|
||||||
|
|
|
@ -129,13 +129,11 @@ createTransaction ::
|
||||||
-> [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
|
-> 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 =
|
||||||
processResult $! txResult
|
processResult $! txResult
|
||||||
where
|
where
|
||||||
processResult :: HexString -> Either TxError HexString
|
processResult :: HexString -> Either TxError HexString
|
||||||
|
@ -168,8 +166,6 @@ createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oPa
|
||||||
sSpend
|
sSpend
|
||||||
oSpend
|
oSpend
|
||||||
outgoing
|
outgoing
|
||||||
(sapSParams sParams)
|
|
||||||
(sapOParams oParams)
|
|
||||||
(znet == MainNet)
|
(znet == MainNet)
|
||||||
(fromIntegral bh)
|
(fromIntegral bh)
|
||||||
build
|
build
|
||||||
|
|
|
@ -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
|
||||||
|
@ -82,6 +83,8 @@ import ZcashHaskell.Types
|
||||||
, RawTxOut(..)
|
, RawTxOut(..)
|
||||||
, RawTxResponse(..)
|
, RawTxResponse(..)
|
||||||
, RawZebraTx(..)
|
, RawZebraTx(..)
|
||||||
|
, RpcError(..)
|
||||||
|
, RpcResponse(..)
|
||||||
, SaplingAddress(..)
|
, SaplingAddress(..)
|
||||||
, SaplingBundle(..)
|
, SaplingBundle(..)
|
||||||
, SaplingCommitmentTree(..)
|
, SaplingCommitmentTree(..)
|
||||||
|
@ -1179,7 +1182,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
|
||||||
|
|
|
@ -86,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
|
||||||
|
|
Loading…
Reference in a new issue