Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Conversation

@Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Jul 7, 2021

The Keyring type represents the common API between all of our keyrings. Currently the keyrings are written in JavaScript and they don't extend a base type, but they are assumed to have certain methods and method signatures.

The Keyring interface represents a keyring instance. It has mandatory methods for basic functionality such as serialization/deserialization, and getting and adding accounts. Some account management methods are optional, like exportAccount which isn't possible to implement on hardware wallets. The signing methods are all optional as well, as they might not be implemented if the keyring doesn't support that type of signing.

The KeyringClass type is used to validate that the class itself has the expected constructor signature and static properties. This needs to be a separate type because you can't validate constructor signatures or static properties with an interface, and we rely upon both of these things being consistent between all keyrings in the KeyringController.

Note that this is just an attempt at capturing the existing keyring API, without making any changes. We will be redesigning this API in the near future.

@Gudahtt
Copy link
Member Author

Gudahtt commented Jul 7, 2021

This depends upon #2

@Gudahtt Gudahtt force-pushed the add-keyring-type branch from 53f9f1b to 95b5bb8 Compare July 7, 2021 15:53
@Gudahtt
Copy link
Member Author

Gudahtt commented Jul 7, 2021

I'm still working on the tests for this type, and I'd like to test this with the real keyrings before moving this out of draft. But the type itself and the inline docs are complete as far as I know, so this is OK for some early review now.

@Gudahtt Gudahtt force-pushed the add-keyring-type branch from 95b5bb8 to 09ceab4 Compare July 9, 2021 01:26
Base automatically changed from add-hex-prefixed to main July 12, 2021 18:16
@Gudahtt Gudahtt force-pushed the add-keyring-type branch 2 times, most recently from daa2b53 to 729c5ce Compare July 12, 2021 18:55
},
"dependencies": {
"@ethereumjs/tx": "^3.2.1",
"eth-sig-util": "^3.0.1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to replace the two types from these packages with our own. Better to avoid any non-type dependencies if possible. Plus, we ought to have our own Transaction type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, the types to develop internally are,

  1. @ethereumjs/tx - Transaction (source)
  2. eth-sig-util - EthEncryptedData (source)

The Keyring type represents the common API between all of our keyrings.
Currently the keyrings are written in JavaScript and they don't extend
a base type, but they are assumed to have certain methods and method
signatures.

The Keyring interface represents a keyring instance. It has mandatory
methods for basic functionality such as serialization/deserialization,
and getting and adding accounts. Some account management methods are
optional, like `exportAccount` which isn't possible to implement on
hardware wallets. The signing methods are all optional as well, as they
might not be implemented if the keyring doesn't support that type of
signing.

The KeyringClass type is used to validate that the class itself has the
expected constructor signature and static properties. This needs to be
a separate type because you can't validate constructor signatures or
static properties with an interface, and we rely upon both of these
things being consistent between all keyrings in the
`KeyringController`.

Note that this is just an attempt at capturing the existing keyring
API, without making any changes. We will be redesigning this API in the
near future.
@socket-security
Copy link

Socket Security Pull Request Report

Dependency issues detected. If you merge this pull request, you will not be alerted to the instances of these issues again.

📜 Install scripts

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Package Script field Source
keccak@3.0.1 (added) install package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
secp256k1@4.0.2 (added) install package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
keccak@3.0.1 (added) binding.gyp package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
secp256k1@4.0.2 (added) binding.gyp package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
🫣 Native code

Contains native code which could be a vector to obscure malicious code, and generally decrease the likelihood of reproducible or reliable installs.

Ensure that native code bindings are expected. Consumers may consider pure JS and functionally similar alternatives to avoid the challenges and risks associated with native code bindings.

Package Location Source
keccak@3.0.1 (added) binding.gyp package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
secp256k1@4.0.2 (added) binding.gyp package.json via @ethereumjs/tx@3.2.1, ethereumjs-util@7.0.10, ethereum-cryptography@0.1.3
Pull request report summary
Issue Status
Install scripts ⚠️ 4 issues
Native code ⚠️ 2 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@2.4.2

  • @SocketSecurity ignore keccak@3.0.1
  • @SocketSecurity ignore secp256k1@4.0.2

Powered by socket.dev

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants