diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index c472e4f..0000000 --- a/.cargo/config +++ /dev/null @@ -1,5 +0,0 @@ -[target.'cfg(target_os = "macos")'] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/.circleci/config.yml b/.circleci/config.yml index 18d0059..37747c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,8 +23,6 @@ commands: && sudo apt-get \ install \ build-essential \ - cargo \ - cmake \ autoconf \ libncurses5-dev - run: @@ -33,10 +31,6 @@ commands: curl -fsSL -o otp-src.tar.gz https://github.com/erlang/otp/archive/OTP-<< parameters.OTP_VERSION >>.tar.gz tar -zxf otp-src.tar.gz --strip-components=1 ./otp_build autoconf && ./configure && make -j$(nproc) && sudo make install - - run: - name: Install rest - command: | - curl https://sh.rustup.rs -sSf | sh -s -- -yq && source $HOME/.cargo/env setup_macos: description: "Setup macos environment" @@ -49,7 +43,7 @@ commands: name: Setup environment command: | brew update - brew install rust cmake erlang@<< parameters.OTP_VERSION >> + brew install erlang@<< parameters.OTP_VERSION >> brew link --force erlang@<< parameters.OTP_VERSION >> run_build: diff --git a/.gitignore b/.gitignore index 076b7c2..89fb6fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ -/target -**/*.rs.bk **/*~ -/parity-ethereum /_build /ebin /priv/ecrecover.dll /priv/ecrecover.so +/c_src/ecrecover.d +/c_src/ecrecover.o diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..99e57d5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "c_src/secp256k1"] + path = c_src/secp256k1 + url = https://github.com/bitcoin-core/secp256k1.git diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 02bb586..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,1996 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aes" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" -dependencies = [ - "aes-soft", - "aesni", - "block-cipher-trait", -] - -[[package]] -name = "aes-ctr" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" -dependencies = [ - "aes-soft", - "aesni", - "ctr", - "stream-cipher", -] - -[[package]] -name = "aes-soft" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" -dependencies = [ - "block-cipher-trait", - "byteorder", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -dependencies = [ - "block-cipher-trait", - "opaque-debug", - "stream-cipher", -] - -[[package]] -name = "ahash" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f00e10d4814aa20900e7948174384f79f1317f24f0ba7494e735111653fc330" -dependencies = [ - "const-random", -] - -[[package]] -name = "aho-corasick" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -dependencies = [ - "memchr", -] - -[[package]] -name = "arrayref" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "backtrace" -version = "0.3.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitvec" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9633b74910e1870f50f5af189b08487195cdb83c0e27a71d6f64d5e09dd0538b" - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array", -] - -[[package]] -name = "block-cipher-trait" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-modes" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31aa8410095e39fdb732909fb5730a48d5bd7c2e3cd76bd1b07b3dbea130c529" -dependencies = [ - "block-cipher-trait", - "block-padding", -] - -[[package]] -name = "block-padding" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "bn" -version = "0.4.4" -source = "git+https://github.com/paritytech/bn#6079255e65793038b9a6e5292203eab482737cc2" -dependencies = [ - "byteorder", - "crunchy 0.2.2", - "lazy_static", - "rand 0.5.6", - "rustc-hex 2.0.1", -] - -[[package]] -name = "byte-slice-cast" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cbcbf18128ec71d8d4a0d054461ec59fff5b75b7d10a4c9b7c7cb1a379c3e77" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -dependencies = [ - "ppv-lite86", -] - -[[package]] -name = "c_vec" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a318911dce53b5f1ca6539c44f5342c632269f0fa7ea3e35f32458c27a7c30" - -[[package]] -name = "cc" -version = "1.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "chrono" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cmake" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" -dependencies = [ - "cc", -] - -[[package]] -name = "common-types" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "derive_more", - "ethbloom", - "ethcore-io", - "ethereum-types", - "ethjson", - "keccak-hash", - "parity-bytes", - "parity-crypto", - "parity-snappy", - "parity-util-mem", - "patricia-trie-ethereum", - "rlp", - "rlp_derive", - "unexpected", - "vm", -] - -[[package]] -name = "const-random" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b641a8c9867e341f3295564203b1c250eb8ce6cb6126e007941f78c4d2ed7fe" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c750ec12b83377637110d5a57f5ae08e895b06c4b16e2bdbf1a94ef717428c59" -dependencies = [ - "proc-macro-hack", - "rand 0.7.2", -] - -[[package]] -name = "crossbeam-deque" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[package]] -name = "crunchy" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array", - "subtle 1.0.0", -] - -[[package]] -name = "ctr" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" -dependencies = [ - "block-cipher-trait", - "stream-cipher", -] - -[[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" -dependencies = [ - "lazy_static", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "rustc_version", - "syn 0.15.44", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "ecrecover" -version = "0.1.0" -dependencies = [ - "base64 0.10.1", - "c_vec", - "ethcore-builtin", - "lazy_static", - "libc", - "parity-bytes", - "rustler", -] - -[[package]] -name = "eip-152" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "arrayref", - "rustc-hex 2.0.1", -] - -[[package]] -name = "elastic-array" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" -dependencies = [ - "heapsize", -] - -[[package]] -name = "ethbloom" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6ee7065ba6a1597cff1e0598cfc3b0b41b5f65ccdf605560a296e7d94e93bf" -dependencies = [ - "crunchy 0.2.2", - "fixed-hash", - "impl-rlp", - "impl-serde", - "tiny-keccak", -] - -[[package]] -name = "ethcore-builtin" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "bn", - "byteorder", - "common-types", - "eip-152", - "ethereum-types", - "ethjson", - "keccak-hash", - "log", - "num", - "parity-bytes", - "parity-crypto", -] - -[[package]] -name = "ethcore-io" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "crossbeam-deque 0.6.3", - "fnv", - "futures", - "log", - "num_cpus", - "parking_lot", - "slab", - "time", - "timer", - "tokio", -] - -[[package]] -name = "ethereum-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba744248e3553a393143d5ebb68939fc3a4ec0c22a269682535f5ffe7fed728c" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint", -] - -[[package]] -name = "ethjson" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "ethereum-types", - "rustc-hex 1.0.0", - "serde", - "serde_json", -] - -[[package]] -name = "failure" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -dependencies = [ - "backtrace", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fixed-hash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6357b15872f8126e4ea7cf79d579473f132ccd2de239494ad1bf4aa892faea68" -dependencies = [ - "byteorder", - "libc", - "rand 0.7.2", - "rustc-hex 2.0.1", - "static_assertions", -] - -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "getrandom" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hashbrown" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6587d09be37fb98a11cb08b9000a3f592451c1b1b613ca69d949160e313a430a" -dependencies = [ - "ahash", - "autocfg", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi 0.3.8", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "impl-codec" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa0086251524c50fd53b32e7b05eb6d79e2f97221eaf0c53c0ca9c3096f21d3" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f39b9963cf5f12fcc4ae4b30a6927ed67d6b4ea4cbe7d17a41131163b401303b" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a263dc95daa6c3788c8f7133d86dc2ad89ec5a0c56167f9e3441c5f7f33358c4" -dependencies = [ - "serde", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" - -[[package]] -name = "keccak-hash" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e563fa6fe52b2686094846118bf2cb2e6f75e6b8cec6c3aba09be8e835c7f998" -dependencies = [ - "primitive-types", - "tiny-keccak", -] - -[[package]] -name = "keccak-hasher" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "ethereum-types", - "hash-db", - "plain_hasher", - "tiny-keccak", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" - -[[package]] -name = "lock_api" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "malloc_size_of_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" -dependencies = [ - "proc-macro2 1.0.6", - "syn 1.0.5", - "synstructure 0.12.1", -] - -[[package]] -name = "memchr" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" - -[[package]] -name = "memoffset" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "mio" -version = "0.6.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -dependencies = [ - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio-uds" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" -dependencies = [ - "iovec", - "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.8", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "num" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" -dependencies = [ - "num-bigint", - "num-integer", - "num-iter", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1" -dependencies = [ - "num-integer", - "num-traits", - "rand 0.4.6", - "rustc-serialize", -] - -[[package]] -name = "num-integer" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bd5272412d173d6bf9afdf98db8612bbabc9a7a830b7bfc9c188911716132e" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" -dependencies = [ - "libc", -] - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "parity-bytes" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa5168b4cf41f3835e4bc6ffb32f51bc9365dc50cb351904595b3931d917fd0c" - -[[package]] -name = "parity-crypto" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27a9c2b525c93d717a234eb220c26474f8d97b08ac50d79faeac4cb6c74bf0b9" -dependencies = [ - "aes", - "aes-ctr", - "block-modes", - "digest", - "ethereum-types", - "hmac", - "lazy_static", - "parity-secp256k1", - "pbkdf2", - "rand 0.7.2", - "ripemd160", - "rustc-hex 2.0.1", - "scrypt", - "sha2", - "subtle 2.2.1", - "tiny-keccak", - "zeroize", -] - -[[package]] -name = "parity-scale-codec" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001fbbb956d8593f321c7a784f64d16b2c99b2657823976eea729006ad2c3668" -dependencies = [ - "arrayvec 0.4.12", - "bitvec", - "byte-slice-cast", - "serde", -] - -[[package]] -name = "parity-secp256k1" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" -dependencies = [ - "arrayvec 0.5.1", - "cc", - "cfg-if", - "rand 0.7.2", -] - -[[package]] -name = "parity-snappy" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63" -dependencies = [ - "libc", - "parity-snappy-sys", -] - -[[package]] -name = "parity-snappy-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a413d51e5e1927320c9de992998e4a279dffb8c8a7363570198bd8383e66f1b" -dependencies = [ - "cmake", - "libc", -] - -[[package]] -name = "parity-util-mem" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc" -dependencies = [ - "cfg-if", - "elastic-array", - "ethereum-types", - "malloc_size_of_derive", - "parking_lot", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi 0.3.8", -] - -[[package]] -name = "patricia-trie-ethereum" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "elastic-array", - "ethereum-types", - "hash-db", - "keccak-hasher", - "parity-bytes", - "rlp", - "trie-db", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "base64 0.9.3", - "byteorder", - "crypto-mac", - "hmac", - "rand 0.5.6", - "sha2", - "subtle 1.0.0", -] - -[[package]] -name = "plain_hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fa6386b1d34aaf0adb9b7dd2885dbe7c34190e6263785e5a7ec2b19044a90f" -dependencies = [ - "crunchy 0.1.6", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "primitive-types" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b5a08dda18910f056e5c2060c034e77cab18e0bd7d895e44f03207af4c71d5" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "uint", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -dependencies = [ - "proc-macro2 1.0.6", - "quote 1.0.2", - "syn 1.0.5", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -dependencies = [ - "proc-macro2 1.0.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.8", -] - -[[package]] -name = "rand" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" -dependencies = [ - "getrandom", - "libc", - "rand_chacha 0.2.1", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -dependencies = [ - "c2-chacha", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.8", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "regex" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" - -[[package]] -name = "ripemd160" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" -dependencies = [ - "block-buffer", - "digest", - "opaque-debug", -] - -[[package]] -name = "rlp" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2f7f9c612d133da9101ef7bcd3e603ca7098901eca852e71f87a83dd3e6b59" -dependencies = [ - "rustc-hex 2.0.1", -] - -[[package]] -name = "rlp_derive" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hex" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" - -[[package]] -name = "rustc-hex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "rustler" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533dc3379a0f166749ce262a941e9b52ce19c3208729fc6b6cce76aea76d939b" -dependencies = [ - "lazy_static", - "rustler_codegen", - "rustler_sys", - "which", -] - -[[package]] -name = "rustler_codegen" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21563a1c4b02773f5c6dce723630c9998694258ff4d67bd6025ba057a29b51c" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "rustler_sys" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cb382fde4f421c51555919e9920b058c0286f6bf59e53d02eb4d281eae6758b" -dependencies = [ - "unreachable", -] - -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" - -[[package]] -name = "scrypt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656c79d0e90d0ab28ac86bf3c3d10bfbbac91450d3f190113b4e76d9fec3cfdd" -dependencies = [ - "byte-tools", - "byteorder", - "hmac", - "pbkdf2", - "sha2", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" -dependencies = [ - "proc-macro2 1.0.6", - "quote 1.0.2", - "syn 1.0.5", -] - -[[package]] -name = "serde_json" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" -dependencies = [ - "block-buffer", - "digest", - "fake-simd", - "opaque-debug", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" - -[[package]] -name = "static_assertions" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" - -[[package]] -name = "stream-cipher" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" -dependencies = [ - "generic-array", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3af2eb31c42e8f0ccf43548232556c42737e01a96db6e1777b0be108e79799" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" -dependencies = [ - "proc-macro2 1.0.6", - "quote 1.0.2", - "unicode-xid 0.2.0", -] - -[[package]] -name = "synstructure" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", - "unicode-xid 0.1.0", -] - -[[package]] -name = "synstructure" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" -dependencies = [ - "proc-macro2 1.0.6", - "quote 1.0.2", - "syn 1.0.5", - "unicode-xid 0.2.0", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -dependencies = [ - "libc", - "redox_syscall", - "winapi 0.3.8", -] - -[[package]] -name = "timer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d42176308937165701f50638db1c31586f183f1aab416268216577aec7306b" -dependencies = [ - "chrono", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy 0.2.2", -] - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes", - "futures", - "mio", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio-codec" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -dependencies = [ - "bytes", - "futures", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" -dependencies = [ - "futures", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" -dependencies = [ - "crossbeam-utils", - "futures", -] - -[[package]] -name = "tokio-fs" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" -dependencies = [ - "futures", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" -dependencies = [ - "bytes", - "futures", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c56391be9805bc80163151c0b9e5164ee64f4b0200962c346fea12773158f22d" -dependencies = [ - "crossbeam-utils", - "futures", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" -dependencies = [ - "fnv", - "futures", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -dependencies = [ - "bytes", - "futures", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2c6a3885302581f4401c82af70d792bb9df1700e7437b0aeb4ada94d5388c" -dependencies = [ - "crossbeam-deque 0.7.1", - "crossbeam-queue", - "crossbeam-utils", - "futures", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" -dependencies = [ - "crossbeam-utils", - "futures", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-udp" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" -dependencies = [ - "bytes", - "futures", - "log", - "mio", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-uds" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" -dependencies = [ - "bytes", - "futures", - "iovec", - "libc", - "log", - "mio", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "trie-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" -dependencies = [ - "elastic-array", - "hash-db", - "hashbrown", - "log", - "rand 0.6.5", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" - -[[package]] -name = "uint" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f0f47ed099f0db671ce82c66548c5de012e3c0cba3963514d1db15c7588701" -dependencies = [ - "byteorder", - "crunchy 0.2.2", - "rustc-hex 2.0.1", -] - -[[package]] -name = "unexpected" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" - -[[package]] -name = "unicode-segmentation" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - -[[package]] -name = "vm" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum.git?rev=acf7c48#acf7c48d7e0fcd67a6a409e47827febcd330ac69" -dependencies = [ - "ethereum-types", - "ethjson", - "keccak-hash", - "parity-bytes", - "patricia-trie-ethereum", - "rlp", -] - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" - -[[package]] -name = "which" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" -dependencies = [ - "failure", - "libc", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "zeroize" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", - "synstructure 0.10.2", -] diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 16f6dbe..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "ecrecover" -version = "0.1.0" -authors = ["John Newby "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -base64 = "0.10.1" -c_vec = "1.3.3" -ethcore-builtin = { git = "https://github.com/paritytech/parity-ethereum.git", rev = "acf7c48" } -lazy_static = "1.3.0" -libc = "0.2.60" -parity-bytes = "0.1.0" -rustler = "0.21.0" - -[lib] -crate-type = ["cdylib"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 7704403..0000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -UNAME := $(shell uname) - -ifeq ($(OS),Windows_NT) - nif_lib_src = ecrecover.dll - nif_lib = ecrecover.dll -else -ifeq ($(UNAME), Linux) - nif_lib_src = libecrecover.so - nif_lib = ecrecover.so -endif -ifeq ($(UNAME), Darwin) - nif_lib_src = libecrecover.dylib - nif_lib = ecrecover.so -endif -endif - -all: priv/$(nif_lib) compile - -compile: - ./rebar3 compile - -priv/$(nif_lib): src/lib.rs -ifneq ($(ECRECOVER_DISABLE_NIF_BUILD), true) - cargo build --release - cp target/release/$(nif_lib_src) $@ -endif - -clean: - rm -f priv/$(nif_lib) target/release/$(nif_lib_src) - ./rebar3 clean diff --git a/Makefile.win32 b/Makefile.win32 new file mode 100644 index 0000000..f974246 --- /dev/null +++ b/Makefile.win32 @@ -0,0 +1,25 @@ +secp256k1_dir := c_src/secp256k1 +secp256k1_lib_dir := c_src/secp256k1/.libs + +CFLAGS := -MT -DNOMINMAX -Ox -DNDEBUG -openmp -W4 -Zi -EHsc -nologo -I$(secp256k1_dir)/include +LDFLAGS := -LIBPATH:$(secp256k1_lib_dir) -nologo + +.PHONY: win32_ecrecover +win32_ecrecover: $(secp256k1_lib_dir)/libsecp256k1.lib + +$(secp256k1_lib_dir)/libsecp256k1.lib: $(secp256k1_lib_dir)/secp256k1.lib + lib ${LDFLAGS} -OUT:$@ -nodefaultlib $^ + +$(secp256k1_lib_dir)/secp256k1.lib: $(secp256k1_obj_dir)/fp.obj + lib ${LDFLAGS} -OUT:$@ -nodefaultlib $< + +$(secp256k1_obj_dir)/fp.obj: $(secp256k1_src_dir)/fp.cpp + cl -c ${CFLAGS} $< -Fo$@ + +$(secp256k1_obj_dir)/bn_c384_256.obj: $(secp256k1_src_dir)/bn_c384_256.cpp + cl -c ${CFLAGS} $< -Fo$@ + +clean_win32_secp256k1: + make -C $(secp256k1_dir) clean + rm -f $(secp256k1_lib_dir)/*.lib $(secp256k1_lib_dir)/*.dll $(secp256k1_lib_dir)/*.exp + diff --git a/c_src/ecrecover.c b/c_src/ecrecover.c new file mode 100644 index 0000000..cc1a72a --- /dev/null +++ b/c_src/ecrecover.c @@ -0,0 +1,102 @@ +#include "erl_nif.h" +#include "secp256k1_recovery.h" + + +static secp256k1_context *ctx = NULL; + +static ERL_NIF_TERM error_result(ErlNifEnv* env, char* error_msg) +{ + return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_string(env, error_msg, ERL_NIF_LATIN1)); +} + +static ERL_NIF_TERM ok_result(ErlNifEnv* env, ERL_NIF_TERM *r) +{ + return enif_make_tuple2(env, enif_make_atom(env, "ok"), *r); +} + +static ERL_NIF_TERM +recover(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + ERL_NIF_TERM r; + ErlNifBinary message, csignature; + int result; + int compressed = SECP256K1_EC_UNCOMPRESSED; + size_t pubkeylen = 65; + int recid; + unsigned char* finished_recpubkey_buf; + secp256k1_ecdsa_recoverable_signature signature; + secp256k1_pubkey recpubkey; + + if (!enif_inspect_binary(env, argv[0], &message)) { + return enif_make_badarg(env); + } + + if (!enif_inspect_binary(env, argv[1], &csignature)) { + return enif_make_badarg(env); + } + + if (!enif_get_int(env, argv[2], &recid)) { + return error_result(env, "Recovery id invalid 0-3"); + } + + if (recid < 0 || recid > 3) { + error_result(env, "Recovery id invalid 0-3x"); + } +printf("xx1\r\n"); + result = secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &signature, csignature.data, recid); +printf("xx2\r\n"); + if (!result) { + return error_result(env, "ecdsa_signature_parse_compact returned 0"); + } + + // Now do ECDSA recovery + result = secp256k1_ecdsa_recover(ctx, &recpubkey, &signature, message.data); + + if (!result) { + return error_result(env, "ecdsa recovery problem"); + } + + // Now serialize recpubkey based on the compression flag + finished_recpubkey_buf = enif_make_new_binary(env, pubkeylen, &r); + + printf("pubker[0] = %d\r\n", recpubkey.data[0]); + + + result = secp256k1_ec_pubkey_serialize(ctx, finished_recpubkey_buf, + &pubkeylen, &recpubkey, compressed); + + if (!result) { + return error_result(env, "ecdsa pubkey serialize error"); + } + + return ok_result(env, &r); + +} + + +static int +load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) +{ + ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + return 0; +} + +static int +upgrade(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM load_info) +{ + return 0; +} + +static void +unload(ErlNifEnv* env, void* priv) +{ + secp256k1_context_destroy(ctx); + return; +} + +static ErlNifFunc nif_funcs[] = + { + {"recover", 3, recover} + }; + +ERL_NIF_INIT(ecrecover, nif_funcs, &load, NULL, NULL, &unload); \ No newline at end of file diff --git a/c_src/secp256k1 b/c_src/secp256k1 new file mode 160000 index 0000000..cbe41ac --- /dev/null +++ b/c_src/secp256k1 @@ -0,0 +1 @@ +Subproject commit cbe41ac138bc0773d60ab1942b7ad6fc5eccfc19 diff --git a/data/erl_ecrecover.input-fail.bin b/data/erl_ecrecover.input-fail.bin deleted file mode 100644 index dba9420..0000000 --- a/data/erl_ecrecover.input-fail.bin +++ /dev/null @@ -1 +0,0 @@ -4717328000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18000000000000000000000000f941ba12e03 \ No newline at end of file diff --git a/data/erl_ecrecover.input.bin b/data/erl_ecrecover.input.bin deleted file mode 100644 index fb70f83..0000000 --- a/data/erl_ecrecover.input.bin +++ /dev/null @@ -1 +0,0 @@ -47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03 \ No newline at end of file diff --git a/include/base64.h b/include/base64.h deleted file mode 100644 index 3dad595..0000000 --- a/include/base64.h +++ /dev/null @@ -1,7 +0,0 @@ -#if !defined __AE__BASE64_H -#define __AE__BASE64_H - -char *bin2hex(unsigned char*, int); -unsigned char *hex2bin(const char*); - -#endif diff --git a/include/ecrecover.h b/include/ecrecover.h deleted file mode 100644 index bfd57b6..0000000 --- a/include/ecrecover.h +++ /dev/null @@ -1,6 +0,0 @@ -#if !defined __AE_ECRECOVER_H -#define __AE_ECRECOVER_H - -int ecrecover(const unsigned char *input, unsigned char *output); - -#endif diff --git a/include/ecrecover.hpp b/include/ecrecover.hpp deleted file mode 100644 index 4732795..0000000 --- a/include/ecrecover.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include -#include - -extern "C" { - -void ecrecover(const unsigned char *input, unsigned char *output); - -} // extern "C" diff --git a/include/erl_comm.h b/include/erl_comm.h deleted file mode 100644 index d756d69..0000000 --- a/include/erl_comm.h +++ /dev/null @@ -1,20 +0,0 @@ -#if !defined __AE__ERL_COMM_H -#define __AE__ERL_COMM_H - -#ifdef DEBUG -#include -#define DEBUG_PRINTF printf -#else -#define DEBUG_PRINTF -#endif - -typedef unsigned char byte; - -#define ECRECOVER_BUFFER_MAX 1024 - -int read_cmd(byte *buf); -int write_cmd(byte *buf, int len); -int read_exact(byte *buf, int len); -int write_exact(byte *buf, int len); - -#endif diff --git a/rebar.config b/rebar.config index 761725c..614e851 100644 --- a/rebar.config +++ b/rebar.config @@ -1,17 +1,39 @@ -{deps, [ - %% ecrecover prebuilt libraries - {ecrecoverprebuilt, - {ecrecoverprebuilt_app_with_priv_from_git, - {git, "https://github.com/aeternity/ecrecover-prebuilt.git", - {ref, "4027374"}}}} - ]}. +{deps, + [{sha3, {git, "https://github.com/aeternity/erlang-sha3", {ref, "b5f27a2"}}}]}. -{plugins, [{rebar_ecrecoverprebuilt_dep, - {git, "https://github.com/aeternity/rebar3-ecrecover-prebuilt-plugin.git", - {ref, "7286efd"}}} - ]}. +{pre_hooks, [ {compile, "git submodule update --init"} + , {"(linux|darwin)", compile, "sh -c \"cd c_src/secp256k1 && ./autogen.sh && ./configure --enable-module-recovery && make\""} + , {"win32", compile, "make -f Makefile.win32 win32_ecrecover"} + ]}. +{post_hooks, [ {"(linux|darwin)", clean, "make -C \"c_src/secp256k1\" clean"} + , {"win32", clean, "make -f Makefile.win32 clean_win32_ecrecover"} + ]}. + + +{plugins, [pc]}. + +{provider_hooks, [ + {post, [ {compile, {pc, compile}} + , {clean, {pc, clean}} + ]} + ]}. + +{port_specs, [{"priv/ecrecover.so", ["c_src/*.c"]}]}. + +{port_env, [ {"darwin", "CFLAGS", "$CFLAGS -fPIC -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -I c_src/secp256k1/include"} + , {"darwin", "CXXFLAGS", "$CXXFLAGS -fPIC -O3 -finline-functions -Wall"} + , {"darwin", "LDFLAGS", "$LDFLAGS c_src/secp256k1/.libs/libsecp256k1.a"} + + , {"linux", "CFLAGS", "$CFLAGS -fPIC -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes -I c_src/secp256k1/include"} + , {"linux", "CXXFLAGS", "$CXXFLAGS -fPIC -O3 -finline-functions -Wall"} + , {"linux", "LDFLAGS", "$LDFLAGS c_src/secp256k1/.libs/libsecp256k1.a -lstdc++"} + + , {"win32", "CFLAGS", "$CFLAGS /LD /MD /Fe /Ox /DNDEBUG /DMCLBN_DONT_EXPORT /Ic_src/secp256k1/include"} + , {"win32", "LDFLAGS", "$LDFLAGS /LIBPATH:c_src/cybozulib_ext/lib c_src/secp256k1/.libs/secp256k1.lib"} +]}. + {dialyzer, [{warnings, [unknown]}, {plt_apps, all_deps}, - {base_plt_apps, [erts, kernel, stdlib, crypto]} + {base_plt_apps, [erts, kernel, stdlib]} ]}. diff --git a/rebar.lock b/rebar.lock index e09aa28..57afcca 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,5 +1 @@ -[{<<"ecrecoverprebuilt">>, - {ecrecoverprebuilt_app_with_priv_from_git, - {git,"https://github.com/aeternity/ecrecover-prebuilt.git", - {ref,"402737411420fc4c500e1f42c921ef185a35cc56"}}}, - 0}]. +[]. diff --git a/rebar3 b/rebar3 index ea5a116..13db1ce 100755 Binary files a/rebar3 and b/rebar3 differ diff --git a/src/ecrecover.app.src b/src/ecrecover.app.src index d96fa46..9c7a456 100644 --- a/src/ecrecover.app.src +++ b/src/ecrecover.app.src @@ -4,8 +4,7 @@ {registered, []}, {applications, [kernel, - stdlib, - ecrecoverprebuilt + stdlib ]}, {env,[]}, {modules, []}, diff --git a/src/ecrecover.erl b/src/ecrecover.erl index f968f91..ee04c55 100644 --- a/src/ecrecover.erl +++ b/src/ecrecover.erl @@ -1,7 +1,9 @@ -module(ecrecover). +%% https://github.com/mbrix/libsecp256k1 + %% API --export([recover/2]). +-export([recover/2, recover/3]). %% NIF -export([load/0]). @@ -9,16 +11,17 @@ %%============================================================================= %% NIF API +%% GoodMsg1 = <<71,23,50,133,168,215,52,30,94,151,47,198,119,40,99,132,248,2,248,239,66,165,236,95,3,187,250,37,76,176,31,173>>. +%% GoodSig1_v = <<27,101,10,207,157,63,95,10,44,121,151,118,161,37,67,85,213,244,6,23,98,162,55,57,106,153,160,224,227,252,43,205,103,41,81,74,13,172,178,230,35,172,74,189,21,124,177,129,99,255,148,34,128,219,77,92,170,214,109,223,148,27,161,46,3>>. +%% ecrecover:recover(<<71,23,50,133,168,215,52,30,94,151,47,198,119,40,99,132,248,2,248,239,66,165,236,95,3,187,250,37,76,176,31,173>>, <<27,101,10,207,157,63,95,10,44,121,151,118,161,37,67,85,213,244,6,23,98,162,55,57,106,153,160,224,227,252,43,205,103,41,81,74,13,172,178,230,35,172,74,189,21,124,177,129,99,255,148,34,128,219,77,92,170,214,109,223,148,27,161,46,3>>). +%% load() -> - % Prefer locally built NIF (good for testing and exotic platforms) over - % prebuilt binaries. - case load_local_nif() of - ok -> - ok; - {error, _} -> - load_prebuilt_nif() - end. + EbinDir = filename:dirname(code:which(?MODULE)), + AppDir = filename:dirname(EbinDir), + PrivDir = filename:join(AppDir, "priv"), + SoName = filename:join(PrivDir, atom_to_list(?MODULE)), + erlang:load_nif(SoName, 0). not_loaded(Line) -> erlang:nif_error({error, {not_loaded, [{module, ?MODULE}, {line, Line}]}}). @@ -26,36 +29,22 @@ not_loaded(Line) -> %%============================================================================= %% External API --spec recover(<<_:(32*8)>>, <<_:(65*8)>>) -> <<_:(32*8)>>. -recover(<<_:32/binary>> = Hash, <<_:65/binary>> = Sig) -> - Input = <>, - case recover_(Input) of - {ok, []} -> - <<0:256>>; - {ok, Res} -> - erlang:list_to_binary(Res); - _Err -> +recover(Hash, <>) when V == 27; V == 28 -> + RecId = V - 27, + case recover(Hash, Sig, RecId) of + {ok, <<4, XY:64/binary>>} -> + <<_:12/bytes, ShortPub:20/bytes>> = keccak256(XY), + <<0:96, ShortPub/binary>>; + {error, _} -> <<0:256>> - end. + end. + +-spec recover(<<_:(32*8)>>, <<_:(65*8)>>, integer()) -> <<_:(32*8)>>. +recover(_Hash, _Sig, _RecId) -> + not_loaded(?LINE). %%============================================================================= %% Internal Functions -load_local_nif() -> - EbinDir = filename:dirname(code:which(?MODULE)), - AppDir = filename:dirname(EbinDir), - PrivDir = filename:join(AppDir, "priv"), - SoName = filename:join(PrivDir, atom_to_list(?MODULE)), - erlang:load_nif(SoName, 0). - -load_prebuilt_nif() -> - case code:priv_dir(ecrecoverprebuilt) of - {error, _} -> - {error, prebuilt_priv_dir_not_found}; - PrivDir -> - SoName = filename:join(PrivDir, atom_to_list(?MODULE)), - erlang:load_nif(SoName, 0) - end. - -recover_(_Input) -> - not_loaded(?LINE). +keccak256(Bin) -> + sha3:hash(256, Bin). diff --git a/src/ecrecover_util.erl b/src/ecrecover_util.erl deleted file mode 100644 index 6d154b7..0000000 --- a/src/ecrecover_util.erl +++ /dev/null @@ -1,28 +0,0 @@ --module(ecrecover_util). - --export([ recover_from_hex/1 - , bin_to_hex/1 - , hex_to_bin/1 - ]). - -%%============================================================================= -%% External API - -recover_from_hex(Input) -> - <> = hex_to_bin(Input), - PubKey = ecrecover:recover(Hash, Sig), - bin_to_hex(PubKey). - -bin_to_hex(Bin) -> - lists:flatten([io_lib:format("~2.16.0B", [X]) || X <- binary_to_list(Bin)]). - -hex_to_bin(S) -> - hex_to_bin(S, []). -hex_to_bin([], Acc) -> - list_to_binary(lists:reverse(Acc)); -hex_to_bin([X,Y|T], Acc) -> - {ok, [V], []} = io_lib:fread("~16u", [X,Y]), - hex_to_bin(T, [V | Acc]); -hex_to_bin([X|T], Acc) -> - {ok, [V], []} = io_lib:fread("~16u", lists:flatten([X,"0"])), - hex_to_bin(T, [V | Acc]). diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 93d60a5..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,42 +0,0 @@ -extern crate c_vec; -extern crate ethcore_builtin; -#[macro_use] -extern crate lazy_static; -extern crate libc; -extern crate parity_bytes; -#[macro_use] -extern crate rustler; - -use crate::ethcore_builtin::Implementation; -use ethcore_builtin::EcRecover; -use parity_bytes::BytesRef; -use rustler::*; - -mod atoms { - rustler_atoms! { - atom ok; - } -} - -rustler_export_nifs!( - "ecrecover", - [("recover_", 1, nif_ecrecover),], - Some(on_load) -); - -#[no_mangle] -fn on_load(_env: Env, _load_info: Term) -> bool { - true -} - -pub fn nif_ecrecover<'a>(env: Env<'a>, args: &[Term<'a>]) -> Result, Error> { - let input: Binary = args[0].decode()?; - let mut byte_ref = Vec::new(); - let ecrecover = EcRecover {}; - let _result = match ecrecover.execute(input.as_slice(), &mut BytesRef::Flexible(&mut byte_ref)) - { - Ok(_) => (), - Err(_e) => return Err(rustler::Error::Atom("ecrecover_failed")), - }; - Ok((atoms::ok(), byte_ref.as_slice()).encode(env)) -} diff --git a/test/ecrecover_tests.erl b/test/ecrecover_tests.erl new file mode 100644 index 0000000..4b5d67d --- /dev/null +++ b/test/ecrecover_tests.erl @@ -0,0 +1,22 @@ +%%%============================================================================= +%%% @copyright (C) 2023, Aeternity Foundation +%%% @doc +%%% Unit tests for ecrecover +%%% @end +%%%============================================================================= +-module(ecrecover_tests). + +-include_lib("eunit/include/eunit.hrl"). + +%% MSG and SIG from aecontract_SUITE, in turn taken from +%% https://github.com/aeternity/parity-ethereum/blob/master/ethcore/builtin/src/lib.rs#L656 +%% GoodHexSig1 = "47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03", +%% <> = aeu_hex:hex_to_bin(GoodHexSig1) +-define(MSG, <<71,23,50,133,168,215,52,30,94,151,47,198,119,40,99,132,248,2,248,239,66,165,236,95,3,187,250,37,76,176,31,173>>). +-define(SIG, <<27,101,10,207,157,63,95,10,44,121,151,118,161,37,67,85,213,244,6,23,98,162,55,57,106,153,160,224,227,252,43,205,103,41,81,74,13,172,178,230,35,172,74,189,21,124,177,129,99,255,148,34,128,219,77,92,170,214,109,223,148,27,161,46,3>>). +-define(EXPECTED_PUBKEY, <<0,0,0,0,0,0,0,0,0,0,0,0,192,139,85,66,209,119,172,102,134,148,105,32,64,151,65,70,58,21,221,219>>). + + +recover_test() -> + PubKey = ecrecover:recover(?MSG, ?SIG), + ?assertEqual(?EXPECTED_PUBKEY, PubKey). \ No newline at end of file