Add new Orchard spending key generation

This commit is contained in:
Rene Vergara 2024-03-05 14:44:00 -06:00
parent f09c3c500b
commit 694ab8fd17
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
2 changed files with 17 additions and 1 deletions

View File

@ -133,3 +133,12 @@ import ZcashHaskell.Types
}
-> `()'
#}
{# fun unsafe rust_wrapper_derive_orchard_spending_key as rustWrapperGenOrchardSpendKey
{ toBorshVar* `BS.ByteString'&
, `Word32'
, `Word32'
, getVarBuffer `Buffer (BS.ByteString)'&
}
-> `()'
#}

View File

@ -18,7 +18,8 @@
module ZcashHaskell.Orchard where
import C.Zcash
( rustWrapperOrchardCheck
( rustWrapperGenOrchardSpendKey
, rustWrapperOrchardCheck
, rustWrapperOrchardNoteDecode
, rustWrapperUADecode
, rustWrapperUfvkDecode
@ -32,6 +33,12 @@ import Foreign.Rust.Marshall.Variable
import ZcashHaskell.Types
import ZcashHaskell.Utils (encodeBech32m, f4Jumble)
-- | Derives an Orchard spending key for the given seed and account ID
genOrchardSpendingKey :: Seed -> CoinType -> AccountId -> BS.ByteString
genOrchardSpendingKey s coinType accountId =
withPureBorshVarBuffer $
rustWrapperGenOrchardSpendKey s (getValue coinType) (fromIntegral accountId)
-- | Checks if given bytestring is a valid encoded unified address
isValidUnifiedAddress :: BS.ByteString -> Maybe UnifiedAddress
isValidUnifiedAddress str =