@inbloxme/keyless-transactions-private
v1.0.4
Published
Package for signing transactions using Inblox password.
Downloads
3
Readme
Keyless Transactions - GetSafle
This package enables usage of SafleId infrastructure as a keyless signing mechanism.
Disclaimer - This is WIP, and release in alpha.
Keyless Transactions
Talking about user adoption, the bottleneck faced by most of the dApps is the user onboarding flow. The user needs to have a wallet, generating and operating a wallet is cumbersome for a new crypto user.
Keyless transactions abstracts the private key from the user and allows the user to sign transaction in an easy way while having the same level of security as before.
SafleId Keyless Transactions allow users to sign transactions via,
- Password
- Biometrics A. Fingerprint B. FaceID
- Device based virtual Hardware Security Module
We have made password based transaction signing available for anyone to use, build upon and replicate.
This documentation focuses more on that, more coming soon. If you want to know more and enagage with development, you can email at the address in footnotes.
Happy #BUIDLing
Design Principles
- Private Key Abstraction - SafleId infrastructure never have the visibility of the private key, it's encrypted on the client with the user password(unsalted & unencrypted) and sent to the virtual Hardware Security Module for safe storage.
- Password Invisibility - User password is never exposed in plain text to any of the systems apart from the client.
- Non-Custodial Relationship - User Private Key is always exportable and encrypted version can be deleted (redundant) from the SafleId infrastructure.
- App Agnostic - Any application without getting an API key can access SafleId service, password based transaction signing requires special access which can be requested for. (In Alpha Testing).
Installation and Usage
Installation
Install the package by running the command,
npm install @inbloxme/keyless-transactions-private
Import the package into your project using,
const inblox = require('@inbloxme/keyless-transactions-private');
Password Based Transaction Sign
Initialising
Initialise the constructor using,
const PBTS = new inblox.PBTS(authenticationToken);
Encryption & Storage
This method is used to store the private key after encrypting it with the user's password. The password of the user gets validated first before encrypting the private key and storing it in the GetSafle Key Management System (KMS).
const StoreKey = PBTS.storeKey({ privateKey, password });
privateKey
- The private key to be encrypted and stored in the GetSafle Key Management System.
password
- The SafleId password of the user. This password is used to encrypt the private key.
Get Encrypted Private Key
This method is used to get the encrypted private key of the user from GetSafle Key Management System.
const encryptedPrivateKey = PBTS.getEncryptedPrivateKey({ password });
password
- The password of the user.
Change Password
This method is used to change the existing password of a user. The old password of the user will get validated and it will be used to retrieve the encrypted private key of the user and decrypt it. Then the private key will be encrypted using the new password and it will get sent to the GetSafle KMS.
const changePassword = PBTS.changePassword({ encryptedPrivateKey, oldPassword, newPassword, confirmPassword });
encryptedPrivateKey
- Encrypted private key of the user which is obtained using the method getEncryptedPrivateKey
.
oldPassword
- The old password of the user.
newPassword
- The new password of the user.
confirmPassword
- Confirm new password.
Reset Password
This method is used to reset the password incase the user forgets thir existing password. The user will have to prove their ownership for their private key before re-encrypting their private key with their new password. This can be done by providing either their private key directly or the 12 word seed phrase or their keystore file with its password. The private key and public address will get extracted which will be used to verify against the public address stored with the Safle systems.
const resetPassword = PBTS.resetPassword({ privateKey, seedphrase, encryptedJson, walletPassword, newPassword, });
privateKey
- The private key of the user's wallet.
OR
seedPhrase
- The 12 word seed phrase.
OR
encryptedJson
- Keystore JSON.
AND
walletPassword
- Keystore password.
AND
newPassword
- New password.
Sign Transaction
This method can be used to sign a transaction using the user's private key. The transaction can be done using the provider as infura by inputting the infura key or the RPC URL.
const signTx = PBTS.signAndSendTx({ password, rawTx });
password
- The SafleId password of the user.
rawTx
- The raw transaction object.
The rawTx
object contains,
to
- Address to send the transaction to.
from
- Address of the sender.
gasPrice
- Price of gas in wei.
gasLimit
- Gas Limit for the transaction.
nonce
- Nonce of the sender address.
value
- Amount to be sent in the transaction.
data
- Data to be passed in the transaction. Can be a contract call data.
Delete Encrypted Private Key
This method is used to delete a user's encypted private key from the GetSafle Key Management System after authenticating the user's password.
const signTx = PBTS.deleteKey({ password });
password
- The Inblox password of the user.
Register SafleID
This method is used to register a user's safleId.
const signTx = PBTS.registerSafleId({ publicAddress, privateKey, password });
publicAddress
- Public address of the user.
privateKey
- The private key of the address.
password
- The Inblox password of the user.
Wallet Generation
Initialising
Initialise the constructor for Wallet generation and wallet import methods using,
const Wallet = new inblox.SafleWallet();
Generate New Wallet
This method is used to generate a new Ethereum wallet.
const newWallet = Wallet.createWallet();
Import Wallet From Mnemonic
This method is used to import an Ethereum wallet from it's 12 word mnemonic phrase.
const wallet = Wallet.importFromMnemonic(mnemonic);
mnemonic
- 12 word mnemonic phrase.
Import Wallet From Keystore JSON
This method is used to import an Ethereum wallet from it's keystore file.
const wallet = Wallet.importFromEncryptedJson(json, passphrase);
json
- Keystore JSON of the wallet.
passphrase
- Keystore password.
Generate 2 Random Numbers
This method is used to generate 2 random numbers so that it can be used to validate the user's seed phrase by asking them to provide the word corresponding to that number.
const wallet = Wallet.generateRandomNumber();
Validate Seed Phrase
This method is used to validate the user's seed phrase by asking them to provide the words corresponding to the 2 numbers generated above.
const wallet = Wallet.validateSeeds({ firstWord, secondWord });
firstWord
- Word corresponding to the first number.
secondWord
- Word corresponding to the second number.
Login Via Safle
Initialising
To use Login Via Safle method, initialise the constructor using,
const loginViaSafle = new inblox.LoginViaSafle(accessToken);
Login Via Safle
This method is used to generate a Bearer token from the GetSafle backend systems which can be used to initiate request to access protected resources.
const token = loginViaSafle.login({ userName, password });
userName
- The user's safleId or the email id associated with Safle platform.
password
- The SafleId password of the user.
LogOut
This method is used to logout from the GetSafle platform.
const token = loginViaSafle.logout();
Note - For all the methods, errors are returned under
error
key and success is returned underresponse
key.
WIP
Want to contribute, we would :heart: that!
We are a Global :earth_asia::earth_africa::earth_americas: team! :muscle:
Write to [email protected], or follow us on twitter, https://twitter.com/inblox_me