@veilo/sdk-core 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +449 -1243
- package/accounts.d.ts +2 -0
- package/accounts.js +3 -0
- package/cloak.d.ts +2 -0
- package/cloak.js +3 -0
- package/config.d.ts +2 -2
- package/config.js +2 -3
- package/dist/cjs/accounts/admin.d.ts +84 -0
- package/dist/cjs/accounts/admin.js +208 -0
- package/dist/cjs/accounts/errors.d.ts +6 -0
- package/dist/cjs/accounts/errors.js +98 -0
- package/dist/cjs/accounts/index.d.ts +4 -0
- package/dist/cjs/accounts/index.js +20 -0
- package/dist/cjs/accounts/pdas.d.ts +23 -0
- package/dist/cjs/accounts/pdas.js +44 -0
- package/dist/cjs/accounts/queries.d.ts +41 -0
- package/dist/cjs/accounts/queries.js +95 -0
- package/dist/cjs/client.d.ts +2 -407
- package/dist/cjs/client.js +6 -938
- package/dist/cjs/cloak/client.d.ts +28 -0
- package/dist/cjs/cloak/client.js +68 -0
- package/dist/cjs/cloak/errors.d.ts +13 -0
- package/dist/cjs/cloak/errors.js +25 -0
- package/dist/cjs/cloak/helpers.d.ts +6 -0
- package/dist/cjs/cloak/helpers.js +35 -0
- package/dist/cjs/cloak/index.d.ts +6 -0
- package/dist/cjs/cloak/index.js +24 -0
- package/dist/cjs/cloak/polling.d.ts +7 -0
- package/dist/cjs/cloak/polling.js +66 -0
- package/dist/cjs/cloak/transport.d.ts +15 -0
- package/dist/cjs/cloak/transport.js +119 -0
- package/dist/cjs/cloak/types.d.ts +188 -0
- package/dist/cjs/cloak/types.js +5 -0
- package/dist/cjs/cloak.d.ts +1 -0
- package/dist/cjs/cloak.js +18 -0
- package/dist/cjs/compactNote.d.ts +21 -0
- package/dist/cjs/compactNote.js +31 -7
- package/dist/cjs/events/index.d.ts +6 -0
- package/dist/cjs/events/index.js +22 -0
- package/dist/cjs/events/parsing.d.ts +25 -0
- package/dist/cjs/events/parsing.js +158 -0
- package/dist/cjs/events/position.d.ts +26 -0
- package/dist/cjs/events/position.js +53 -0
- package/dist/cjs/events/recovery.d.ts +87 -0
- package/dist/cjs/events/recovery.js +281 -0
- package/dist/cjs/events/scanning.d.ts +35 -0
- package/dist/cjs/events/scanning.js +98 -0
- package/dist/cjs/events/tree.d.ts +27 -0
- package/dist/cjs/events/tree.js +63 -0
- package/dist/cjs/events/types.d.ts +39 -0
- package/dist/cjs/events.d.ts +1 -77
- package/dist/cjs/events.js +6 -154
- package/dist/cjs/identity/encoding.d.ts +9 -0
- package/dist/cjs/identity/encoding.js +85 -0
- package/dist/cjs/identity/index.d.ts +4 -0
- package/dist/cjs/identity/index.js +20 -0
- package/dist/cjs/identity/noteKey.d.ts +33 -0
- package/dist/cjs/identity/noteKey.js +97 -0
- package/dist/cjs/identity/spending.d.ts +18 -0
- package/dist/cjs/identity/spending.js +46 -0
- package/dist/cjs/identity/viewKey.d.ts +38 -0
- package/dist/cjs/identity/viewKey.js +105 -0
- package/dist/cjs/idl/index.d.ts +18 -0
- package/dist/cjs/idl/index.js +24 -0
- package/dist/cjs/idl/privacy_pool.json +9907 -9907
- package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
- package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
- package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
- package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/cjs/index.d.ts +9 -3
- package/dist/cjs/index.js +15 -2
- package/dist/cjs/notes/amount.d.ts +2 -0
- package/dist/cjs/notes/amount.js +21 -0
- package/dist/cjs/notes/encryption.d.ts +41 -0
- package/dist/cjs/notes/encryption.js +75 -0
- package/dist/cjs/notes/index.d.ts +8 -0
- package/dist/cjs/notes/index.js +24 -0
- package/dist/cjs/notes/mailbox.d.ts +70 -0
- package/dist/cjs/notes/mailbox.js +164 -0
- package/dist/cjs/notes/model.d.ts +91 -0
- package/dist/cjs/notes/model.js +109 -0
- package/dist/cjs/notes/nullifier.d.ts +27 -0
- package/dist/cjs/notes/nullifier.js +45 -0
- package/dist/cjs/notes/recovery.d.ts +20 -0
- package/dist/cjs/notes/recovery.js +48 -0
- package/dist/cjs/notes/selection.d.ts +77 -0
- package/dist/cjs/notes/selection.js +193 -0
- package/dist/cjs/notes/spent.d.ts +60 -0
- package/dist/cjs/notes/spent.js +101 -0
- package/dist/cjs/perps/constants.d.ts +16 -0
- package/dist/cjs/perps/constants.js +52 -0
- package/dist/cjs/perps/index.d.ts +5 -0
- package/dist/cjs/perps/index.js +21 -0
- package/dist/cjs/perps/keys.d.ts +16 -0
- package/dist/cjs/perps/keys.js +43 -0
- package/dist/cjs/perps/pdas.d.ts +29 -0
- package/dist/cjs/perps/pdas.js +55 -0
- package/dist/cjs/perps/relayer.d.ts +9 -0
- package/dist/cjs/perps/relayer.js +35 -0
- package/dist/cjs/perps/types.d.ts +126 -0
- package/dist/cjs/perps/types.js +2 -0
- package/dist/cjs/positions/index.d.ts +4 -0
- package/dist/cjs/positions/index.js +20 -0
- package/dist/cjs/positions/keys.d.ts +29 -0
- package/dist/cjs/positions/keys.js +71 -0
- package/dist/cjs/positions/pdas.d.ts +15 -0
- package/dist/cjs/positions/pdas.js +54 -0
- package/dist/cjs/positions/relayer.d.ts +4 -0
- package/dist/cjs/positions/relayer.js +15 -0
- package/dist/cjs/positions/types.d.ts +97 -0
- package/dist/cjs/positions/types.js +2 -0
- package/dist/cjs/predictions/client.d.ts +41 -0
- package/dist/cjs/predictions/client.js +147 -0
- package/dist/cjs/predictions/index.d.ts +5 -0
- package/dist/cjs/predictions/index.js +21 -0
- package/dist/cjs/predictions/keys.d.ts +14 -0
- package/dist/cjs/predictions/keys.js +40 -0
- package/dist/cjs/predictions/pdas.d.ts +6 -0
- package/dist/cjs/predictions/pdas.js +13 -0
- package/dist/cjs/predictions/relayer.d.ts +3 -0
- package/dist/cjs/predictions/relayer.js +11 -0
- package/dist/cjs/predictions/types.d.ts +178 -0
- package/dist/cjs/predictions/types.js +2 -0
- package/dist/cjs/program.d.ts +2 -0
- package/dist/cjs/program.js +8 -7
- package/dist/cjs/proof.d.ts +1 -183
- package/dist/cjs/proof.js +16 -290
- package/dist/cjs/proofs/encoding.d.ts +17 -0
- package/dist/cjs/proofs/encoding.js +72 -0
- package/dist/cjs/proofs/formatting.d.ts +6 -0
- package/dist/cjs/proofs/formatting.js +34 -0
- package/dist/cjs/proofs/index.d.ts +5 -0
- package/dist/cjs/proofs/index.js +21 -0
- package/dist/cjs/proofs/swap.d.ts +87 -0
- package/dist/cjs/proofs/swap.js +144 -0
- package/dist/cjs/proofs/transaction.d.ts +28 -0
- package/dist/cjs/proofs/transaction.js +110 -0
- package/dist/cjs/proofs/types.d.ts +70 -0
- package/dist/cjs/proofs/types.js +2 -0
- package/dist/cjs/prover.d.ts +30 -4
- package/dist/cjs/prover.js +118 -49
- package/dist/cjs/relayer/api.d.ts +31 -0
- package/dist/cjs/relayer/api.js +86 -0
- package/dist/cjs/relayer/client.d.ts +73 -0
- package/dist/cjs/relayer/client.js +206 -0
- package/dist/cjs/relayer/crypto.d.ts +5 -0
- package/dist/cjs/relayer/crypto.js +26 -0
- package/dist/cjs/relayer/encoding.d.ts +2 -0
- package/dist/cjs/relayer/encoding.js +23 -0
- package/dist/cjs/relayer/errors.d.ts +7 -0
- package/dist/cjs/relayer/errors.js +17 -0
- package/dist/cjs/relayer/index.d.ts +6 -0
- package/dist/cjs/relayer/index.js +19 -0
- package/dist/cjs/relayer/internal-config.d.ts +36 -0
- package/dist/cjs/relayer/internal-config.js +9 -0
- package/dist/cjs/relayer/internal.d.ts +6 -0
- package/dist/cjs/relayer/internal.js +14 -0
- package/dist/cjs/relayer/transport.d.ts +19 -0
- package/dist/cjs/relayer/transport.js +68 -0
- package/dist/{src/relayer.d.ts → cjs/relayer/types.d.ts} +53 -96
- package/dist/cjs/relayer/types.js +5 -0
- package/dist/cjs/relayer.d.ts +1 -318
- package/dist/cjs/relayer.js +15 -254
- package/dist/cjs/shield/alt.js +8 -8
- package/dist/cjs/shield/errors.js +2 -2
- package/dist/cjs/shield/finalize.js +2 -2
- package/dist/cjs/shield/ix.d.ts +1 -1
- package/dist/cjs/shield/owner.js +9 -11
- package/dist/cjs/shield/ports.js +3 -3
- package/dist/cjs/shield/preflight.js +3 -3
- package/dist/cjs/shield/shield.js +20 -19
- package/dist/cjs/shield/types.d.ts +1 -1
- package/dist/cjs/transactions/deposit.d.ts +94 -0
- package/dist/cjs/transactions/deposit.js +234 -0
- package/dist/cjs/transactions/index.d.ts +7 -0
- package/dist/cjs/transactions/index.js +26 -0
- package/dist/cjs/transactions/swap.d.ts +71 -0
- package/dist/cjs/transactions/swap.js +184 -0
- package/dist/cjs/transactions/transact.d.ts +34 -0
- package/dist/cjs/transactions/transact.js +146 -0
- package/dist/cjs/transactions/transfer.d.ts +51 -0
- package/dist/cjs/transactions/transfer.js +106 -0
- package/dist/cjs/transactions/withdraw.d.ts +52 -0
- package/dist/cjs/transactions/withdraw.js +104 -0
- package/dist/cjs/utxo.d.ts +1 -235
- package/dist/cjs/utxo.js +15 -404
- package/dist/esm/accounts/admin.d.ts +84 -0
- package/dist/esm/accounts/admin.js +165 -0
- package/dist/esm/accounts/errors.d.ts +6 -0
- package/dist/esm/accounts/errors.js +95 -0
- package/dist/esm/accounts/index.d.ts +4 -0
- package/dist/esm/accounts/index.js +4 -0
- package/dist/esm/accounts/pdas.d.ts +23 -0
- package/dist/esm/accounts/pdas.js +38 -0
- package/dist/esm/accounts/queries.d.ts +41 -0
- package/dist/esm/accounts/queries.js +88 -0
- package/dist/esm/client.d.ts +2 -407
- package/dist/esm/client.js +3 -891
- package/dist/esm/cloak/client.d.ts +28 -0
- package/dist/esm/cloak/client.js +64 -0
- package/dist/esm/cloak/errors.d.ts +13 -0
- package/dist/esm/cloak/errors.js +21 -0
- package/dist/esm/cloak/helpers.d.ts +6 -0
- package/dist/esm/cloak/helpers.js +31 -0
- package/dist/esm/cloak/index.d.ts +6 -0
- package/dist/esm/cloak/index.js +6 -0
- package/dist/esm/cloak/polling.d.ts +7 -0
- package/dist/esm/cloak/polling.js +63 -0
- package/dist/esm/cloak/transport.d.ts +15 -0
- package/dist/esm/cloak/transport.js +115 -0
- package/dist/esm/cloak/types.d.ts +188 -0
- package/dist/esm/cloak/types.js +4 -0
- package/dist/esm/cloak.d.ts +1 -0
- package/dist/esm/cloak.js +2 -0
- package/dist/esm/compactNote.d.ts +21 -0
- package/dist/esm/compactNote.js +24 -1
- package/dist/esm/events/index.d.ts +6 -0
- package/dist/esm/events/index.js +6 -0
- package/dist/esm/events/parsing.d.ts +25 -0
- package/dist/esm/events/parsing.js +120 -0
- package/dist/esm/events/position.d.ts +26 -0
- package/dist/esm/events/position.js +48 -0
- package/dist/esm/events/recovery.d.ts +87 -0
- package/dist/esm/events/recovery.js +237 -0
- package/dist/esm/events/scanning.d.ts +35 -0
- package/dist/esm/events/scanning.js +92 -0
- package/dist/esm/events/tree.d.ts +27 -0
- package/dist/esm/events/tree.js +58 -0
- package/dist/esm/events/types.d.ts +39 -0
- package/dist/esm/events/types.js +1 -0
- package/dist/esm/events.d.ts +1 -77
- package/dist/esm/events.js +3 -129
- package/dist/esm/identity/encoding.d.ts +9 -0
- package/dist/esm/identity/encoding.js +75 -0
- package/dist/esm/identity/index.d.ts +4 -0
- package/dist/esm/identity/index.js +4 -0
- package/dist/esm/identity/noteKey.d.ts +33 -0
- package/dist/esm/identity/noteKey.js +91 -0
- package/dist/esm/identity/spending.d.ts +18 -0
- package/dist/esm/identity/spending.js +35 -0
- package/dist/esm/identity/viewKey.d.ts +38 -0
- package/dist/esm/identity/viewKey.js +96 -0
- package/dist/esm/idl/index.d.ts +18 -0
- package/dist/esm/idl/index.js +18 -0
- package/dist/esm/idl/privacy_pool.json +9907 -9907
- package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
- package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
- package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
- package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/esm/index.d.ts +9 -3
- package/dist/esm/index.js +10 -3
- package/dist/esm/notes/amount.d.ts +2 -0
- package/dist/esm/notes/amount.js +18 -0
- package/dist/esm/notes/encryption.d.ts +41 -0
- package/dist/esm/notes/encryption.js +67 -0
- package/dist/esm/notes/index.d.ts +8 -0
- package/dist/esm/notes/index.js +8 -0
- package/dist/esm/notes/mailbox.d.ts +70 -0
- package/dist/esm/notes/mailbox.js +154 -0
- package/dist/esm/notes/model.d.ts +91 -0
- package/dist/esm/notes/model.js +99 -0
- package/dist/esm/notes/nullifier.d.ts +27 -0
- package/dist/esm/notes/nullifier.js +40 -0
- package/dist/esm/notes/recovery.d.ts +20 -0
- package/dist/esm/notes/recovery.js +45 -0
- package/dist/esm/notes/selection.d.ts +77 -0
- package/dist/esm/notes/selection.js +188 -0
- package/dist/esm/notes/spent.d.ts +60 -0
- package/dist/esm/notes/spent.js +96 -0
- package/dist/esm/perps/constants.d.ts +16 -0
- package/dist/esm/perps/constants.js +48 -0
- package/dist/esm/perps/index.d.ts +5 -0
- package/dist/esm/perps/index.js +5 -0
- package/dist/esm/perps/keys.d.ts +16 -0
- package/dist/esm/perps/keys.js +35 -0
- package/dist/esm/perps/pdas.d.ts +29 -0
- package/dist/esm/perps/pdas.js +47 -0
- package/dist/esm/perps/relayer.d.ts +9 -0
- package/dist/esm/perps/relayer.js +25 -0
- package/dist/esm/perps/types.d.ts +126 -0
- package/dist/esm/perps/types.js +1 -0
- package/dist/esm/positions/index.d.ts +4 -0
- package/dist/esm/positions/index.js +4 -0
- package/dist/esm/positions/keys.d.ts +29 -0
- package/dist/esm/positions/keys.js +65 -0
- package/dist/esm/positions/pdas.d.ts +15 -0
- package/dist/esm/positions/pdas.js +44 -0
- package/dist/esm/positions/relayer.d.ts +4 -0
- package/dist/esm/positions/relayer.js +10 -0
- package/dist/esm/positions/types.d.ts +97 -0
- package/dist/esm/positions/types.js +1 -0
- package/dist/esm/predictions/client.d.ts +41 -0
- package/dist/esm/predictions/client.js +141 -0
- package/dist/esm/predictions/index.d.ts +5 -0
- package/dist/esm/predictions/index.js +5 -0
- package/dist/esm/predictions/keys.d.ts +14 -0
- package/dist/esm/predictions/keys.js +33 -0
- package/dist/esm/predictions/pdas.d.ts +6 -0
- package/dist/esm/predictions/pdas.js +10 -0
- package/dist/esm/predictions/relayer.d.ts +3 -0
- package/dist/esm/predictions/relayer.js +7 -0
- package/dist/esm/predictions/types.d.ts +178 -0
- package/dist/esm/predictions/types.js +1 -0
- package/dist/esm/program.d.ts +2 -0
- package/dist/esm/program.js +4 -3
- package/dist/esm/proof.d.ts +1 -183
- package/dist/esm/proof.js +2 -281
- package/dist/esm/proofs/encoding.d.ts +17 -0
- package/dist/esm/proofs/encoding.js +68 -0
- package/dist/esm/proofs/formatting.d.ts +6 -0
- package/dist/esm/proofs/formatting.js +31 -0
- package/dist/esm/proofs/index.d.ts +5 -0
- package/dist/esm/proofs/index.js +5 -0
- package/dist/esm/proofs/swap.d.ts +87 -0
- package/dist/esm/proofs/swap.js +138 -0
- package/dist/esm/proofs/transaction.d.ts +28 -0
- package/dist/esm/proofs/transaction.js +105 -0
- package/dist/esm/proofs/types.d.ts +70 -0
- package/dist/esm/proofs/types.js +1 -0
- package/dist/esm/prover.d.ts +30 -4
- package/dist/esm/prover.js +115 -15
- package/dist/esm/relayer/api.d.ts +31 -0
- package/dist/esm/relayer/api.js +55 -0
- package/dist/esm/relayer/client.d.ts +73 -0
- package/dist/esm/relayer/client.js +199 -0
- package/dist/esm/relayer/crypto.d.ts +5 -0
- package/dist/esm/relayer/crypto.js +20 -0
- package/dist/esm/relayer/encoding.d.ts +2 -0
- package/dist/esm/relayer/encoding.js +19 -0
- package/dist/esm/relayer/errors.d.ts +7 -0
- package/dist/esm/relayer/errors.js +13 -0
- package/dist/esm/relayer/index.d.ts +6 -0
- package/dist/esm/relayer/index.js +3 -0
- package/dist/esm/relayer/internal-config.d.ts +36 -0
- package/dist/esm/relayer/internal-config.js +6 -0
- package/dist/esm/relayer/internal.d.ts +6 -0
- package/dist/esm/relayer/internal.js +10 -0
- package/dist/esm/relayer/transport.d.ts +19 -0
- package/dist/esm/relayer/transport.js +64 -0
- package/dist/esm/relayer/types.d.ts +275 -0
- package/dist/esm/relayer/types.js +4 -0
- package/dist/esm/relayer.d.ts +1 -318
- package/dist/esm/relayer.js +2 -249
- package/dist/esm/shield/alt.js +1 -1
- package/dist/esm/shield/errors.js +1 -1
- package/dist/esm/shield/finalize.js +1 -1
- package/dist/esm/shield/ix.d.ts +1 -1
- package/dist/esm/shield/owner.js +3 -5
- package/dist/esm/shield/ports.js +1 -1
- package/dist/esm/shield/preflight.js +1 -1
- package/dist/esm/shield/shield.js +4 -3
- package/dist/esm/shield/types.d.ts +1 -1
- package/dist/esm/transactions/deposit.d.ts +94 -0
- package/dist/esm/transactions/deposit.js +198 -0
- package/dist/esm/transactions/index.d.ts +7 -0
- package/dist/esm/transactions/index.js +7 -0
- package/dist/esm/transactions/swap.d.ts +71 -0
- package/dist/esm/transactions/swap.js +144 -0
- package/dist/esm/transactions/transact.d.ts +34 -0
- package/dist/esm/transactions/transact.js +110 -0
- package/dist/esm/transactions/transfer.d.ts +51 -0
- package/dist/esm/transactions/transfer.js +103 -0
- package/dist/esm/transactions/withdraw.d.ts +52 -0
- package/dist/esm/transactions/withdraw.js +101 -0
- package/dist/esm/utxo.d.ts +1 -235
- package/dist/esm/utxo.js +2 -382
- package/identity.d.ts +2 -0
- package/identity.js +3 -0
- package/idl.d.ts +2 -0
- package/idl.js +3 -0
- package/notes.d.ts +2 -0
- package/notes.js +3 -0
- package/package.json +131 -11
- package/perps.d.ts +2 -0
- package/perps.js +3 -0
- package/poseidon.d.ts +2 -2
- package/poseidon.js +2 -3
- package/positions.d.ts +2 -0
- package/positions.js +3 -0
- package/predictions.d.ts +2 -0
- package/predictions.js +3 -0
- package/proof.d.ts +2 -2
- package/proof.js +2 -3
- package/prover.d.ts +2 -2
- package/prover.js +2 -3
- package/relayer.d.ts +2 -0
- package/relayer.js +3 -0
- package/shield.d.ts +2 -2
- package/shield.js +2 -3
- package/transactions.d.ts +2 -0
- package/transactions.js +3 -0
- package/SHIELD_INTEGRATION.md +0 -143
- package/dist/src/client.d.ts +0 -407
- package/dist/src/client.js +0 -951
- package/dist/src/compactNote.d.ts +0 -107
- package/dist/src/compactNote.js +0 -167
- package/dist/src/config.d.ts +0 -82
- package/dist/src/config.js +0 -57
- package/dist/src/events.d.ts +0 -77
- package/dist/src/events.js +0 -167
- package/dist/src/idl/privacy_pool.js +0 -15218
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -67
- package/dist/src/merkle.d.ts +0 -77
- package/dist/src/merkle.js +0 -156
- package/dist/src/poseidon.d.ts +0 -29
- package/dist/src/poseidon.js +0 -100
- package/dist/src/program.d.ts +0 -37
- package/dist/src/program.js +0 -61
- package/dist/src/proof.d.ts +0 -183
- package/dist/src/proof.js +0 -292
- package/dist/src/prover.d.ts +0 -54
- package/dist/src/prover.js +0 -112
- package/dist/src/random.d.ts +0 -16
- package/dist/src/random.js +0 -28
- package/dist/src/relayer.js +0 -257
- package/dist/src/retry.d.ts +0 -32
- package/dist/src/retry.js +0 -75
- package/dist/src/shield/alt.d.ts +0 -87
- package/dist/src/shield/alt.js +0 -194
- package/dist/src/shield/computeBudget.d.ts +0 -61
- package/dist/src/shield/computeBudget.js +0 -64
- package/dist/src/shield/errors.d.ts +0 -58
- package/dist/src/shield/errors.js +0 -121
- package/dist/src/shield/finalize.d.ts +0 -45
- package/dist/src/shield/finalize.js +0 -119
- package/dist/src/shield/index.d.ts +0 -35
- package/dist/src/shield/index.js +0 -68
- package/dist/src/shield/ix.d.ts +0 -54
- package/dist/src/shield/ix.js +0 -119
- package/dist/src/shield/owner.d.ts +0 -36
- package/dist/src/shield/owner.js +0 -126
- package/dist/src/shield/ports.d.ts +0 -43
- package/dist/src/shield/ports.js +0 -153
- package/dist/src/shield/preflight.d.ts +0 -30
- package/dist/src/shield/preflight.js +0 -154
- package/dist/src/shield/shield.d.ts +0 -68
- package/dist/src/shield/shield.js +0 -499
- package/dist/src/shield/types.d.ts +0 -202
- package/dist/src/utxo.d.ts +0 -235
- package/dist/src/utxo.js +0 -407
- package/dist/tests/compact-note.test.d.ts +0 -1
- package/dist/tests/compact-note.test.js +0 -173
- package/dist/tests/config.test.d.ts +0 -1
- package/dist/tests/config.test.js +0 -102
- package/dist/tests/edge-cases.test.d.ts +0 -1
- package/dist/tests/edge-cases.test.js +0 -220
- package/dist/tests/encryption.test.d.ts +0 -1
- package/dist/tests/encryption.test.js +0 -215
- package/dist/tests/events.test.d.ts +0 -1
- package/dist/tests/events.test.js +0 -78
- package/dist/tests/multi-tree.test.d.ts +0 -1
- package/dist/tests/multi-tree.test.js +0 -405
- package/dist/tests/pda.test.d.ts +0 -1
- package/dist/tests/pda.test.js +0 -229
- package/dist/tests/poseidon-builder-parity.test.d.ts +0 -1
- package/dist/tests/poseidon-builder-parity.test.js +0 -72
- package/dist/tests/poseidon.test.d.ts +0 -1
- package/dist/tests/poseidon.test.js +0 -142
- package/dist/tests/proof.test.d.ts +0 -1
- package/dist/tests/proof.test.js +0 -296
- package/dist/tests/relayer.test.d.ts +0 -1
- package/dist/tests/relayer.test.js +0 -271
- package/dist/tests/sdk.integration.test.d.ts +0 -1
- package/dist/tests/sdk.integration.test.js +0 -330
- package/dist/tests/shield-owner.test.d.ts +0 -1
- package/dist/tests/shield-owner.test.js +0 -89
- package/dist/tests/shield-preflight.test.d.ts +0 -1
- package/dist/tests/shield-preflight.test.js +0 -87
- package/dist/tests/shield-realproof.test.d.ts +0 -1
- package/dist/tests/shield-realproof.test.js +0 -272
- package/dist/tests/shield.test.d.ts +0 -1
- package/dist/tests/shield.test.js +0 -403
- package/dist/tests/utxo.test.d.ts +0 -1
- package/dist/tests/utxo.test.js +0 -140
- /package/dist/{src/shield → cjs/events}/types.js +0 -0
- /package/dist/{src/idl/privacy_pool.d.ts → cjs/idl/privacy_pool_legacy.d.ts} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BN254_FR_MODULUS, bigIntToBytesBE, bytesToBigIntBE, poseidon2, poseidon3, pubkeyToField, } from "../poseidon.js";
|
|
2
|
+
import { deriveNullifier } from "../notes/nullifier.js";
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
// ExtData Hash Computation
|
|
5
|
+
// -----------------------------------------------------------------------------
|
|
6
|
+
/**
|
|
7
|
+
* Compute the external data hash.
|
|
8
|
+
* Matches on-chain computation:
|
|
9
|
+
* hash1 = Poseidon(recipient, relayer)
|
|
10
|
+
* hash2 = Poseidon(fee, refund)
|
|
11
|
+
* extDataHash = Poseidon(hash1, hash2, claimant)
|
|
12
|
+
*/
|
|
13
|
+
export function computeExtDataHash(extData) {
|
|
14
|
+
const recipientField = pubkeyToField(extData.recipient);
|
|
15
|
+
const relayerField = pubkeyToField(extData.relayer);
|
|
16
|
+
const feeField = extData.fee % BN254_FR_MODULUS;
|
|
17
|
+
const refundField = extData.refund % BN254_FR_MODULUS;
|
|
18
|
+
const claimantField = pubkeyToField(extData.claimant);
|
|
19
|
+
const hash1 = poseidon2(recipientField, relayerField);
|
|
20
|
+
const hash2 = poseidon2(feeField, refundField);
|
|
21
|
+
const finalHash = poseidon3(hash1, hash2, claimantField);
|
|
22
|
+
return bigIntToBytesBE(finalHash);
|
|
23
|
+
}
|
|
24
|
+
// -----------------------------------------------------------------------------
|
|
25
|
+
// Circuit Input Preparation
|
|
26
|
+
// -----------------------------------------------------------------------------
|
|
27
|
+
/**
|
|
28
|
+
* Convert i64 to field element (handles negative via modular arithmetic).
|
|
29
|
+
* For negative values, we add the field modulus to get the equivalent positive representation.
|
|
30
|
+
*/
|
|
31
|
+
export function i64ToField(value) {
|
|
32
|
+
if (value >= 0n) {
|
|
33
|
+
return value % BN254_FR_MODULUS;
|
|
34
|
+
}
|
|
35
|
+
return (BN254_FR_MODULUS + value) % BN254_FR_MODULUS;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Prepare transaction circuit inputs from high-level parameters.
|
|
39
|
+
* This converts the SDK types into the format expected by the circuit.
|
|
40
|
+
*/
|
|
41
|
+
export function prepareTransactionInputs(params) {
|
|
42
|
+
const { inputUTXOs, outputUTXOs, root, publicAmount, extData, mintAddress } = params;
|
|
43
|
+
const extDataHash = computeExtDataHash(extData);
|
|
44
|
+
const mintField = pubkeyToField(mintAddress);
|
|
45
|
+
// Prepare input UTXO data
|
|
46
|
+
const inAmount = [
|
|
47
|
+
inputUTXOs[0].amount,
|
|
48
|
+
inputUTXOs[1].amount,
|
|
49
|
+
];
|
|
50
|
+
const inPubkey = [
|
|
51
|
+
inputUTXOs[0].pubkey,
|
|
52
|
+
inputUTXOs[1].pubkey,
|
|
53
|
+
];
|
|
54
|
+
const inBlinding = [
|
|
55
|
+
inputUTXOs[0].blinding,
|
|
56
|
+
inputUTXOs[1].blinding,
|
|
57
|
+
];
|
|
58
|
+
const inPathIndex = [
|
|
59
|
+
inputUTXOs[0].pathIndex,
|
|
60
|
+
inputUTXOs[1].pathIndex,
|
|
61
|
+
];
|
|
62
|
+
const inPathElements = [
|
|
63
|
+
inputUTXOs[0].pathElements.map((e) => bytesToBigIntBE(e) % BN254_FR_MODULUS),
|
|
64
|
+
inputUTXOs[1].pathElements.map((e) => bytesToBigIntBE(e) % BN254_FR_MODULUS),
|
|
65
|
+
];
|
|
66
|
+
const inPrivateKey = [
|
|
67
|
+
inputUTXOs[0].privateKey,
|
|
68
|
+
inputUTXOs[1].privateKey,
|
|
69
|
+
];
|
|
70
|
+
// Prepare output UTXO data
|
|
71
|
+
const outAmount = [
|
|
72
|
+
outputUTXOs[0].amount,
|
|
73
|
+
outputUTXOs[1].amount,
|
|
74
|
+
];
|
|
75
|
+
const outPubkey = [
|
|
76
|
+
outputUTXOs[0].pubkey,
|
|
77
|
+
outputUTXOs[1].pubkey,
|
|
78
|
+
];
|
|
79
|
+
const outBlinding = [
|
|
80
|
+
outputUTXOs[0].blinding,
|
|
81
|
+
outputUTXOs[1].blinding,
|
|
82
|
+
];
|
|
83
|
+
// Derive nullifiers for input UTXOs
|
|
84
|
+
const inputNullifiers = [
|
|
85
|
+
deriveNullifier(inputUTXOs[0], inputUTXOs[0].pathIndex, inputUTXOs[0].privateKey),
|
|
86
|
+
deriveNullifier(inputUTXOs[1], inputUTXOs[1].pathIndex, inputUTXOs[1].privateKey),
|
|
87
|
+
];
|
|
88
|
+
return {
|
|
89
|
+
root,
|
|
90
|
+
publicAmount,
|
|
91
|
+
extDataHash,
|
|
92
|
+
mintAddress,
|
|
93
|
+
inputNullifiers,
|
|
94
|
+
outputCommitments: [outputUTXOs[0].commitment, outputUTXOs[1].commitment],
|
|
95
|
+
inAmount,
|
|
96
|
+
inPubkey,
|
|
97
|
+
inBlinding,
|
|
98
|
+
inPathIndex,
|
|
99
|
+
inPathElements,
|
|
100
|
+
inPrivateKey,
|
|
101
|
+
outAmount,
|
|
102
|
+
outPubkey,
|
|
103
|
+
outBlinding,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* External data that gets hashed into ext_data_hash.
|
|
4
|
+
* These are public parameters that affect financial flows.
|
|
5
|
+
*/
|
|
6
|
+
export type ExtData = {
|
|
7
|
+
/** Who receives withdrawal (for withdrawals) */
|
|
8
|
+
recipient: PublicKey;
|
|
9
|
+
/** Who submits tx and gets fee */
|
|
10
|
+
relayer: PublicKey;
|
|
11
|
+
/** Fee to relayer in lamports/token units */
|
|
12
|
+
fee: bigint;
|
|
13
|
+
/** Refund to user in lamports/token units (for gas compensation) */
|
|
14
|
+
refund: bigint;
|
|
15
|
+
/** Claimant key committed into the proof */
|
|
16
|
+
claimant: PublicKey;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Transaction circuit inputs (8 public inputs, many private inputs).
|
|
20
|
+
* This structure is used to prepare inputs for the snarkjs prover.
|
|
21
|
+
*/
|
|
22
|
+
export type TransactionCircuitInputs = {
|
|
23
|
+
/** Merkle root of UTXO tree */
|
|
24
|
+
root: Uint8Array;
|
|
25
|
+
/** Net deposit/withdrawal amount (positive = deposit, negative = withdrawal) */
|
|
26
|
+
publicAmount: bigint;
|
|
27
|
+
/** Hash of external data (recipient, relayer, fee, refund) */
|
|
28
|
+
extDataHash: Uint8Array;
|
|
29
|
+
/** Token mint address */
|
|
30
|
+
mintAddress: PublicKey;
|
|
31
|
+
/** Nullifiers for the two input UTXOs */
|
|
32
|
+
inputNullifiers: [Uint8Array, Uint8Array];
|
|
33
|
+
/** Commitments for the two output UTXOs */
|
|
34
|
+
outputCommitments: [Uint8Array, Uint8Array];
|
|
35
|
+
inAmount: [bigint, bigint];
|
|
36
|
+
inPubkey: [bigint, bigint];
|
|
37
|
+
inBlinding: [bigint, bigint];
|
|
38
|
+
inPathIndex: [number, number];
|
|
39
|
+
inPathElements: [bigint[], bigint[]];
|
|
40
|
+
inPrivateKey: [bigint, bigint];
|
|
41
|
+
outAmount: [bigint, bigint];
|
|
42
|
+
outPubkey: [bigint, bigint];
|
|
43
|
+
outBlinding: [bigint, bigint];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Proof structure matching the on-chain TransactionProof struct.
|
|
47
|
+
* Total size: 256 bytes (64 + 128 + 64)
|
|
48
|
+
*/
|
|
49
|
+
export type TransactionProofStruct = {
|
|
50
|
+
/** G1 point A (64 bytes) */
|
|
51
|
+
proofA: number[];
|
|
52
|
+
/** G2 point B (128 bytes) */
|
|
53
|
+
proofB: number[];
|
|
54
|
+
/** G1 point C (64 bytes) */
|
|
55
|
+
proofC: number[];
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Shape of a Groth16 proof produced by snarkjs.
|
|
59
|
+
*/
|
|
60
|
+
export type RawProof = {
|
|
61
|
+
pi_a: [string, string, string];
|
|
62
|
+
pi_b: [[string, string], [string, string], [string, string]];
|
|
63
|
+
pi_c: [string, string, string];
|
|
64
|
+
protocol: string;
|
|
65
|
+
curve: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Proof builder function type - takes circuit inputs and returns a raw snarkjs proof.
|
|
69
|
+
*/
|
|
70
|
+
export type TransactionProofBuilder = (inputs: TransactionCircuitInputs) => Promise<RawProof>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/prover.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { TransactionProofBuilder, RawProof } from "./
|
|
1
|
+
import type { TransactionProofBuilder, RawProof } from "./proofs/types.js";
|
|
2
|
+
import { type SwapProofBuilder } from "./proofs/swap.js";
|
|
2
3
|
/**
|
|
3
4
|
* Circuit artifact paths required by snarkjs.
|
|
4
5
|
*
|
|
5
|
-
* These files are large (10-100 MB) and
|
|
6
|
-
*
|
|
6
|
+
* These files are large (10-100 MB) and are NOT bundled in the npm package —
|
|
7
|
+
* `files` ships `dist/` only. Optional: omit them and the prover resolves a
|
|
8
|
+
* local copy (see `resolveCircuitArtifacts`). Supply them explicitly whenever
|
|
9
|
+
* the defaults cannot apply, which includes every browser build.
|
|
7
10
|
*
|
|
8
11
|
* For Node.js: pass file system paths (e.g. "./circuits/transaction.wasm").
|
|
9
12
|
* For browsers: pass Uint8Array buffers or URLs that fetch returns as ArrayBuffer.
|
|
@@ -14,6 +17,27 @@ export interface CircuitArtifacts {
|
|
|
14
17
|
/** Path or buffer for the Groth16 proving key (.zkey) */
|
|
15
18
|
zkeyPath: string | Uint8Array;
|
|
16
19
|
}
|
|
20
|
+
/** The circuits this package can resolve artifacts for. */
|
|
21
|
+
export type CircuitName = "transaction" | "swap";
|
|
22
|
+
/**
|
|
23
|
+
* Resolve circuit artifacts from disk when the caller did not supply them.
|
|
24
|
+
*
|
|
25
|
+
* Search order, first hit wins:
|
|
26
|
+
*
|
|
27
|
+
* 1. $VEILO_CIRCUITS_DIR explicit override
|
|
28
|
+
* 2. <package>/circuits populated by `npm run copy:circuits`
|
|
29
|
+
* 3. <cwd>/circuits
|
|
30
|
+
* 4. <cwd>/node_modules/@veilo/sdk-core/circuits
|
|
31
|
+
*
|
|
32
|
+
* NODE ONLY, AND DELIBERATELY LAZY. `node:fs` is imported inside the call, not
|
|
33
|
+
* at module scope: this module is reachable from the package root export, and a
|
|
34
|
+
* top-level `node:fs` import throws at bundle time in browser builds with no
|
|
35
|
+
* Node polyfill — the same reason `random.ts` avoids `node:crypto`. Browsers
|
|
36
|
+
* must pass `CircuitArtifacts` explicitly; there is nothing to resolve there.
|
|
37
|
+
*
|
|
38
|
+
* @throws when no candidate directory holds both files, listing what it tried
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveCircuitArtifacts(circuit: CircuitName): Promise<CircuitArtifacts>;
|
|
17
41
|
/**
|
|
18
42
|
* Create a proof builder function for the transaction circuit.
|
|
19
43
|
*
|
|
@@ -40,7 +64,9 @@ export interface CircuitArtifacts {
|
|
|
40
64
|
* const proof = await prover(circuitInputs);
|
|
41
65
|
* ```
|
|
42
66
|
*/
|
|
43
|
-
export declare function createTransactionProver(artifacts
|
|
67
|
+
export declare function createTransactionProver(artifacts?: CircuitArtifacts): TransactionProofBuilder;
|
|
68
|
+
/** Create a proof builder for the current `swap.circom` witness shape. */
|
|
69
|
+
export declare function createSwapProver(artifacts?: CircuitArtifacts): SwapProofBuilder;
|
|
44
70
|
/**
|
|
45
71
|
* Verify a Groth16 proof against public signals and a verification key.
|
|
46
72
|
*
|
package/dist/esm/prover.js
CHANGED
|
@@ -1,14 +1,92 @@
|
|
|
1
|
-
import { formatInputsForSnarkjs
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { formatInputsForSnarkjs } from "./proofs/formatting.js";
|
|
2
|
+
import { formatSwapInputsForSnarkjs, } from "./proofs/swap.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lazy-load snarkjs — works in both CJS and ESM contexts.
|
|
5
|
+
*
|
|
6
|
+
* The import is built through `Function` so TypeScript cannot rewrite it into a
|
|
7
|
+
* `require()` in the CommonJS build, and bundlers cannot follow it into browser
|
|
8
|
+
* output. Never call `require("snarkjs")` directly here: `require` is not
|
|
9
|
+
* defined in the ESM build, so it throws ReferenceError instead of this
|
|
10
|
+
* message.
|
|
11
|
+
*/
|
|
12
|
+
async function loadSnarkjs(purpose = "proof generation") {
|
|
4
13
|
try {
|
|
5
14
|
// Dynamic import works in both CJS (Node 12+) and ESM
|
|
6
15
|
return await Function('return import("snarkjs")')();
|
|
7
16
|
}
|
|
8
17
|
catch {
|
|
9
|
-
throw new Error(
|
|
18
|
+
throw new Error(`snarkjs is required for ${purpose}. Install it: npm install snarkjs`);
|
|
10
19
|
}
|
|
11
20
|
}
|
|
21
|
+
/** Layout produced by `npm run copy:circuits`, relative to a circuits root. */
|
|
22
|
+
const ARTIFACT_LAYOUT = {
|
|
23
|
+
transaction: {
|
|
24
|
+
wasm: "transaction/transaction_js/transaction.wasm",
|
|
25
|
+
zkey: "transaction/transaction_final.zkey",
|
|
26
|
+
},
|
|
27
|
+
swap: {
|
|
28
|
+
wasm: "swap/swap_js/swap.wasm",
|
|
29
|
+
zkey: "swap/swap_final.zkey",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolve circuit artifacts from disk when the caller did not supply them.
|
|
34
|
+
*
|
|
35
|
+
* Search order, first hit wins:
|
|
36
|
+
*
|
|
37
|
+
* 1. $VEILO_CIRCUITS_DIR explicit override
|
|
38
|
+
* 2. <package>/circuits populated by `npm run copy:circuits`
|
|
39
|
+
* 3. <cwd>/circuits
|
|
40
|
+
* 4. <cwd>/node_modules/@veilo/sdk-core/circuits
|
|
41
|
+
*
|
|
42
|
+
* NODE ONLY, AND DELIBERATELY LAZY. `node:fs` is imported inside the call, not
|
|
43
|
+
* at module scope: this module is reachable from the package root export, and a
|
|
44
|
+
* top-level `node:fs` import throws at bundle time in browser builds with no
|
|
45
|
+
* Node polyfill — the same reason `random.ts` avoids `node:crypto`. Browsers
|
|
46
|
+
* must pass `CircuitArtifacts` explicitly; there is nothing to resolve there.
|
|
47
|
+
*
|
|
48
|
+
* @throws when no candidate directory holds both files, listing what it tried
|
|
49
|
+
*/
|
|
50
|
+
export async function resolveCircuitArtifacts(circuit) {
|
|
51
|
+
let fs;
|
|
52
|
+
let path;
|
|
53
|
+
try {
|
|
54
|
+
fs = await Function('return import("node:fs")')();
|
|
55
|
+
path = await Function('return import("node:path")')();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error(`Cannot resolve ${circuit} circuit artifacts: no filesystem available. ` +
|
|
59
|
+
"Pass CircuitArtifacts explicitly (browsers must supply buffers or URLs).");
|
|
60
|
+
}
|
|
61
|
+
const layout = ARTIFACT_LAYOUT[circuit];
|
|
62
|
+
if (!layout) {
|
|
63
|
+
throw new Error(`Unknown circuit ${JSON.stringify(circuit)}. Known circuits: ` +
|
|
64
|
+
`${Object.keys(ARTIFACT_LAYOUT).join(", ")}.`);
|
|
65
|
+
}
|
|
66
|
+
const cwd = typeof process !== "undefined" ? process.cwd() : ".";
|
|
67
|
+
// __dirname exists in the CJS build; the ESM build falls back to cwd-relative
|
|
68
|
+
// candidates. dist/cjs/prover.js → ../../circuits is the package root copy.
|
|
69
|
+
const packageDir = typeof __dirname !== "undefined"
|
|
70
|
+
? path.resolve(__dirname, "..", "..", "circuits")
|
|
71
|
+
: undefined;
|
|
72
|
+
const roots = [
|
|
73
|
+
process.env?.VEILO_CIRCUITS_DIR,
|
|
74
|
+
packageDir,
|
|
75
|
+
path.resolve(cwd, "circuits"),
|
|
76
|
+
path.resolve(cwd, "node_modules", "@veilo", "sdk-core", "circuits"),
|
|
77
|
+
].filter((root) => Boolean(root));
|
|
78
|
+
for (const root of roots) {
|
|
79
|
+
const wasmPath = path.resolve(root, layout.wasm);
|
|
80
|
+
const zkeyPath = path.resolve(root, layout.zkey);
|
|
81
|
+
if (fs.existsSync(wasmPath) && fs.existsSync(zkeyPath)) {
|
|
82
|
+
return { wasmPath, zkeyPath };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Cannot resolve ${circuit} circuit artifacts. Looked for ${layout.wasm} ` +
|
|
86
|
+
`and ${layout.zkey} under:\n ${roots.join("\n ")}\n` +
|
|
87
|
+
"Run `npm run copy:circuits` in the SDK, set VEILO_CIRCUITS_DIR, or pass " +
|
|
88
|
+
"CircuitArtifacts explicitly.");
|
|
89
|
+
}
|
|
12
90
|
/**
|
|
13
91
|
* Create a proof builder function for the transaction circuit.
|
|
14
92
|
*
|
|
@@ -36,10 +114,30 @@ async function loadSnarkjs() {
|
|
|
36
114
|
* ```
|
|
37
115
|
*/
|
|
38
116
|
export function createTransactionProver(artifacts) {
|
|
117
|
+
// Resolved on first use, not at factory time: constructing a prover must stay
|
|
118
|
+
// free of filesystem access so browser bundles can import this module.
|
|
119
|
+
let resolved;
|
|
39
120
|
return async (inputs) => {
|
|
40
121
|
const snarkjs = await loadSnarkjs();
|
|
122
|
+
resolved ?? (resolved = artifacts
|
|
123
|
+
? Promise.resolve(artifacts)
|
|
124
|
+
: resolveCircuitArtifacts("transaction"));
|
|
125
|
+
const { wasmPath, zkeyPath } = await resolved;
|
|
41
126
|
const formattedInputs = formatInputsForSnarkjs(inputs);
|
|
42
|
-
const { proof } = await snarkjs.groth16.fullProve(formattedInputs,
|
|
127
|
+
const { proof } = await snarkjs.groth16.fullProve(formattedInputs, wasmPath, zkeyPath);
|
|
128
|
+
return proof;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Create a proof builder for the current `swap.circom` witness shape. */
|
|
132
|
+
export function createSwapProver(artifacts) {
|
|
133
|
+
let resolved;
|
|
134
|
+
return async (inputs) => {
|
|
135
|
+
const snarkjs = await loadSnarkjs();
|
|
136
|
+
resolved ?? (resolved = artifacts
|
|
137
|
+
? Promise.resolve(artifacts)
|
|
138
|
+
: resolveCircuitArtifacts("swap"));
|
|
139
|
+
const { wasmPath, zkeyPath } = await resolved;
|
|
140
|
+
const { proof } = await snarkjs.groth16.fullProve(formatSwapInputsForSnarkjs(inputs), wasmPath, zkeyPath);
|
|
43
141
|
return proof;
|
|
44
142
|
};
|
|
45
143
|
}
|
|
@@ -54,18 +152,20 @@ export function createTransactionProver(artifacts) {
|
|
|
54
152
|
* @returns true if the proof is valid
|
|
55
153
|
*/
|
|
56
154
|
export async function verifyProof(proof, publicSignals, vkey) {
|
|
57
|
-
|
|
58
|
-
let snarkjs;
|
|
59
|
-
try {
|
|
60
|
-
snarkjs = require("snarkjs");
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
throw new Error('snarkjs is required for proof verification. Install it: npm install snarkjs');
|
|
64
|
-
}
|
|
155
|
+
const snarkjs = await loadSnarkjs("proof verification");
|
|
65
156
|
let vkeyObj;
|
|
66
157
|
if (typeof vkey === "string") {
|
|
67
|
-
// Node.js file path — read and parse
|
|
68
|
-
|
|
158
|
+
// Node.js file path — read and parse. Same hidden import as
|
|
159
|
+
// resolveCircuitArtifacts: a plain `await import("fs")` is followed by
|
|
160
|
+
// bundlers and breaks browser builds that have no Node polyfill.
|
|
161
|
+
let fs;
|
|
162
|
+
try {
|
|
163
|
+
fs = await Function('return import("node:fs")')();
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new Error("Reading a verification key from a path requires Node. Pass the parsed " +
|
|
167
|
+
"verification key object instead.");
|
|
168
|
+
}
|
|
69
169
|
vkeyObj = JSON.parse(fs.readFileSync(vkey, "utf-8"));
|
|
70
170
|
}
|
|
71
171
|
else {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CheckNullifiersResponse, ChallengeResponse, CheckUsernameResponse, DeleteUserDataResponse, MerkleRootResponse, MerkleTreeResponse, PreRegisterKeyResponse, PrivateSwapRequest, PrivateSwapResponse, PrivateTransferRequest, PrivateTransferResponse, QueryNotesRequest, QueryNotesResponse, RegisterRequest, RegisterResponse, RestoreRequest, RestoreResponse, SaveEncryptedNoteRequest, SaveEncryptedNoteResponse, VeiloPublicKeyResponse, WithdrawRequest, WithdrawResponse } from "./types.js";
|
|
2
|
+
/** Request a wallet-authentication challenge from Veilo. */
|
|
3
|
+
export declare function getChallenge(walletPublicKey: string): Promise<ChallengeResponse>;
|
|
4
|
+
/** Register a Veilo account and receive its auth token. */
|
|
5
|
+
export declare function register(data: RegisterRequest): Promise<RegisterResponse>;
|
|
6
|
+
/** Restore a Veilo account and receive its auth token. */
|
|
7
|
+
export declare function restore(data: RestoreRequest): Promise<RestoreResponse>;
|
|
8
|
+
export declare function checkUsername(username: string): Promise<CheckUsernameResponse>;
|
|
9
|
+
export declare function getVeiloPublicKey(params: {
|
|
10
|
+
username: string;
|
|
11
|
+
publicKey?: never;
|
|
12
|
+
} | {
|
|
13
|
+
publicKey: string;
|
|
14
|
+
username?: never;
|
|
15
|
+
}): Promise<VeiloPublicKeyResponse>;
|
|
16
|
+
export declare function preRegisterKey(solanaAddress: string): Promise<PreRegisterKeyResponse>;
|
|
17
|
+
export declare function saveEncryptedNote(data: SaveEncryptedNoteRequest): Promise<SaveEncryptedNoteResponse>;
|
|
18
|
+
/** Query notes with an explicit per-call token; no auth state is shared. */
|
|
19
|
+
export declare function queryEncryptedNotes(authToken: string, params?: QueryNotesRequest): Promise<QueryNotesResponse>;
|
|
20
|
+
/** Delete the authenticated user's stored data without retaining their token. */
|
|
21
|
+
export declare function deleteUserData(authToken: string): Promise<DeleteUserDataResponse>;
|
|
22
|
+
/** Raw check-batch call. Prefer `checkNullifiersSpent`, which chunks for you. */
|
|
23
|
+
export declare function checkNullifiers(nullifiers: string[]): Promise<CheckNullifiersResponse>;
|
|
24
|
+
export declare function getMerkleRoot(mintAddress?: string, treeId?: number): Promise<MerkleRootResponse>;
|
|
25
|
+
export declare function getMerkleTree(mintAddress?: string, treeId?: number): Promise<MerkleTreeResponse>;
|
|
26
|
+
export declare function submitWithdraw(data: WithdrawRequest): Promise<WithdrawResponse>;
|
|
27
|
+
export declare function submitPrivateTransfer(data: PrivateTransferRequest): Promise<PrivateTransferResponse>;
|
|
28
|
+
export declare function submitPrivateSwap(data: PrivateSwapRequest): Promise<PrivateSwapResponse>;
|
|
29
|
+
export { submitClosePosition, submitMergePositions, submitOpenPosition, } from "../positions/relayer.js";
|
|
30
|
+
export { submitJperpCancelTrigger, submitJperpClose, submitJperpOpen, submitJperpRecoverNative, submitJperpRecoverSeed, submitJperpReissue, submitJperpSetTpsl, submitJperpUpdateTpsl, } from "../perps/relayer.js";
|
|
31
|
+
export { submitPredictionOpen, submitPredictionReissue, } from "../predictions/relayer.js";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createInternalRelayerClient, getInternalRelayerClient, } from "./internal.js";
|
|
2
|
+
/** Request a wallet-authentication challenge from Veilo. */
|
|
3
|
+
export function getChallenge(walletPublicKey) {
|
|
4
|
+
return getInternalRelayerClient().getChallenge(walletPublicKey);
|
|
5
|
+
}
|
|
6
|
+
/** Register a Veilo account and receive its auth token. */
|
|
7
|
+
export function register(data) {
|
|
8
|
+
return getInternalRelayerClient().register(data);
|
|
9
|
+
}
|
|
10
|
+
/** Restore a Veilo account and receive its auth token. */
|
|
11
|
+
export function restore(data) {
|
|
12
|
+
return getInternalRelayerClient().restore(data);
|
|
13
|
+
}
|
|
14
|
+
export function checkUsername(username) {
|
|
15
|
+
return getInternalRelayerClient().checkUsername(username);
|
|
16
|
+
}
|
|
17
|
+
export function getVeiloPublicKey(params) {
|
|
18
|
+
return getInternalRelayerClient().getVeiloPublicKey(params);
|
|
19
|
+
}
|
|
20
|
+
export function preRegisterKey(solanaAddress) {
|
|
21
|
+
return getInternalRelayerClient().preRegisterKey(solanaAddress);
|
|
22
|
+
}
|
|
23
|
+
export function saveEncryptedNote(data) {
|
|
24
|
+
return getInternalRelayerClient().saveEncryptedNote(data);
|
|
25
|
+
}
|
|
26
|
+
/** Query notes with an explicit per-call token; no auth state is shared. */
|
|
27
|
+
export function queryEncryptedNotes(authToken, params = {}) {
|
|
28
|
+
return createInternalRelayerClient({ authToken }).queryEncryptedNotes(params);
|
|
29
|
+
}
|
|
30
|
+
/** Delete the authenticated user's stored data without retaining their token. */
|
|
31
|
+
export function deleteUserData(authToken) {
|
|
32
|
+
return createInternalRelayerClient({ authToken }).deleteUserData();
|
|
33
|
+
}
|
|
34
|
+
/** Raw check-batch call. Prefer `checkNullifiersSpent`, which chunks for you. */
|
|
35
|
+
export function checkNullifiers(nullifiers) {
|
|
36
|
+
return getInternalRelayerClient().checkNullifiers(nullifiers);
|
|
37
|
+
}
|
|
38
|
+
export function getMerkleRoot(mintAddress, treeId) {
|
|
39
|
+
return getInternalRelayerClient().getMerkleRoot(mintAddress, treeId);
|
|
40
|
+
}
|
|
41
|
+
export function getMerkleTree(mintAddress, treeId) {
|
|
42
|
+
return getInternalRelayerClient().getMerkleTree(mintAddress, treeId);
|
|
43
|
+
}
|
|
44
|
+
export function submitWithdraw(data) {
|
|
45
|
+
return getInternalRelayerClient().submitWithdraw(data);
|
|
46
|
+
}
|
|
47
|
+
export function submitPrivateTransfer(data) {
|
|
48
|
+
return getInternalRelayerClient().submitPrivateTransfer(data);
|
|
49
|
+
}
|
|
50
|
+
export function submitPrivateSwap(data) {
|
|
51
|
+
return getInternalRelayerClient().submitPrivateSwap(data);
|
|
52
|
+
}
|
|
53
|
+
export { submitClosePosition, submitMergePositions, submitOpenPosition, } from "../positions/relayer.js";
|
|
54
|
+
export { submitJperpCancelTrigger, submitJperpClose, submitJperpOpen, submitJperpRecoverNative, submitJperpRecoverSeed, submitJperpReissue, submitJperpSetTpsl, submitJperpUpdateTpsl, } from "../perps/relayer.js";
|
|
55
|
+
export { submitPredictionOpen, submitPredictionReissue, } from "../predictions/relayer.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { CheckNullifiersResponse, ChallengeResponse, CheckUsernameResponse, DeleteUserDataResponse, MerkleRootResponse, MerkleTreeResponse, PreRegisterKeyResponse, PrivateSwapRequest, PrivateSwapResponse, PrivateTransferRequest, PrivateTransferResponse, QueryNotesRequest, QueryNotesResponse, RegisterRequest, RegisterResponse, RestoreRequest, RestoreResponse, RetryPolicy, SaveEncryptedNoteRequest, SaveEncryptedNoteResponse, VeiloPublicKeyResponse, WithdrawRequest, WithdrawResponse } from "./types.js";
|
|
2
|
+
import { type InternalRelayerClientOptions } from "./internal-config.js";
|
|
3
|
+
import type { ClosePositionRequest, ClosePositionResponse, MergePositionsRequest, MergePositionsResponse, OpenPositionRequest, OpenPositionResponse } from "../positions/types.js";
|
|
4
|
+
import type { JperpCancelTriggerRequest, JperpCancelTriggerResponse, JperpCloseRequest, JperpDecreaseResponse, JperpOpenRequest, JperpOpenResponse, JperpRecoverNativeRequest, JperpRecoverNativeResponse, JperpRecoverSeedRequest, JperpRecoverSeedResponse, JperpReissueRequest, JperpReissueResponse, JperpSetTpslRequest, JperpUpdateTpslRequest } from "../perps/types.js";
|
|
5
|
+
import type { PredictionOpenRequest, PredictionOpenResponse, PredictionReissueRequest, PredictionReissueResponse } from "../predictions/types.js";
|
|
6
|
+
/** @internal Relayer transport behind the SDK's functional helpers. */
|
|
7
|
+
export declare class VeiloRelayerClient {
|
|
8
|
+
private readonly transport;
|
|
9
|
+
private readonly relayerPubKey;
|
|
10
|
+
constructor(config?: InternalRelayerClientOptions, retry?: Partial<RetryPolicy>);
|
|
11
|
+
/** Update the auth token (e.g. after register/restore). */
|
|
12
|
+
setAuthToken(token: string): void;
|
|
13
|
+
private encryptPayload;
|
|
14
|
+
/** Request a signature challenge for wallet authentication. */
|
|
15
|
+
getChallenge(walletPublicKey: string): Promise<ChallengeResponse>;
|
|
16
|
+
/** Register a new account with a signed challenge. Returns a JWT auth token. */
|
|
17
|
+
register(data: RegisterRequest): Promise<RegisterResponse>;
|
|
18
|
+
/** Restore an existing account using a signed challenge. Returns a JWT auth token. */
|
|
19
|
+
restore(data: RestoreRequest): Promise<RestoreResponse>;
|
|
20
|
+
/** Check whether a username is available for registration. */
|
|
21
|
+
checkUsername(username: string): Promise<CheckUsernameResponse>;
|
|
22
|
+
/** Look up a user's Veilo public key by username or wallet public key. */
|
|
23
|
+
getVeiloPublicKey(params: {
|
|
24
|
+
username: string;
|
|
25
|
+
publicKey?: never;
|
|
26
|
+
} | {
|
|
27
|
+
publicKey: string;
|
|
28
|
+
username?: never;
|
|
29
|
+
}): Promise<VeiloPublicKeyResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Provision (or retrieve) the Veilo spend key paired with a Solana address.
|
|
32
|
+
* Public and idempotent; the response contains public key material only.
|
|
33
|
+
*/
|
|
34
|
+
preRegisterKey(solanaAddress: string): Promise<PreRegisterKeyResponse>;
|
|
35
|
+
/** Save an encrypted note to the relayer's database. */
|
|
36
|
+
saveEncryptedNote(data: SaveEncryptedNoteRequest): Promise<SaveEncryptedNoteResponse>;
|
|
37
|
+
/** Query encrypted notes for the authenticated user. Requires auth token. */
|
|
38
|
+
queryEncryptedNotes(params?: QueryNotesRequest): Promise<QueryNotesResponse>;
|
|
39
|
+
/** Delete all stored data for the authenticated user. Requires auth token. */
|
|
40
|
+
/**
|
|
41
|
+
* Ask which of these nullifiers the relayer has seen spent.
|
|
42
|
+
*
|
|
43
|
+
* Caller must respect MAX_NULLIFIERS_PER_CHECK; `checkNullifiersSpent` in
|
|
44
|
+
* notes/spent.ts does the chunking. Unauthenticated: a nullifier reveals
|
|
45
|
+
* nothing about ownership on its own.
|
|
46
|
+
*/
|
|
47
|
+
checkNullifiers(nullifiers: string[]): Promise<CheckNullifiersResponse>;
|
|
48
|
+
deleteUserData(): Promise<DeleteUserDataResponse>;
|
|
49
|
+
/** Fetch the current Merkle root for a pool, optionally filtered by mint and tree ID. */
|
|
50
|
+
getMerkleRoot(mintAddress?: string, treeId?: number): Promise<MerkleRootResponse>;
|
|
51
|
+
/** Fetch the full Merkle tree (all leaves) for a pool. */
|
|
52
|
+
getMerkleTree(mintAddress?: string, treeId?: number): Promise<MerkleTreeResponse>;
|
|
53
|
+
/** Submit an encrypted withdrawal request to the relayer. Not retried on failure. */
|
|
54
|
+
submitWithdraw(data: WithdrawRequest): Promise<WithdrawResponse>;
|
|
55
|
+
/** Submit an encrypted private transfer request. Not retried on failure. */
|
|
56
|
+
submitPrivateTransfer(data: PrivateTransferRequest): Promise<PrivateTransferResponse>;
|
|
57
|
+
/** Submit an encrypted private swap request. Not retried on failure. */
|
|
58
|
+
submitPrivateSwap(data: PrivateSwapRequest): Promise<PrivateSwapResponse>;
|
|
59
|
+
submitOpenPosition(data: OpenPositionRequest): Promise<OpenPositionResponse>;
|
|
60
|
+
submitClosePosition(data: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
61
|
+
submitMergePositions(data: MergePositionsRequest): Promise<MergePositionsResponse>;
|
|
62
|
+
submitJperpOpen(data: JperpOpenRequest): Promise<JperpOpenResponse>;
|
|
63
|
+
submitJperpClose(data: JperpCloseRequest): Promise<JperpDecreaseResponse>;
|
|
64
|
+
submitJperpSetTpsl(data: JperpSetTpslRequest): Promise<JperpDecreaseResponse>;
|
|
65
|
+
submitJperpUpdateTpsl(data: JperpUpdateTpslRequest): Promise<JperpDecreaseResponse>;
|
|
66
|
+
submitJperpCancelTrigger(data: JperpCancelTriggerRequest): Promise<JperpCancelTriggerResponse>;
|
|
67
|
+
submitJperpReissue(data: JperpReissueRequest): Promise<JperpReissueResponse>;
|
|
68
|
+
submitJperpRecoverSeed(data: JperpRecoverSeedRequest): Promise<JperpRecoverSeedResponse>;
|
|
69
|
+
submitJperpRecoverNative(data: JperpRecoverNativeRequest): Promise<JperpRecoverNativeResponse>;
|
|
70
|
+
submitPredictionOpen(data: PredictionOpenRequest): Promise<PredictionOpenResponse>;
|
|
71
|
+
submitPredictionReissue(data: PredictionReissueRequest): Promise<PredictionReissueResponse>;
|
|
72
|
+
private submitEncrypted;
|
|
73
|
+
}
|