Coder Social home page Coder Social logo

hyugit / uint256 Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 10.0 94 KB

An UInt256 library written in Swift 4

License: MIT License

Swift 98.69% Objective-C 0.37% Ruby 0.94%
swift swift4 carthage swift-package-manager uint256 biginteger bigint ios macos cocoapods

uint256's Introduction

UInt256

Build Status Language Platform Carthage Compatible CocoaPods Compatible Coverage Status

A UInt256 library written in Swift 4, inspired by CryptoCoinSwift/UInt256

Features

This library provides a UInt256 struct that conforms nicely to Swift's FixedWidthInteger and UnsignedInteger protocols. According to Apple, the two are the necessary top level protocols for an UInt member: here

It supports a complete set of arithmetic operations, as well as properties and functions that are common to other UInt family members such as UInt64, UInt32, UInt8, etc. The library leverages Karatsuba fast multiplication algorithm, Divide and Conquer division algorithm, Barrett Algorithm for division and other efficient algos for other operators. Other features include integer literal representation (ExpressibleByIntegerLiteral), default description (CustomStringConvertible) and Hashable.

The library is written entirely in Swift 4. It can be installed as a Swift Package, a Carthage package or a CocoaPod. And a playground is also included as a testbench.

Please feel free to submit new feature requests and report issues here on GitHub. ๐Ÿ˜ƒ

Please use the playground to try out all the features!

Swift Protocol Conformance

The main struct UInt256 conforms strictly to the following protocols:

  • FixedWidthInteger
  • UnsignedInteger
  • BinaryInteger
  • Numeric
  • Comparable
  • Equatable
  • CustomStringConvertible
  • Hashable

Requirements

  • iOS 8.0+ / macOS 10.10+
  • Xcode 8.0+
  • Swift 4

Communication

If you need any help or have a feature request, please open an issue here on GitHub; if you found a bug or want to help with the development, please submit a pull request. All contributions are welcome! ๐Ÿ˜ƒ

Installation

Carthage

First, make sure have Carthage installed:

brew update
brew install carthage

To integrate this library into your Xcode project, simply put the following line into your carfile:

github "hyugit/UInt256"

Finally, run carthage update to build the framework, and drag the built framework (either UInt256_iOS.framework or UInt256_macOS.framework) into your Xcode project

Swift Package Manager

This library supports Swift Package Manager as well. If you have your swift package config set up already, please add the following line to your Package.swift:

dependencies: [
    .package(url: "https://github.com/hyugit/UInt256.git", from: "4.0.0")
]

CocoaPods

Install CocoaPods following its official guide

To integrate UInt256 into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'UInt256', :git => 'https://github.com/hyugit/UInt256.git'
end

And run pod install afterwards.

Manual installation

You can also add this library manually to your project.

In the terminal, under your top level project directory, add this library as a git submodule by running the following command:

git submodule add https://github.com/hyugit/UInt256.git

Have Xcode open, go to your new UInt256 subdirectory in Finder, drag UInt256.xcodeproj into the project navigator of your project. Remember to embed the framework to your build target.

Next steps...

  • add documentation
  • look into leveraging GPU/Metal
  • benchmark
  • make UInt256 conform to FixedWidthInteger
  • add an example, preferably through a playground
  • add CocoaPods support
  • more tests, test coverage, corner cases, lint, code review
  • automate build and test runs
  • karatsuba multiplication
  • fast modulo, division, and other algos

License

This library is released under the MIT license. Please see LICENSE

uint256's People

Contributors

hyugit avatar larsschwegmann avatar sajjon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

uint256's Issues

I pod trunk pushed

I pod trunk pushed the podspec, I want to add you as owner, send me an email so can add you as owner: [email protected]

I will pod trunk push EllipticCurve as well. I will open a PR in that repo for the podspec, listing this repo as a dependency (that is why I had to pod trunk push this repo).

Thanks!

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.