npm.io
0.3.0 • Published yesterday

@taquito/sapling-wasm

Licence
MIT
Version
0.3.0
Deps
0
Size
5.2 MB
Vulns
0
Weekly
0

Sapling Wasm

npm

A Wasm wrapper around Zcash Rust crates, published as part of the Taquito package namespace.

The published package name is @taquito/sapling-wasm.

Install

To add the JavaScript Sapling library into your project:

npm install --save @taquito/sapling-wasm

Examples

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

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

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

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

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

More advanced examples can be found in ./examples.

Development

npm run build