Git Product home page Git Product logo

filecoin-signing-tools's Introduction

Filecoin Signing Tools

License GithubActions npm version


zondax_light zondax_dark

Please visit our website at zondax.ch



๐Ÿšซ PROJECT MAINTENANCE NOTICE ๐Ÿšซ

This package will continue to be actively maintained until 2023-12-31. After this date, it will no longer receive updates or bug fixes. Users are encouraged to seek alternative solutions after this period and are welcome to fork the project for continued development.


โš ๏ธ Relevant Note โš ๏ธ

We are excited to announce that we have created a new package called izari-filecoin ๐Ÿ”—, which will be the successor to filecoin-signing-tools. Izari Filecoin is an advanced and user-friendly package that includes several new features and improvements that were not available in this project. The new package is also better organized and easier to use. While this project will continue to be maintained, no new features will be added to it. Therefore, we strongly recommend that you switch to Izari Filecoin to take advantage of its new features and benefits.


You can find more information in the Documentation Site

  • Rust Native Library

    • Secp256k1
    • Multisig (Work in progress)
    • BLS
    • Filecoin transactions (CBOR <> JSON serialization)
  • WASM Library

    • Secp256k1
    • Multisig (Work in progress)
    • BLS
    • Filecoin transactions (CBOR <> JSON serialization)
  • Examples

Caller Callee Status
Browser WASM Ready โœ”๏ธ Link
Node.js / Mocha WASM Ready โœ”๏ธ Link
C Rust Ready โœ”๏ธ Link
C++ Rust Ready โœ”๏ธ Link
Java Rust Ready โœ”๏ธ Link
Kotlin Rust Ready โœ”๏ธ Link
Go Rust Ready โœ”๏ธ Link
Objective-C Rust Ready โœ”๏ธ Link
Swift Rust Ready โœ”๏ธ Link
Flutter Rust Ready โœ”๏ธ Link
React Native Rust Planned โณ Soon

Running tests and examples

TIP: A good place to look for reproducible steps is the circleci configuration of this project

Installing dependencies

You will need rust installed.

# Install wasm-pack in your system
$ make install_wasmpack
# Install some utilitary tools
$ make install_deps_rust

Note: wasm parck are required if you want to use the wasm version of the lib.

Rust

cargo test -p filecoin-signer

WASM

Build WASM and link it locally so examples are linked to the local version:

make build_npm

After this, you can run the following tests / examples:

Command Description
make test_npm_unit Unit tests
make test_npm_node Node integration tests
make test_npm_browser Browser integration tests

filecoin-signing-tools's People

Contributors

ameanasad avatar anonyma avatar c410-f3r avatar dependabot[bot] avatar ec2 avatar emmanuelm41 avatar gfpacheco avatar jleni avatar karrq avatar lawrathod avatar meandavejustice avatar mrsmkl avatar neithanmo avatar rllola avatar unded avatar vinayakkalra avatar woshidama323 avatar

Stargazers

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

Watchers

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

filecoin-signing-tools's Issues

Add React Native Example

  • Use key_derive for the example.
  • Add a small section in the documentation
  • Adjust circleCI configuration to confirm
    This very likely depends on the Obj-C and Java examples

๐Ÿ”— zboto Link

Specify error type in manual_testvectors file

In order to improve testing we should add error type for invalid transaction.

Example :

    {
        "description": "Address protocol 2 Invalid payload length of 21 bytes",
        "encoded_tx": "iFYCAAAAAAAAAAAAAAAAAAAAAAAAAAAAVgIAAAAAAAAAAAAAAAAAAAAAAAAAAAABRAABhqBDAAnEQwBhqABA",
        "valid": false,
        "testnet": false,
        "message": {
            "to": "f2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3sien4",
            "from": "f2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3sien4",
            "nonce": 1,
            "value": "100000",
            "gas_price": "2500",
            "gas_limit": "25000",
            "method": 0
        },
        "encoded_tx_hex": "88560200000000000000000000000000000000000000000056020000000000000000000000000000000000000000000144000186a0430009c4430061a80040",
   "error": "Invalid payload"
    }

Error should probably be a regexp.

๐Ÿ”— zboto Link

Document JSONRPC API

