Giter Site home page Giter Site logo

sshyran / cosmostation-mobile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cosmostation/cosmostation-mobile

0.0 1.0 0.0 37.12 MB

:alien: Cosmostation Wallet Apps (Android & iOS)

License: MIT License

Java 58.70% Swift 39.70% Objective-C 1.57% Ruby 0.03%

cosmostation-mobile's Introduction

Cosmostation logo

Cosmostation Mobile Wallet

Welcome to Cosmostation's Open Source Mobile Apps!

MIT Twitter Follow

๐Ÿš€ Developed / Developing by Cosmostation

About

Cosmostation wallet apps are non-custodial tendermint-based wallet that supports Cosmos Network. We will add more tendermint-based blockchain projects in the coming updates, such as IRISnet, IOV, Kava.

Notice1

for generate signature with swift you have to modify BicoinKey library after pod intalled. please check below code for get correct signature in tendermint /Pods/BitcoinKit/Source/Crypro.swift (line ~59)

  public static func sign(_ data: Data, privateKey: PrivateKey) throws -> Data {
      let ctx = secp256k1_context_create(UInt32(SECP256K1_CONTEXT_SIGN))!
      defer { secp256k1_context_destroy(ctx) }

      let signature = UnsafeMutablePointer<secp256k1_ecdsa_signature>.allocate(capacity: 1)
      defer { signature.deallocate() }

      var paddingKey = Data()
      let value: UInt8 = 0
      for i in privateKey.raw.count..<32 {
          paddingKey.append(value)
      }
      paddingKey.append(privateKey.raw)


      let status = data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
          paddingKey.withUnsafeBytes { secp256k1_ecdsa_sign(ctx, signature, ptr, $0, nil, nil) }
      }
      guard status == 1 else { throw CryptoError.signFailed }

      let normalizedsig = UnsafeMutablePointer<secp256k1_ecdsa_signature>.allocate(capacity: 1)
      defer { normalizedsig.deallocate() }
      secp256k1_ecdsa_signature_normalize(ctx, normalizedsig, signature)

      var length: size_t = 128
      var der = Data(count: length)
      guard der.withUnsafeMutableBytes({ return secp256k1_ecdsa_signature_serialize_der(ctx, $0, &length, normalizedsig) }) == 1 else { throw CryptoError.noEnoughSpace }
      der.count = length
      return der
  }

Notice2

IOS to prevent Binance-libarary and Bitcoinkit from conflict with secp256k1, we have to modifiy dependancy or else. instead modify dependancy, just change file name for simple using.

If you want local build, please check below steps.

  1. becuase we uploaded full pod file, you have to re install pod files.
  2. pod deintegrate(https://github.com/CocoaPods/cocoapods-deintegrate)
  3. pod install
  4. change your BitcoinKit's modle.modulemap (any name is ok instead "secp256k12")
module secp256k12 [system] {
    private header "include/secp256k1.h"
    link "secp256k1"
}
  1. fix bitcoinkit's import name to new one.(Bitcoinkit/Cryto.swift line 32, Bitcoinkit/ScriptMachine.swift line 26)

Notice3

For Xcode upper 11 and new swift version. we have local fixed with HDwalletKit and BitcoinKit 1.0.2 DHWalletKit/Script.swift line 454

    public static func buildPublicKeyHashOut(pubKeyHash: Data) -> Data {
//        let tmp: Data = Data() + OpCode.OP_DUP + OpCode.OP_HASH160 + UInt8(pubKeyHash.count) + pubKeyHash + OpCode.OP_EQUALVERIFY
        let tmp: Data = Data() + OpCode.OP_DUP + OpCode.OP_HASH160 + UInt8(pubKeyHash.count)
        let secondTmp = pubKeyHash + OpCode.OP_EQUALVERIFY
        return tmp + secondTmp + OpCode.OP_CHECKSIG
    }

BitCoinkit/Script.swift line 461

    public static func buildPublicKeyHashOut(pubKeyHash: Data) -> Data {
//        let tmp: Data = Data() + OpCode.OP_DUP + OpCode.OP_HASH160 + UInt8(pubKeyHash.count) + pubKeyHash + OpCode.OP_EQUALVERIFY
//        return tmp + OpCode.OP_CHECKSIG
        let tmp: Data = Data() + OpCode.OP_DUP + OpCode.OP_HASH160 + UInt8(pubKeyHash.count)
        let secondTmp = pubKeyHash + OpCode.OP_EQUALVERIFY
        return tmp + secondTmp + OpCode.OP_CHECKSIG
    }

Notice4

for local build upper xcode 11.3 you have to change command line tools path update

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

Downloads

Cosmostation's Services and Community

License

Copyright ยฉ Cosmostation, Inc. All rights reserved.

Licensed under the MIT.

cosmostation-mobile's People

Contributors

wannabit-yongjoo avatar heartbreaker avatar ronaldstoner avatar jaybxyz avatar stamper-dev avatar

Watchers

 avatar

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.