Wasm, Android and iOS wrappers around Zcash Rust crates.
The project is divided into the following packages:
sapling
- common sources in Rust, provides C and Wasm bindings for Zcash cratessapling-wasm
- a JavaScript library using Wasm bindings from thesapling
packagesapling-android
- a native Android library using C bindings from thesapling
packagesapling-ios
- a native iOS library using C bindings from thesapling
package
To add JS AirGap Sapling library into your project run:
$ npm install --save @airgap/sapling-wasm
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')
)
More advanced examples can be found in js/examples
.
To add Android AirGap Sapling library into your project:
-
Ensure Android NDK is supported in your project.
-
Add the JitPack repository to your root
build.gradle
file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency:
def saplingVersion = "x.y.z"
implementation "com.github.airgap-it:airgap-sapling:$saplingVersion"
To add iOS AirGap Sapling into your project, add the package dependency:
Open the Add Package Dependency
window (as described in the official guide) and enter the AirGap Sapling GitHub repository URL:
https://github.com/airgap-it/airgap-sapling
Add the following dependency in your Package.swift
file:
.package(url: "https://github.com/airgap-it/airgap-sapling", from: "x.y.z")