Sapling WASM library for web developers

The Sapling WASM library brings the Zcash Rust crates to the web and enables Sapling operations for web applications.

AirGap
Published in
2 min readAug 17, 2021

--

Since Edo, the Tezos protocol upgrade that was recently injected, privacy preserving transaction will be possible on Tezos. AirGap has released Sapling support on testnet and will soon enable it on mainnet as well.

During the requirements engineering phase of the AirGap integration, the team became aware that there is no Sapling implementation for web developers.

We’ve started working on the airgap-sapling library and made the development version available on npm as a developer preview.

$ npm install --save @airgap/sapling-wasm

Address, key, and transaction generation

The library handles all relevant Sapling operations, from address creation to transaction signing.

Here is a small example, more advanced examples can be found in the repository.

import * as bip39 from 'bip39'
import * as sapling from '@airgap/sapling-wasm'
import { SaplingPaymentAddress } from '@airgap/sapling-wasm'

const mnemonic: string = bip39.generateMnemonic()
const seed: Buffer = await bip39.mnemonicToSeed(mnemonic, '')
const derivationPath: string = 'm/'

// create an extended spending key
const spendingKey: Buffer = await sapling.getExtendedSpendingKey(seed, derivationPath)
console.log('spendingKey =', spendingKey.toString('hex'))

// create an extended full viewing key
const viewingKey: Buffer = await sapling.getExtendedFullViewingKey(seed, derivationPath)
console.log('viewingKey =', viewingKey.toString('hex'))

// get default address
const address: SaplingPaymentAddress = await sapling.getPaymentAddressFromViewingKey(viewingKey)
console.log(
'address.index =', address.index.toString('hex'),
'address.raw =', address.raw.toString('hex')
)

What does this mean for developers?

Web developers that want to work on Sapling support for Tezos can use the library without having to re-implement the logic themselves.

Additionally, libraries like the Tezos Typescript library Taquito can use the sapling-wasm library for their integration.

Download AirGap

AirGap Wallet
📱 iOS — App Store
📱 Android — Google Play (GitHub APK)
💻 macOS
💻 Windows
💻 Linux

AirGap Vault
📱 iOS — App Store
📱 Android — Google Play (GitHub APK)

Interested in AirGap? Stay in touch.

Telegram | GitHub | Website | Twitter | Reddit

--

--