Transparent & Shielded DEX with Maya Protocol

All open source, repo has already been shared I see


Should take a couple of months


Hi @hanh

ZCG discussed this grant in our brainstorm session today. There are two things that we would like to see updated in your current proposal.

  1. We would like to see more substantive information for each of your milestone deliverables.
  • For example, your milestone 1 deliverable states “design and planning”. Can you please provide more detail on what this entails and what you are planning to submit to the Zcash Foundation as a deliverable?
  • Milestone deliverables need to be clear and substantive for the Zcash Foundation to properly evaluate them without needing to reach out to the committee causing delays to your milestone payouts. Please update each milestone deliverable with more detail.
  1. Our current understanding is that Maya will only support receiving transparent ZEC, and that it’s highly recommended to only send funds to Maya from a transparent address because Maya needs to know a return address.
  • Can you please document Maya’s vault/liquidity pool incompatibility with shielded addresses and how you plan to overcome this in the wallet as an execution risk in your grant? We would like this to be captured in your grant.



The form accepts a single line of text per milestone. Where would you like to have the extended description?

Edit: I added this section then.

Extended Milestone Description

M1: Resolve issues surrounding the usage of transparent & shielded addresses for sending and receiving ZEC

Sending ZEC: A shielded sender does not include a return address. In case of rejection from MP, how do they refund the user?

Proposal: Add a custom refund address in the memo. Signed off my MP but pending implementation and merge from upstream (Thorchain). That shouldn’t be a problem since it is already planned, but we need to follow up.


  • Restrict to transparent

  • Issue warning when sending from shielded

Receiving ZEC: MP Validators need to check that the payment from the Vault is completed successfully in a decentralized way. As such, they must be able to decrypt shielded tx from MP.

  • Solution: Establish a rotating OVK used by Asgard that allows validators to recover the encryption key. The output notes are not malleable per the protocol design. Open Issues: What’s the process for managing the OVK? How do validators get the OVK?

How do we integrate librustzcash into MP?

  • MP is written in Go. They are OK if external components are integrated via C FFI.

What API will the Zcash integration have?



  • API documents

  • Sequence Diagrams for the swap from/to ZEC

  • Signoff for any dependency on MP

M2: BiFrost

Implementation of the BiFrost component for Zcash.

  • Zcash Blockchain scanner

  • Detect and verify incoming ZEC into Asguard

  • Detect and verify outgoing ZEC (use transparent address or decrypt using OVK)

  • Parse memo

  • Calculate Fees per ZIP 317

  • Build unsigned transaction v5

  • Calculate Sighash per ZIP 244

  • Sign TSS


  • PR Into BiFrost

  • Zcash external library

M3: Mayanode

  • Add logic to parse an address

  • Return gas asset for the chain

  • add logic in regards to how to update

  • define a new asset

  • add logic to get address from a pubic key


  • PR into MayaNode

M4: Finishing touches and testing

  • Deployment script: Node Launcher

  • Stagenet/Testnet

  • Add support to JS client library xchainjs


  • Test end to end swap from NodeJS

M5: Integration in YWallet


  • Ability to swap without leaving YWallet.

Note that YW only has support for Zcash. Therefore for the another currency, a different app must be used.

For bitcoin, YW will generate a payment URI.

This work is primarily for adding Zcash to the backend of MP. As such YW has no dependency on it and works like any other MP client. In other words, users should be able to swap using other apps or online as long as their wallet supports custom memos.


This reveals non-negligible metadata and fails to achieve a z ecosystem. It’s also irrelevant to this discussion now that hanh has committed to support swaps to shielded addresses.

I don’t want to disagree with the representative from Maya yet I will say this sounds optimistic to me. hanh quoted ~5-6 months.


@hanh at the most recent meeting, the @ZcashGrants Committee voted to approve this proposal and has requested that you provide monthly updates via the forum in this thread.


Thank you for your ongoing trust. I’m looking forward to swapping BTC for ZEC :wink:


if THORChain ever decides to integrate ZEC, would this grant also help to get that done fast?
or would that need a lot of additional work?

That’s probably best to ask @mayaprotocol

1 Like

Yes it would be very easy. Would require a few minor changes only.
But it wouldn’t make sense for THORChain to do it. MP and TC work with liquidity pools. We rely on users to provide liquidity. More liquidity also means less slippage. If liquidity gets fragmented, it’s ultimately bad for the user. Hence being on either TC or Maya should be sufficient.
Also, we’ll (Maya) have aggregation with THORChain soon, making it possible to swap from Maya supported assets (DASH, KUJI, ARB, (and soon: ADA, KAS, ZEC, etc.)) to THORChain supported assets (LTC, BCH, DOGE, AVAX, ATOM, BSC) and vice versa in one transaction.


Quick update: Still working on the tech design & prototype with the Maya team. It’s getting there. No issues so far.


Here’s the design doc Maya Protocol / Zcash :: Docs


Very very cool. Seems like zcashd is being used. What will happen when zcashd is deprecated?


Currently zebrad does not have the features required to be used with bifrost. Eventually it should become possible to replace zcashd with it.


wow, very thankful for your constant updates here @hanh. I cannot stress enough how important this work is for freedom… If we can actually pull this off it would be monumental, for the first time in history people will have permissionless access to private p2p electronic cash.


Looks great, @hanh!


Join us next week for a new Monday’s with Maya! We’ll have @joshs and @hanh joining to talk about Zcash, the upcoming $ZEC integration into Maya Protocol and more!


Twitter space with @hanh, @mayaprotocol, & @joshs is starting now:

Join Here :arrow_forward:


1st half was pretty introductory high level stuff, I missed the second half, did it get into the weeds a bit more? Any new info or annoucnements?

1 Like

Here’s a run of the smoke tests from a dev build

I[2024-04-25 04:22:58,532]  0     MASTER => USER-1     [SEED] 5.00000000 ZEC.ZEC
I[2024-04-25 04:23:09,043]  1     MASTER => PROVIDER-1 [SEED] 5.00000000 ZEC.ZEC
I[2024-04-25 04:23:19,562]  2 PROVIDER-1 => VAULT      [ADD:ZEC.ZEC:PROVIDER-1] 2.50000000 ZEC.ZEC
I[2024-04-25 04:23:32,626]  3 PROVIDER-1 => VAULT      [ADD:ZEC.ZEC:PROVIDER-1] 100,000.00000000 MAYA.CACAO
I[2024-04-25 04:23:37,761]  4     USER-1 => VAULT      [SWAP:MAYA.CACAO:USER-1] 1.00000000 ZEC.ZEC
I[2024-04-25 04:23:48,632] [+] 20,388.16326530 MAYA.CACAO | Fee 20.00000000 MAYA.CACAO | Gas 20.00000000 MAYA.CACAO
I[2024-04-25 04:23:48,632]  5     USER-1 => VAULT      [SWAP:ZEC.ZEC:USER-1] 50,000.00000000 MAYA.CACAO
I[2024-04-25 04:24:07,579] [+] 0.84745086 ZEC.ZEC | Fee 0.00030000 ZEC.ZEC | Gas 0.00015000 ZEC.ZEC
  • Steps 0 & 1: Send some ZEC funds to the USER-1 and PROVIDER-1
  • Steps 2 & 3: Provide some liquidity to the ZEC pool (ZEC & CACAO)
  • Step 4: Swap from ZEC to CACAO: 1 ZEC → 20,388.16326530 CACAO
  • Step 5: Swap from CACAO to ZEC: 50,000 CACAO → 0.84745086 ZEC

I’ll set up a live cast if enough people are interested.