This should be aligned with Examples in #10

  • adjust to new API
  • setup vuepress
  • document WASM API
  • add comments to rust code (#81)

Add support for send_sign

send_sign(transaction, private_key) -> txhash

It should raise an error if transaction is testnet but node is Mainnet and vice versa.

Fail to parse transaction

Fail to parse this transaction :

885501fd1d0f4dfcd7e99afcb99a8326b7dc459d32c62855015d77a86f78f72f2f71edc37ce67cb344417ea1520242000140400040'

By accident I have passed an extra caracter "`" and it panicked instead of sending an error.

log

The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value: InvalidLength
Location: src/libcore/result.rs:1165

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Fail empty value

The following testcase is failing when parsing :

    {
        "description": "Empty value",
        "encoded_tx": "iFUB0VAFBOTRrD6JrIkaRQJYb6vZtBdVAbiCYZ1GVY89njFtEbSNzyETJwJqAUEAQwAJxEMAYagAQA==",
        "valid": false,
        "testnet": false,
        "not_implemented": true,
        "message": {
            "to": "f12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a",
            "from": "f1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy",
            "nonce": 1,
            "value": "",
            "gas_price": "2500",
            "gas_limit": "25000",
            "method": 0
        },
        "encoded_tx_hex": "885501d1500504e4d1ac3e89ac891a4502586fabd9b4175501b882619d46558f3d9e316d11b48dcf211327026a01430009c4430061a80040"
    }

However the value seems to be optional :
https://chainsafe.github.io/forest/forest_message/struct.UnsignedMessage.html

My guess is that it should not fail.

Fail if address have 0 bytes

The following test case fails :

    {
        "description": "TODO invalid test case ",
        "encoded_tx": "iEBAAEIAAEIAAEIAAABA",
        "valid": false,
        "testnet": false,
        "message": {
            "to": "",
            "from": "",
            "nonce": 0,
            "value": "0",
            "gas_price": "0",
            "gas_limit": "0",
            "method": 0
        },
        "encoded_tx_hex": "884040004200004200004200000040"
    }

I suspect that forest doesn't check that the length is not 0 and try to get the first byte here :
https://github.com/ChainSafe/forest/blob/d1194bdd942fcd9856376f1cb486739d9631d59b/vm/address/src/lib.rs#L222

Lotus integration - signature does not match

When using the wasm library to derive an address and private key and sign a message, the lotus jsonrpc sends back a "signature does not match" error.

We ran into this same issue with the Ledger once, here's the relevant conversation/fix:

usually people normally deal with compressed public keys (33 bytes)
[7:45 AM]
the are completely equivalent... any secp256k1 library will take one or the other without problem, etc. etc..
[7:45 AM]
the thing is.. addresses hash the pubkey... so then.. it is not the same if you use one or the other
[7:45 AM]
and for the same pubkey/privkey pairs, there were 2 addresses
[7:46 AM]
depending on which format is used (compressed/uncompressed)
[7:46 AM]
this can actually be a serious issue
[7:47 AM]
we have to use uncompressed everywhere or things will fail

CircleCI / Docker - Running ChromeDriver WASM unit tests in docker fails

This only fails when running inside Docker in CI. The tests pass locally

driver status: signal: 9                          
driver stdout:
    Starting ChromeDriver 2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926) on port 39291
    Only local connections are allowed.
    Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

driver stderr:
    [1583857375.960][SEVERE]: bind() failed: Cannot assign requested address (99)

Add support for get_average_gas

It should return some average (or other reference value or stat) for gas requirements in the network

It requires support in Lotus

Add Flutter Example

  • Use key_derive for the example.
  • Add a small section in the documentation
  • Adjust circleCI configuration to confirm
    This very likely depends on the Obj-C and Java examples

verify_signature might need a network flag

If I am not mistaken we have the same issue with verify_signature than with recover_key.

We should also have a flag in order to specify the network when matching the recovered address from the signature and address extracted from the tx.

    // Compare recovered public key with the public key from the transaction
    if tx_from != from.to_string() {
        return Ok(false);
    }

Extend Transaction parse support

Transaction parse support should work for both signed and unsigned types. The function should accept CBOR hexstrings for both cases and detect automatically the correct type.

Disctinct `key_derive` when it is from mnemonic and from seed

Remarks
key_derive only works when given a mnemonic. However the chances is that exchanges have a seed and not the mnemonic because mnemonic are mostly used for backup. Going from seed to mnemonic is not possible.

Proposition
We should support key_derive_from_seed(seed, path).

Service - Lotus integration (jsonrpc requests)

The signing service will rely on a connection to a Lotus node to:

  • Request Nonce values for specific accounts
  • Determine network (mainnet / testnet)
  • Relay signed transactions to the network

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.