Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@metamask/bip32-example-snap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@metamask/bip32-example-snap
This snap demonstrates the use of snap_getBip32Entropy and
snap_getBip32PublicKey to derive a BIP-32 public key and private key from the
user's secret recovery phrase.
Snap manifest
Note: Using
snap_getBip32Entropyandsnap_getBip32PublicKeyrequires their respectivesnap_getBip32Entropyandsnap_getBip32PublicKeypermissions. Refer to the documentation for more information.
Along with other permissions, the manifest of this snap includes the
snap_getBip32Entropy and snap_getBip32PublicKey permissions:
{
"initialPermissions": {
"snap_getBip32Entropy": [
{
"path": ["m", "44'", "0'"],
"curve": "secp256k1"
},
{
"path": ["m", "44'", "0'"],
"curve": "ed25519"
}
],
"snap_getBip32PublicKey": [
{
"path": ["m", "44'", "0'"],
"curve": "secp256k1"
}
]
}
}Each of the items in the snap_getBip32Entropy and snap_getBip32PublicKey
permissions is an object with the following properties:
path: The BIP-32 derivation path to use.curve: The elliptic curve to use. These methods supportsecp256k1anded25519.
Snap usage
This snap exposes an onRpcRequest handler, which supports the following
JSON-RPC methods:
getPublicKey: Get the public key for the givenpathandcurve.signMessage: Sign amessagewith the private key for the givenpathandcurve. The message is signed with the chosen curve's signing algorithm (ECDSA forsecp256k1and EdDSA fored25519).
For more information, you can refer to the end-to-end tests.