diff --git a/composer.json b/composer.json index f95de58..b28110e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require": { "web3p/rlp": "~0.2", - "web3p/secp256k1": "~0.2", - "kornrunner/keccak": "~1" + "kornrunner/keccak": "~1", + "simplito/elliptic-php": "1.0.3" } } diff --git a/composer.lock b/composer.lock index b51bca3..658fa03 100644 --- a/composer.lock +++ b/composer.lock @@ -1,45 +1,73 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d49eae17ce62b9584285247e680e8e4a", + "content-hash": "4a0c191d5a2902125fc452718993b5ce", "packages": [ { - "name": "fgrosse/phpasn1", - "version": "dev-master", + "name": "kornrunner/keccak", + "version": "1.0.2", "source": { "type": "git", - "url": "https://github.com/fgrosse/PHPASN1.git", - "reference": "0e27e71e3d0a8d5c3f1471d727fd9574d920f33c" + "url": "https://github.com/kornrunner/php-keccak.git", + "reference": "b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/0e27e71e3d0a8d5c3f1471d727fd9574d920f33c", - "reference": "0e27e71e3d0a8d5c3f1471d727fd9574d920f33c", + "url": "https://api.github.com/repos/kornrunner/php-keccak/zipball/b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34", + "reference": "b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34", "shasum": "" }, "require": { - "ext-gmp": "*", - "php": ">=7.0.0" + "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "~6.3", - "satooshi/php-coveralls": "dev-master" - }, - "suggest": { - "php-curl": "For loading OID information from the web if they have not bee defined statically" + "phpunit/phpunit": "~7", + "satooshi/php-coveralls": "~2" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" + "autoload": { + "psr-4": { + "kornrunner\\": "src" } }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Boris Momcilovic", + "homepage": "https://github.com/kornrunner/php-keccak" + } + ], + "description": "Pure PHP implementation of Keccak", + "keywords": [ + "keccak", + "sha-3" + ], + "time": "2018-03-05T10:32:01+00:00" + }, + { + "name": "simplito/bigint-wrapper-php", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/simplito/bigint-wrapper-php.git", + "reference": "cf21ec76d33f103add487b3eadbd9f5033a25930" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/simplito/bigint-wrapper-php/zipball/cf21ec76d33f103add487b3eadbd9f5033a25930", + "reference": "cf21ec76d33f103add487b3eadbd9f5033a25930", + "shasum": "" + }, + "type": "library", "autoload": { "psr-4": { - "FG\\": "lib/" + "BI\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -48,58 +76,38 @@ ], "authors": [ { - "name": "Friedrich Große", - "email": "friedrich.grosse@gmail.com", - "homepage": "https://github.com/FGrosse", - "role": "Author" - }, - { - "name": "All contributors", - "homepage": "https://github.com/FGrosse/PHPASN1/contributors" + "name": "Simplito Team", + "email": "s.smyczynski@simplito.com", + "homepage": "https://simplito.com" } ], - "description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.", - "homepage": "https://github.com/FGrosse/PHPASN1", - "keywords": [ - "DER", - "asn.1", - "asn1", - "ber", - "binary", - "decoding", - "encoding", - "x.509", - "x.690", - "x509", - "x690" - ], - "time": "2017-12-17 10:21:51" + "description": "Common interface for php_gmp and php_bcmath modules", + "time": "2018-02-27T12:38:08+00:00" }, { - "name": "kornrunner/keccak", - "version": "1.0.2", + "name": "simplito/bn-php", + "version": "1.1.2", "source": { "type": "git", - "url": "https://github.com/kornrunner/php-keccak.git", - "reference": "b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34" + "url": "https://github.com/simplito/bn-php.git", + "reference": "e852fcd27e4acbc32459606d7606e45a85e42465" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kornrunner/php-keccak/zipball/b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34", - "reference": "b3cd83ded1acff7af40b4ca5b8ea76b164ed0c34", + "url": "https://api.github.com/repos/simplito/bn-php/zipball/e852fcd27e4acbc32459606d7606e45a85e42465", + "reference": "e852fcd27e4acbc32459606d7606e45a85e42465", "shasum": "" }, "require": { - "php": ">=7.1.0" + "simplito/bigint-wrapper-php": "~1.0.0" }, "require-dev": { - "phpunit/phpunit": "~7", - "satooshi/php-coveralls": "~2" + "phpunit/phpunit": "*" }, "type": "library", "autoload": { "psr-4": { - "kornrunner\\": "src" + "BN\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -108,45 +116,40 @@ ], "authors": [ { - "name": "Boris Momcilovic", - "homepage": "https://github.com/kornrunner/php-keccak" + "name": "Simplito Team", + "email": "s.smyczynski@simplito.com", + "homepage": "https://simplito.com" } ], - "description": "Pure PHP implementation of Keccak", - "keywords": [ - "keccak", - "sha-3" - ], - "time": "2018-03-05T10:32:01+00:00" + "description": "Big number implementation compatible with bn.js", + "time": "2018-04-12T11:07:43+00:00" }, { - "name": "mdanter/ecc", - "version": "dev-master", + "name": "simplito/elliptic-php", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/phpecc/phpecc.git", - "reference": "7c77251d3a7f52ef4ebc1c023452aad96ab13c83" + "url": "https://github.com/simplito/elliptic-php.git", + "reference": "cab829d270dfd6acdff8383d862ed02a12d1f9dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpecc/phpecc/zipball/7c77251d3a7f52ef4ebc1c023452aad96ab13c83", - "reference": "7c77251d3a7f52ef4ebc1c023452aad96ab13c83", + "url": "https://api.github.com/repos/simplito/elliptic-php/zipball/cab829d270dfd6acdff8383d862ed02a12d1f9dd", + "reference": "cab829d270dfd6acdff8383d862ed02a12d1f9dd", "shasum": "" }, "require": { "ext-gmp": "*", - "fgrosse/phpasn1": "v2.0.x", - "php": ">=7.0" + "simplito/bn-php": "~1.1.0" }, "require-dev": { - "phpunit/phpunit": "^6.0", - "squizlabs/php_codesniffer": "~2", - "symfony/yaml": "~2.6|~3.0" + "phpbench/phpbench": "@dev", + "phpunit/phpunit": "*" }, "type": "library", "autoload": { "psr-4": { - "Mdanter\\Ecc\\": "src/" + "Elliptic\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -155,29 +158,21 @@ ], "authors": [ { - "name": "Matyas Danter", - "homepage": "http://matejdanter.com/", - "role": "Author" - }, - { - "name": "Thibaud Fabre", - "email": "thibaud@aztech.io", - "homepage": "http://aztech.io", - "role": "Maintainer" - }, - { - "name": "Thomas Kerin", - "email": "afk11@users.noreply.github.com", - "role": "Maintainer" + "name": "Simplito Team", + "email": "s.smyczynski@simplito.com", + "homepage": "https://simplito.com" } ], - "description": "PHP Elliptic Curve Cryptography library", - "homepage": "https://github.com/phpecc/phpecc", + "description": "Fast elliptic curve cryptography", + "homepage": "https://github.com/simplito/elliptic-php", "keywords": [ - "Diffie", + "Curve25519", "ECDSA", - "Hellman", + "Ed25519", + "EdDSA", + "cryptography", "curve", + "ecc", "ecdh", "elliptic", "nistp192", @@ -185,11 +180,9 @@ "nistp256", "nistp384", "nistp521", - "phpecc", - "secp256k1", - "secp256r1" + "secp256k1" ], - "time": "2018-02-12 08:51:13" + "time": "2018-04-12T11:17:52+00:00" }, { "name": "web3p/rlp", @@ -226,45 +219,6 @@ ], "description": "Recursive Length Prefix Encoding in PHP.", "time": "2018-03-19T15:21:29+00:00" - }, - { - "name": "web3p/secp256k1", - "version": "v0.2", - "source": { - "type": "git", - "url": "https://github.com/web3p/secp256k1.git", - "reference": "f63f4e88de662311f114b510a1c17a460e20dbf2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/web3p/secp256k1/zipball/f63f4e88de662311f114b510a1c17a460e20dbf2", - "reference": "f63f4e88de662311f114b510a1c17a460e20dbf2", - "shasum": "" - }, - "require": { - "mdanter/ecc": "dev-master" - }, - "require-dev": { - "phpunit/phpunit": "~6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Web3p\\Secp256k1\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "sc0Vu", - "email": "alk03073135@gmail.com" - } - ], - "description": "Ethereum secp256k1 library in PHP.", - "time": "2018-03-20T02:37:13+00:00" } ], "packages-dev": [ @@ -321,7 +275,7 @@ "constructor", "instantiate" ], - "time": "2018-03-05 09:41:42" + "time": "2018-03-05T09:41:42+00:00" }, { "name": "myclabs/deep-copy", @@ -371,7 +325,7 @@ "object", "object graph" ], - "time": "2017-12-18 00:20:24" + "time": "2017-12-18T00:20:24+00:00" }, { "name": "phar-io/manifest", @@ -426,7 +380,7 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-04-07 07:07:10" + "time": "2017-04-07T07:07:10+00:00" }, { "name": "phar-io/version", @@ -477,28 +431,28 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "dev-master", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "81339187a96c6fdb70cd876b129891f8ca501508" + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/81339187a96c6fdb70cd876b129891f8ca501508", - "reference": "81339187a96c6fdb70cd876b129891f8ca501508", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=5.5" }, "require-dev": { - "phpunit/phpunit": "^6" + "phpunit/phpunit": "^4.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -527,30 +481,32 @@ "reflection", "static analysis" ], - "time": "2018-02-14 18:58:54" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "dev-master", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "182609736818dc750d42470c0be2a5ed74bad3bd" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/182609736818dc750d42470c0be2a5ed74bad3bd", - "reference": "182609736818dc750d42470c0be2a5ed74bad3bd", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": ">=7.1", - "phpdocumentor/type-resolver": "^0", - "webmozart/assert": "^1" + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", "extra": { @@ -560,7 +516,9 @@ }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src" + "phpDocumentor\\Reflection\\": [ + "src/" + ] } }, "notification-url": "https://packagist.org/downloads/", @@ -574,39 +532,41 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2018-02-14 19:00:58" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "dev-master", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "69bf1b199584f2004365a150c2e6cfbe852b6d66" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/69bf1b199584f2004365a150c2e6cfbe852b6d66", - "reference": "69bf1b199584f2004365a150c2e6cfbe852b6d66", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { - "php": ">=7.1", - "phpdocumentor/reflection-common": "^2" + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.5" + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src" + "phpDocumentor\\Reflection\\": [ + "src/" + ] } }, "notification-url": "https://packagist.org/downloads/", @@ -619,7 +579,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2018-02-14 18:59:20" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", @@ -627,19 +587,19 @@ "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + "reference": "5d4764d0b9beb04d5b36801c868cfc79a12c70a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/5d4764d0b9beb04d5b36801c868cfc79a12c70a3", + "reference": "5d4764d0b9beb04d5b36801c868cfc79a12c70a3", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { @@ -682,7 +642,7 @@ "spy", "stub" ], - "time": "2018-02-19 10:16:54" + "time": "2018-04-19T14:17:18+00:00" }, { "name": "phpunit/php-code-coverage", @@ -690,12 +650,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "982ce790a6f31b8f1319a15d86e4614b109af25e" + "reference": "83f09c29758c52e71bdb81ad2cc9124b85b5a4ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/982ce790a6f31b8f1319a15d86e4614b109af25e", - "reference": "982ce790a6f31b8f1319a15d86e4614b109af25e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/83f09c29758c52e71bdb81ad2cc9124b85b5a4ef", + "reference": "83f09c29758c52e71bdb81ad2cc9124b85b5a4ef", "shasum": "" }, "require": { @@ -745,7 +705,7 @@ "testing", "xunit" ], - "time": "2017-12-07 10:13:30" + "time": "2018-04-07T12:06:18+00:00" }, { "name": "phpunit/php-file-iterator", @@ -792,7 +752,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27 13:52:08" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -882,7 +842,7 @@ "keywords": [ "timer" ], - "time": "2018-01-06 05:27:16" + "time": "2018-01-06T05:27:16+00:00" }, { "name": "phpunit/php-token-stream", @@ -931,7 +891,7 @@ "keywords": [ "tokenizer" ], - "time": "2017-11-27 08:47:38" + "time": "2017-11-27T08:47:38+00:00" }, { "name": "phpunit/phpunit", @@ -939,12 +899,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ea739aae4742aa4eae1e98d4d06acdbf01692415" + "reference": "1617f456e1522f9b32723549ddc5a370f8322e91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea739aae4742aa4eae1e98d4d06acdbf01692415", - "reference": "ea739aae4742aa4eae1e98d4d06acdbf01692415", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1617f456e1522f9b32723549ddc5a370f8322e91", + "reference": "1617f456e1522f9b32723549ddc5a370f8322e91", "shasum": "" }, "require": { @@ -1015,7 +975,7 @@ "testing", "xunit" ], - "time": "2018-03-15T16:51:04+00:00" + "time": "2018-04-16T03:59:19+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1074,7 +1034,7 @@ "mock", "xunit" ], - "time": "2018-01-07 17:10:51" + "time": "2018-01-07T17:10:51+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1119,11 +1079,11 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04 10:23:55" + "time": "2017-03-04T10:23:55+00:00" }, { "name": "sebastian/comparator", - "version": "dev-master", + "version": "2.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", @@ -1183,7 +1143,7 @@ "compare", "equality" ], - "time": "2018-02-01 13:46:46" + "time": "2018-02-01T13:46:46+00:00" }, { "name": "sebastian/diff", @@ -1235,20 +1195,20 @@ "keywords": [ "diff" ], - "time": "2017-12-14 11:32:19" + "time": "2017-12-14T11:32:19+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "cd35e43a53ec1c10424a5dec250c30e952e09ced" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd35e43a53ec1c10424a5dec250c30e952e09ced", + "reference": "cd35e43a53ec1c10424a5dec250c30e952e09ced", "shasum": "" }, "require": { @@ -1285,7 +1245,7 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "time": "2018-03-21T07:21:42+00:00" }, { "name": "sebastian/exporter", @@ -1352,7 +1312,7 @@ "export", "exporter" ], - "time": "2017-11-16 09:48:09" + "time": "2017-11-16T09:48:09+00:00" }, { "name": "sebastian/global-state", @@ -1403,7 +1363,7 @@ "keywords": [ "global state" ], - "time": "2017-11-16 09:49:42" + "time": "2017-11-16T09:49:42+00:00" }, { "name": "sebastian/object-enumerator", @@ -1450,7 +1410,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-11-16 09:50:04" + "time": "2017-11-16T09:50:04+00:00" }, { "name": "sebastian/object-reflector", @@ -1495,7 +1455,7 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2018-01-07 16:00:13" + "time": "2018-01-07T16:00:13+00:00" }, { "name": "sebastian/recursion-context", @@ -1548,7 +1508,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-11-16 10:04:08" + "time": "2017-11-16T10:04:08+00:00" }, { "name": "sebastian/resource-operations", @@ -1590,7 +1550,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2016-10-03 07:43:09" + "time": "2016-10-03T07:43:09+00:00" }, { "name": "sebastian/version", @@ -1681,12 +1641,12 @@ "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "23bf61bc8a7cc229d7ce8689b1bf818a9e192cac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/23bf61bc8a7cc229d7ce8689b1bf818a9e192cac", + "reference": "23bf61bc8a7cc229d7ce8689b1bf818a9e192cac", "shasum": "" }, "require": { @@ -1723,7 +1683,7 @@ "check", "validate" ], - "time": "2018-01-29 19:49:41" + "time": "2018-04-19T15:46:26+00:00" } ], "aliases": [], diff --git a/src/Transaction.php b/src/Transaction.php index bd1f613..cb94056 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -15,7 +15,8 @@ use RuntimeException; use kornrunner\Keccak; use Web3p\RLP\RLP; -use Web3p\Secp256k1\Secp256k1; +use Elliptic\EC; +use Elliptic\EC\KeyPair; use ArrayAccess; class Transaction implements ArrayAccess @@ -64,10 +65,17 @@ class Transaction implements ArrayAccess /** * secp256k1 * - * @var \Web3p\Secp256k1\Secp256k1 + * @var \Elliptic\EC */ protected $secp256k1; + /** + * privateKey + * + * @var \Elliptic\EC\KeyPair + */ + protected $privateKey; + /** * construct * @@ -84,7 +92,7 @@ public function __construct(array $txData=[]) } } $this->rlp = new RLP; - $this->secp256k1 = new Secp256k1; + $this->secp256k1 = new EC('secp256k1'); } /** @@ -210,11 +218,8 @@ public function getTxData() * @param string $value * @return string */ - public function sha3($value) + public function sha3(string $value) { - if (!is_string($value)) { - throw new InvalidArgumentException('The value to sha3 function must be string.'); - } $hash = Keccak::hash($value, 256); if ($hash === $this::SHA3_NULL_HASH) { @@ -226,19 +231,21 @@ public function sha3($value) /** * serialize * - * @return string + * @return \Web3p\RLP\RLP\Buffer */ public function serialize() { - $v = 37; $chainId = $this->offsetGet('chainId'); - if ($chainId) { - $v = (int) $chainId * 2 + 35; + // sort tx data + if (ksort($this->txData) !== true) { + throw new RuntimeException('Cannot sort tx data by keys.'); + } + if ($chainId && $chainId > 0) { + $txData = array_fill(0, 9, ''); + } else { + $txData = array_fill(0, 6, ''); } - $this->offsetSet('v', $v); - $txData = array_fill(0, 9, ''); - foreach ($this->txData as $key => $data) { if ($key >= 0) { $txData[$key] = $data; @@ -255,15 +262,23 @@ public function serialize() */ public function sign(string $privateKey) { - $txHash = $this->hash(); - $rlp = new RLP; - $secp256k1 = new Secp256k1; - $signature = $secp256k1->sign($txHash, $privateKey); - $r = $signature->getR(); - $s = $signature->getS(); + $txHash = $this->hash(false); + $privateKey = $this->secp256k1->keyFromPrivate($privateKey, 'hex'); + $signature = $privateKey->sign($txHash); + $r = $signature->r; + $s = $signature->s; + $v = $signature->recoveryParam + 35; - $this->offsetSet('r', '0x' . gmp_strval($r, 16)); - $this->offsetSet('s', '0x' . gmp_strval($s, 16)); + $chainId = $this->offsetGet('chainId'); + + if ($chainId && $chainId > 0) { + $v += (int) $chainId * 2; + } + + $this->offsetSet('r', '0x' . $r->toString(16)); + $this->offsetSet('s', '0x' . $s->toString(16)); + $this->offsetSet('v', $v); + $this->privateKey = $privateKey; return $this->serialize()->toString('hex'); } @@ -271,11 +286,80 @@ public function sign(string $privateKey) /** * hash * + * @param bool $includeSignature * @return string */ - public function hash() + public function hash($includeSignature=false) { - $serializedTx = $this->serialize()->toString('utf8'); + $chainId = $this->offsetGet('chainId'); + + // sort tx data + if (ksort($this->txData) !== true) { + throw new RuntimeException('Cannot sort tx data by keys.'); + } + if ($includeSignature) { + $txData = $this->txData; + } else { + if ($chainId && $chainId > 0) { + $v = (int) $chainId; + $this->offsetSet('r', ''); + $this->offsetSet('s', ''); + $this->offsetSet('v', $v); + $txData = array_fill(0, 9, ''); + } else { + $txData = array_fill(0, 6, ''); + } + + foreach ($this->txData as $key => $data) { + if ($key >= 0) { + $txData[$key] = $data; + } + } + } + $serializedTx = $this->rlp->encode($txData)->toString('utf8'); + return $this->sha3($serializedTx); } + + /** + * getFromAddress + * + * @return string + */ + public function getFromAddress() + { + $from = $this->offsetGet('from'); + + if ($from) { + return $from; + } + if (!isset($this->privateKey) || !($this->privateKey instanceof KeyPair)) { + // recover from hash + $r = $this->offsetGet('r'); + $s = $this->offsetGet('s'); + $v = $this->offsetGet('v'); + $chainId = $this->offsetGet('chainId'); + + if (!$r || !$s) { + throw new RuntimeException('Invalid signature r and s.'); + } + $txHash = $this->hash(false); + + if ($chainId && $chainId > 0) { + $v -= ($chainId * 2); + } + $v -= 35; + $publicKey = $this->secp256k1->recoverPubKey($txHash, [ + 'r' => $r, + 's' => $s + ], $v); + $publicKey = $publicKey->encode('hex'); + } else { + $publicKey = $this->privateKey->getPublic(false, 'hex'); + } + $from = '0x' . substr($this->sha3(substr(hex2bin($publicKey), 1)), 24); + + $this->offsetSet('from', $from); + return $from; + } } \ No newline at end of file diff --git a/test/unit/TransactionTest.php b/test/unit/TransactionTest.php index 72eee74..9ad21f6 100644 --- a/test/unit/TransactionTest.php +++ b/test/unit/TransactionTest.php @@ -100,11 +100,11 @@ public function testSet() } /** - * testSerialize + * testSha3 * * @return void */ - public function testSerialize() + public function testSha3() { $transaction = new Transaction([ 'nonce' => '0x01', @@ -113,11 +113,21 @@ public function testSerialize() 'gas' => '0x76c0', 'gasPrice' => '0x9184e72a000', 'value' => '0x9184e72a', + 'chainId' => 4, 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); - $this->assertEquals('f852018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675258080', $transaction->serialize()->toString('hex')); + $this->assertNull($transaction->sha3('')); + $this->assertEquals('47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad', $transaction->sha3('hello world')); + } + /** + * testHash + * + * @return void + */ + public function testHash() + { $transaction = new Transaction([ 'nonce' => '0x01', 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155', @@ -125,20 +135,11 @@ public function testSerialize() 'gas' => '0x76c0', 'gasPrice' => '0x9184e72a000', 'value' => '0x9184e72a', - 'chainId' => 4, 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); - $this->assertEquals('f852018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f0724456752b8080', $transaction->serialize()->toString('hex')); - } + $this->assertEquals('79617051b33e38636c12fb761abf62c20a9dd5a743ca5f338f04f2cf5f2ec6bd', $transaction->hash()); - /** - * testSha3 - * - * @return void - */ - public function testSha3() - { $transaction = new Transaction([ 'nonce' => '0x01', 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155', @@ -150,16 +151,15 @@ public function testSha3() 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); - $this->assertNull($transaction->sha3('')); - $this->assertEquals('47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad', $transaction->sha3('hello world')); + $this->assertEquals('8aace0c8df439c9cc9f313b116f1db03e0811ca07e582d351aad1c9d6542c23d', (string) $transaction); } /** - * testHash + * testSign * * @return void */ - public function testHash() + public function testSign() { $transaction = new Transaction([ 'nonce' => '0x01', @@ -170,9 +170,16 @@ public function testHash() 'value' => '0x9184e72a', 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); + $this->assertEquals('f892018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567523a0a48d3ce9c68bb49825aea5335bd07432823e858e8a504767d08290c28aafddf8a0416c7abc3a67080db0ad07c42de82db4e05518f99595119677398c68d431ab37', $transaction->sign($this->testPrivateKey)); + } - $this->assertEquals('710aee292b0f1749aaa0cfef67111e2f716afbdb475e7f250bdb80c6655b0a66', $transaction->hash()); - + /** + * testSerialize + * + * @return void + */ + public function testSerialize() + { $transaction = new Transaction([ 'nonce' => '0x01', 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155', @@ -180,29 +187,96 @@ public function testHash() 'gas' => '0x76c0', 'gasPrice' => '0x9184e72a000', 'value' => '0x9184e72a', - 'chainId' => 4, 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); - $this->assertEquals('dd4238507087c6d354079ea5a4c8da7abde43252f0accf79601d0fa1a10300d8', (string) $transaction); + $this->assertEquals('f84f018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', $transaction->serialize()->toString('hex')); + + // sign tx + $transaction->sign($this->testPrivateKey); + + $this->assertEquals('f892018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567523a0a48d3ce9c68bb49825aea5335bd07432823e858e8a504767d08290c28aafddf8a0416c7abc3a67080db0ad07c42de82db4e05518f99595119677398c68d431ab37', $transaction->serialize()->toString('hex')); } /** - * testSign + * testEIP155 + * you can find test case here: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md * * @return void */ - public function testSign() + public function testEIP155() { $transaction = new Transaction([ - 'nonce' => '0x01', - 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155', - 'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567', - 'gas' => '0x76c0', - 'gasPrice' => '0x9184e72a000', - 'value' => '0x9184e72a', - 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' + 'nonce' => '0x09', + 'to' => '0x3535353535353535353535353535353535353535', + 'gas' => '0x5208', + 'gasPrice' => '0x4a817c800', + 'value' => '0xde0b6b3a7640000', + 'chainId' => 1, + 'data' => '' ]); - $this->assertEquals('f892018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567525a08d8bfd01c48454b5b3fed2361cbd0e8c3282d5bd2e26762e4c9dfbe1ef35f325a06d6a5dc397934b5544835f34ff24263cbc00bdd516b6f0df3f29cdf6c779ccfb', $transaction->sign($this->testPrivateKey)); + $this->assertEquals('daf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53', $transaction->hash(false)); + $this->assertEquals('f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83', $transaction->sign('0x4646464646464646464646464646464646464646464646464646464646464646')); + } + + /** + * testGetFromAddress + * 0x9d8a62f656a8d1615c1294fd71e9cfb3e4855a4f + * + * @return void + */ + public function testGetFromAddress() + { + $transaction = new Transaction([ + 'nonce' => '0x09', + 'to' => '0x3535353535353535353535353535353535353535', + 'gas' => '0x5208', + 'gasPrice' => '0x4a817c800', + 'value' => '0xde0b6b3a7640000', + 'chainId' => 1, + 'data' => '' + ]); + // sign tx + $transaction->sign('0x4646464646464646464646464646464646464646464646464646464646464646'); + $r = $transaction['r']; + $s = $transaction['s']; + $v = $transaction['v']; + + // get from privatekey + $fromA = $transaction->getFromAddress(); + + $transaction = new Transaction([ + 'nonce' => '0x09', + 'to' => '0x3535353535353535353535353535353535353535', + 'gas' => '0x5208', + 'gasPrice' => '0x4a817c800', + 'value' => '0xde0b6b3a7640000', + 'chainId' => 1, + 'data' => '' + ]); + $transaction['r'] = $r; + $transaction['s'] = $s; + $transaction['v'] = $v; + + // get from r, s, v + $fromB = $transaction->getFromAddress(); + + $transaction = new Transaction([ + 'from' => '0x9d8a62f656a8d1615c1294fd71e9cfb3e4855a4f', + 'nonce' => '0x09', + 'to' => '0x3535353535353535353535353535353535353535', + 'gas' => '0x5208', + 'gasPrice' => '0x4a817c800', + 'value' => '0xde0b6b3a7640000', + 'chainId' => 1, + 'data' => '' + ]); + + // get from transaction + $fromC = $transaction->getFromAddress(); + + $this->assertEquals('0x9d8a62f656a8d1615c1294fd71e9cfb3e4855a4f', $fromA); + $this->assertEquals($fromA, $fromB); + $this->assertEquals($fromB, $fromC); } } \ No newline at end of file