We just did a fully trustless shielded ZEC to EVM atomic swap with no new signing primitives! And yes, it is programmable

We did! A single Sinsemilla hash circuit in BN254 hit 29.6 million gates, and on BLS381 might be sort of 2-3M at best.

Yes, that is because it likely did same-field math. Such as a Halo2 proof for Sinsemilla. The thing is, Halo2 is not native to Ethereum, and would require more than the block gas limit to verify. So the only alternative is to “box” the hash in a different, more compatible curve, such as BN254 or BLS12-381 (Ethereum has precompiles for both), but then the issue becomes that Sinsemilla is not native to THESE curves, and therefore requires normalisation at every step.

Basically, take modadd on BN254: the 255th bit is nearly half of the value of a number (little endian), which Zcash natively uses, making it the most significant bit. But you can only hold 254 of the 255 bits in a BN254 field, meaning for every one number you want to add, you need to setup two fields, and ensure the calculation works properly with dozens of guards.

On BLS12-381, the field is big enough to accumulate an addition, but for modmul, the size of the multiplied field is 255+255 bits, which is bigger than 381 and doesn’t neatly fit.

Okay yeah-

I keep forgetting about the Halo2/Groth16 difference and the Hash difference of Zcash vs. Ethereum. My project was totally on EVM, so I had no problem choosing the best hash and field of my choosing.
Thanks.

1 Like

We just identified a critical cross-chain replay issue that renders the current bridge unusable without finality, which is why we are quickly devising a fix. Do not interpret it as “this idea is broken”, we have already identified a proper fix for both finality and this replay issue that will be implemented soon, so the idea is still fully viable.

Could elaborate on that ? Without revealing your tech, what is the workflow and the shape of the prediction fn?

Well, revealing our “tech” (there’s a paper on it! so it’s nothing new nor secret), it’s just a Blake2b transaction digest tree of a 1-in-1-out Action schema. It’s nothing fancy, really, you just precompute the Sapling/Transparent digests because they are constant (0-in-0-out), and then take the pk_d, g_d and compute a commitment. It’s the principle that’s novel, not the mechanism.

As for the code that generates the txID verbatim, that would be:

function compute(
        uint32 version,
        uint32 versionGroupId,
        uint32 consensusBranchId,
        uint32 lockTime,
        uint32 expiryHeight,
        bytes32 compactDigest,
        bytes32 memosDigest,
        bytes32 noncompactDigest
    ) external view returns (bytes32 txidOut, bytes32 ironwoodDigestOut) {
        bytes32 h = headerDigest(version, versionGroupId, consensusBranchId, lockTime, expiryHeight);
        ironwoodDigestOut = ironwoodDigest(compactDigest, memosDigest, noncompactDigest);
        txidOut = txid(h, ironwoodDigestOut, consensusBranchId);
    }

and

Action.Inputs memory inputs = abi.decode(actionAbi, (Action.Inputs));
        (
            bytes32 compactDigest,
            bytes32 memosDigest,
            bytes32 noncompactDigest,
            bytes32 cmx0,
            bytes32 nf0,
            bytes32 nf1
        ) = abi.decode(computeAbi, (bytes32, bytes32, bytes32, bytes32, bytes32, bytes32));
        bytes32 actionCmx = action.commitNote1(inputs);
        if (actionCmx != cmx0) revert CmxMismatch();
        bytes32 txid = _computeTxid(r, compactDigest, memosDigest, noncompactDigest);

Pretty standard stuff. It relies on the concept that you don’t NECESSARILY need to associate the signature (which is segregated as spendAuthSig tree) into the effects tree, and secondly, you don’t HAVE to check if the input notes are valid, as the network’s validators do the job for you. So you’re free to let the user set the input note parameters wholesale blindly, as the network would reject them for you. So the only things you really need per-se is the output note details, such as p_k, g_d, v, and blinding factors, and optionally nullifier (but we recommend deriving it from a network-wide fair randomness function such as the Beacon Chain digests)

Right now we are not encapsulating the cmx generation in a NIZK due to compute constraints (254-bits is too constrained, we’re moving to 381-bit, we even tried to implement Halo2 on EVM)

The “replay vulnerability” is that transaction ID generation does NOT differ between mainnet and testnet, but we are solving that by fixing finality (proving the finality belongs to the mainnet via anchor blocks)

Also, hanh, I’m sure you have many other doubts about usability based on this barebones demo, which we have sincerely tried to solve via adding LP-like mechanics to reduce on-chain interactions to <=2. We will be publishing an update on that plus an interactive, testable-right-now UI hopefully today!

I asked to have the workflow / sequence diagram so that we can clearly see which actor is responsible for providing what data and in what order.

1 Like

Oh- I… misinterpreted that, sorry, sleep deprived. Let me make one real quick.

I’ll make one for the new P2P flow.

I hope this is not too crude, best I could do with Mermaid. This is for the new P2P flow, ETH->ZEC.

For ZEC->ETH, the flow is more or less the same for P2P, just with the roles reversed.

Specifically, a spending key is never needed for party B before execution, and they have to reveal rho, rcm, psi and nullifier for now, which will be hidden by NIZK later.

2 Likes

Is this something you are pursuing to production?

1 Like

Yes, we are pursuing to production. Right now our biggest hurdle is that there is no uniform standard for web RPCs from a Zcash wallet, so we’re building our own to build a functional test, as well as writing a paper for on-chain consensus. We will soon request a community grant!

Our current plans, if done as-is, will eventually allow holders of ZEC to make their ZEC available for yield as automated LPs while remaining fully private, earning profits in Ethereum or any bridged asset while doing absolutely nothing :slight_smile:

2 Likes

We have made a grant application too!

Further, we recommend you check out Introduction · Skyhook !

Great work sir

1 Like