diff --git a/LICENSE b/LICENSE-APACHEv2 similarity index 100% rename from LICENSE rename to LICENSE-APACHEv2 diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..8766e65 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Status Research & Development GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index a98d1a3..419fb60 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status (Travis)](https://img.shields.io/travis/status-im/mpint/master.svg?label=Linux%20/%20macOS "Linux/macOS build status (Travis)")](https://travis-ci.org/status-im/mpint) [![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg) A fast and portable multi-precision integer library in pure Nim @@ -14,3 +15,12 @@ Main focus: - casting to and from array of bytes - converting to and from Hex - converting to and from decimal strings + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. diff --git a/mpint.nimble b/mpint.nimble index 4245a4f..cbef02f 100644 --- a/mpint.nimble +++ b/mpint.nimble @@ -2,12 +2,12 @@ packageName = "mpint" version = "0.0.1" author = "Status Research & Development GmbH" description = "Efficient multiprecision int in Nim" -license = "Apache License 2.0" +license = "Apache License 2.0 or MIT" srcDir = "src" ### Dependencies -requires "nim >= 0.17.2" +requires "nim >= 0.18" proc test(name: string, lang: string = "c") = if not dirExists "build": diff --git a/src/mpint.nim b/src/mpint.nim index 8899899..475409d 100644 --- a/src/mpint.nim +++ b/src/mpint.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ./uint_type, ./uint_init, diff --git a/src/private/bithacks.nim b/src/private/bithacks.nim index 7735608..3d64d4e 100644 --- a/src/private/bithacks.nim +++ b/src/private/bithacks.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../uint_type @@ -50,4 +56,4 @@ proc bit_length*[T: MpUint](n: T): int {.noSideEffect.}= if n.hi.bit_length == 0: n.lo.bit_length else: - n.hi.bit_length + maxHalfRepr \ No newline at end of file + n.hi.bit_length + maxHalfRepr diff --git a/src/private/casting.nim b/src/private/casting.nim index 4d42790..9dfc288 100644 --- a/src/private/casting.nim +++ b/src/private/casting.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../uint_type, macros @@ -50,4 +56,4 @@ proc toMpUint*[T: SomeInteger](n: T): auto {.noSideEffect, inline.} = elif T is uint16: return (cast[ptr [MpUint[uint8]]](unsfddr n))[] else: - raise newException(ValueError, "You can only cast uint16, uint32 or uint64 to multiprecision integers") \ No newline at end of file + raise newException(ValueError, "You can only cast uint16, uint32 or uint64 to multiprecision integers") diff --git a/src/uint_binary_ops.nim b/src/uint_binary_ops.nim index 2bcca90..d2e53e8 100644 --- a/src/uint_binary_ops.nim +++ b/src/uint_binary_ops.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ./private/[bithacks, casting], uint_type, @@ -153,4 +159,4 @@ proc `div`*[T: BaseUint](x, y: T): T {.inline, noSideEffect.} = proc `mod`*[T: BaseUint](x, y: T): T {.inline, noSideEffect.} = ## Division operation for multi-precision unsigned uint - divmod(x,y).rem \ No newline at end of file + divmod(x,y).rem diff --git a/src/uint_bitwise_ops.nim b/src/uint_bitwise_ops.nim index 6b45c9b..54f8ded 100644 --- a/src/uint_bitwise_ops.nim +++ b/src/uint_bitwise_ops.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import uint_type diff --git a/src/uint_comparison.nim b/src/uint_comparison.nim index 58783f5..edc5282 100644 --- a/src/uint_comparison.nim +++ b/src/uint_comparison.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ./uint_type diff --git a/src/uint_init.nim b/src/uint_init.nim index d713f71..d0604a3 100644 --- a/src/uint_init.nim +++ b/src/uint_init.nim @@ -1,9 +1,15 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import typetraits -import ./private/bithacks, +import ./private/[bithacks, casting], ./uint_type proc initMpUint*[T: BaseUint; U: BaseUInt](n: T, base_type: typedesc[U]): MpUint[U] {.noSideEffect.} = @@ -26,4 +32,4 @@ proc u128*[T: BaseUInt](n: T): UInt128 {.noSideEffect, inline.}= initMpUint(n, uint64) proc u256*[T: BaseUInt](n: T): UInt256 {.noSideEffect, inline.}= - initMpUint(n, UInt256) \ No newline at end of file + initMpUint(n, UInt256) diff --git a/src/uint_logical_ops.nim b/src/uint_logical_ops.nim index 1d186c2..5f19185 100644 --- a/src/uint_logical_ops.nim +++ b/src/uint_logical_ops.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import uint_type @@ -21,4 +27,4 @@ proc `and`*(x, y: MpUint): MpUint {.noInit, noSideEffect, inline.}= proc `xor`*(x, y: MpUint): MpUint {.noInit, noSideEffect, inline.}= ## `Bitwise xor` of numbers x and y result.lo = x.lo xor y.lo - result.hi = x.hi xor y.hi \ No newline at end of file + result.hi = x.hi xor y.hi diff --git a/src/uint_type.nim b/src/uint_type.nim index 50f4572..05732d2 100644 --- a/src/uint_type.nim +++ b/src/uint_type.nim @@ -1,6 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). - +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. type MpUint*{.packed.}[BaseUint] = object @@ -23,4 +28,4 @@ template convBool(typ: typedesc): untyped = convBool(uint8) convBool(uint16) convBool(uint32) -convBool(uint64) \ No newline at end of file +convBool(uint64) diff --git a/tests/all_tests.nim b/tests/all_tests.nim index abb11d9..785a027 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -1,7 +1,13 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).$ +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import test_endianness, test_comparison, test_addsub, - test_muldiv \ No newline at end of file + test_muldiv diff --git a/tests/test_addsub.nim b/tests/test_addsub.nim index 22006fe..5186752 100644 --- a/tests/test_addsub.nim +++ b/tests/test_addsub.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../src/mpint, unittest @@ -67,4 +73,4 @@ suite "Testing substraction implementation": let a = initMpUint(100, uint8) let b = initMpUint(101, uint8) - check: cast[uint16](a-b) == high(uint16) \ No newline at end of file + check: cast[uint16](a-b) == high(uint16) diff --git a/tests/test_bitwise.nim b/tests/test_bitwise.nim index 159fd0d..2633c89 100644 --- a/tests/test_bitwise.nim +++ b/tests/test_bitwise.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../src/mpint, unittest diff --git a/tests/test_comparison.nim b/tests/test_comparison.nim index 4019826..ae6b4cf 100644 --- a/tests/test_comparison.nim +++ b/tests/test_comparison.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../src/mpint, unittest @@ -31,4 +37,4 @@ suite "Testing comparison operators": check: b >= a check: not (b >= a + b) check: b + b >= a + a + a - check: cast[Mpuint[uint8]](c) >= a * b \ No newline at end of file + check: cast[Mpuint[uint8]](c) >= a * b diff --git a/tests/test_endianness.nim b/tests/test_endianness.nim index f693c19..9692bb8 100644 --- a/tests/test_endianness.nim +++ b/tests/test_endianness.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../src/mpint, unittest diff --git a/tests/test_muldiv.nim b/tests/test_muldiv.nim index c53d7de..a8a2074 100644 --- a/tests/test_muldiv.nim +++ b/tests/test_muldiv.nim @@ -1,5 +1,11 @@ -# Copyright (c) 2018 Status Research & Development GmbH -# Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT). +# Mpint +# Copyright 2018 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. import ../src/mpint, unittest