Mantle
Mantle SDK repository
Initialising a new Mantle instance:
const mantle = new Mantle()
The mantle instance exposes methods to facilitate, amongst other things, mnemonic and HD public/private key generation, IPFS API access etc.
Mnemonic generation
Mnemonic, HD private/public keys and private/public keys are generated via loadMnemonic
. Supply a mnemonic associated with an existing account in order to retrieve key information, or supply no argument in order to generate a new set of keys.
Symmetric encryption
Facilitated via the encryptSymmetric
and decryptSymmetric
static methods. Shared secrets can be generated via createSymmetricKey
.
IPFS setup
Examples
Please see tests in test/mantle.spec.js
for further examples.
Mnemonic generation and key removal
mantle.mnemonic
mantle.loadMnemonic()
mantle.mnemonic
mantle.removeKeys()
mantle.mnemonic
mantle.loadMnemonic('tragic panic toast hazard royal marine visual laptop salmon guard finger upper')
Asymmetric encryption/decryption
const data = 'foo'
const encrypted = Mantle.encrypt(data, mantle.publicKey)
const decrypted = Mantle.decrypt(encrypted, mantle.privateKey)
Symmetric encryption/decryption
const data = 'foo'
const secret = Mantle.createSymmetricKey()
const encrypted = Mantle.encryptSymmetric(data, secret)
const decrypted = Mantle.decryptSymmetric(encrypted, secret)
Local testing
- Install dependencies:
npm install
- Install and initialize IPFS (see IPFS setup section)
- Run the IPFS daemon:
ipfs daemon
- Run test suite:
npm test
Documentation
Please check the documentation created in this repo: https://github.com/appliedblockchain/mantle-intro-doc