Commit Graph

2 Commits

Author SHA1 Message Date
Michael Bradley, Jr 54cb3d746f refactor: nim_status -> status
The name of the repo is not being changed. But instead of doing:

```nim
import nim_status
```

You would do:

```nim
import status
```

This is in line with nim-chronos (`import chronos`), nim-waku (`import waku`),
and many other Nim libs.
2021-07-29 14:23:26 -05:00
Eric Mastro f81027c7d5 refactor(nim-status): change to a port of status-go's account generation
Closes: #199

Some functions in `nim-status` were attempting to do too much in comparison to their `status-go` counterparts. The filesystem in `nim-status` varied quite a lot from the filesystem in `status-go`, which made comparing functions difficult. The end result was that certain cryptographic operations, such as generating a `keyUid` did not match between `nim-status` and `status-go`.

This PR fixes this problem by first moving some account generation files around in the filesystem to more closely mirror `status-go`. Then, the account generation functions from `status-go` were ported over to `nim-status` and the example chat client was changed to use these new functions.

Once the port from `status-go` had been completed, it could be more clearly seen that the cause of the `keyUid` mismatch was due to the use of `nim-eth`’s `PrivateKey` type over `secp256k1`’s `SkPrivateKey`. `nim-eth` does not include the `0x04` prefix that `secp256k1` uses, because `nim-eth` is more focused on ethereum implementations which do not need the prefix. Switching `PrivateKey` (in `nim-eth`) to `SkPrivateKey` (in `secp256k1`) and `PublicKey` to `SkPublicKey` allowed the `keyUid` generation to match between `nim-status` and `status-go`.

There was also some confusion between two different `Account` types in the codebase. One `Account` type was for public consumption and stored in the unencrypted accounts db. The other `Account` type contained private keys and was meant to be stored in the encrypted user db. The public `Account` type was changed to `PublicAccount` to avoid confusion.

Other notable changes include:

- chore(nim-status): Keccak 256 hash the plain text db password before keying the db.
- feat(ex-client): Move the db interactions to the nim-status client instead of doing all of it in the task.
- chore(ex-client): Remove `bip32passphrase` from `/import` arg and assume an empty string for now.

### Todo:

1. Adjust `derive` to use hardened children. This can be shown in the “derive address from imported key” test that fails when uncommented. [An issue has been created for this]([https://github.com/status-im/nim-status/issues/211](https://github.com/status-im/nim-status/issues/211))
2021-07-15 15:54:55 -05:00