GithubHelp home page GithubHelp logo

kukai-wallet / kukai-crypto-swift Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 1.6 MB

Kukai Crypto Swift is a native Swift library for creating regular or HD wallets for the Tezos blockchain

License: MIT License

Swift 100.00%
bip39 bip44 blockchain ios macos swift tezos wallet cryptocurrency tez tezos-blockchain xtz

kukai-crypto-swift's Introduction

Kukai Crypto Swift

Platforms Swift Package Manager License

Kukai Crypto Swift is a native Swift library for creating regular and HD key pairs for the Tezos blockchain. Supporting both TZ1 (Ed25519) and TZ2 (secp256k1) for regular pairs, and TZ1 (Ed25519 (BIP44 via SLIP-0010)) for HD pairs.


Feature set includes:
  • Create BIP39 mnemonics in English or Chinese
  • Generate a cryptographic seed from a Menmonic in a tiny fraction of a second
  • Create TZ1 or TZ2 key pair from a seed
  • Derive HD key pair from a seed and derivation path
  • Support for optional passwords

Based off:

Install

Kukai Crypto Swift supports the Swift Package Manager. Either use the Xcode editor to add to your project by clicking File -> Swift Packages -> Add Package Dependency, search for the git repo https://github.com/kukai-wallet/kukai-crypto-swift.git and choose from version 1.0.0.

Or add it to your Package.swift dependencies like so:

dependencies: [
    .package(url: "https://github.com/kukai-wallet/kukai-crypto-swift", from: "1.0.0")
]


How to use

Create a new Mnemonic

let mnemonic = try Mnemonic(numberOfWords: .twentyFour)

Create a Mnemonic from an existing phrase

let mnemonic = try Mnemonic(seedPhrase: "word1 word2 word3 ...")

Create a regular key pair and get a Tezos address

let keyPair = KeyPair.regular(fromMnemonic: mnemonic, passphrase: "", andSigningCurve: .ed25519)

print(keyPair.publicKey.publicKeyHash) // tz1Abc123...
let keyPair = KeyPair.regular(fromMnemonic: mnemonic, passphrase: "", andSigningCurve: .secp256k1)

print(keyPair.publicKey.publicKeyHash) // tz2def456...

Create a HD key pair

let keyPair = KeyPair.hd(fromMnemonic: mnemonic, passphrase: "", andDerivationPath: "44'/1729'/0'/0'")

Sign a message

let messageToSign = "something very interesting that needs to be signed".bytes
let result = keyPair.privateKey.sign(bytes: messageToSign)

print("Result hex: \(result.hexString)") // c4d20c77d627d8c07e....


Documentation

Compiled Swift Doc's can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.