EOSIO / EOSIO/eosjs-ecc

ecc.isValidPublic() return false on some valid public keys

Open
#48 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
289
Forks
117
PR merge metrics
No merged PRs in 30d

Description

[ecc.isValidPublic('EOS5K6ag7t87u3F4jdkmt73wQtd9oprQFyJsp6vskrrwoQoPqcPdE7') return false #489](https://github.com/EOSIO/eosjs/issues/489)

**Version**
eosjs 20.0.0-beta3
eosjs-ecc 4.0.4

**Describe the bug**
1. ecc.isValidPublic() return false on 2 public keys of account 1255gdpaftgs
2. Point.decodeFrom() report 'Invalid sequence tag'

**To Reproduce**

1. get the public keys of 1255gdpaftgs

2. validate these keys using ecc.isValidPublic()

```
# umu @ UMU-MBP in ~/github/meet-one/mainnet-snapshot on git:master x [21:45:27]
$ cleos -u https://mainnet.meet.one get account 1255gdpaftgs
created: 2018-11-08T01:25:13.500
permissions:
owner 1: 1 EOS5K6ag7t87u3F4jdkmt73wQtd9oprQFyJsp6vskrrwoQoPqcPdE7
active 1: 1 EOS5Kkxpsx71txnR8niEmZmcG6d6AeSQqYw1qfXYQBDkgh5v4tbGxH
memory:
quota: 5.345 KiB used: 3.365 KiB

net bandwidth:
staked: 0.1000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 79.93 KiB
limit: 79.93 KiB

cpu bandwidth:
staked: 0.1000 EOS (total stake delegated from account to self)
delegated: 0.0000 EOS (total staked delegated to account from others)
used: 0 us
available: 12.63 ms
limit: 12.63 ms

producers:

# umu @ UMU-MBP in ~/github/meet-one/mainnet-snapshot on git:master x [21:45:33]
$ node
> const ecc = require('eosjs-ecc')
undefined
> ecc.isValidPublic('EOS5K6ag7t87u3F4jdkmt73wQtd9oprQFyJsp6vskrrwoQoPqcPdE7')
false
> ecc.isValidPublic('EOS5Kkxpsx71txnR8niEmZmcG6d6AeSQqYw1qfXYQBDkgh5v4tbGxH')
false
```

**Expected behavior**
true, but return false.

**More**
It seems like a bug of `ecurve 1.0.5`

`ecc.PublicKey('EOS5Kkxpsx71txnR8niEmZmcG6d6AeSQqYw1qfXYQBDkgh5v4tbGxH')`

type is 128, isValidPublic() = false

`ecc.PublicKey('EOS7enq7SL9AUhBYgkYMksj34LPKtAr7iu56KKrNTcUPTRqTp5VaN')`

type is 3, isValidPublic() = true

I use C++ code to validate these keys, and the test passes.

```
BOOST_AUTO_TEST_CASE(test_by_UMU) try {
auto pub_str = std::string("EOS5Kkxpsx71txnR8niEmZmcG6d6AeSQqYw1qfXYQBDkgh5v4tbGxH");
auto pub = public_key(pub_str);

std::cout << pub_str << " => " << pub << std::endl;

BOOST_CHECK(pub.valid());
BOOST_CHECK_EQUAL(pub_str, std::string(pub));
} FC_LOG_AND_RETHROW();
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.