UNPKG

ssv-keys

Version:

CLI Tool for splitting a validator key into a predefined threshold of shares via Shamir-Secret-Sharing (SSS), and encrypt them with a set of operator keys.

43 lines (34 loc) 1.43 kB
import { KeySharesItem, SSVKeys } from "@ssv-labs/ssv-sdk"; const keystore = require('./test.keystore.json'); const operatorKeys = require('./operators.json'); const operatorIds = require('./operatorIds.json'); const keystorePassword = 'testtest'; // The nonce of the owner within the SSV contract (increments after each validator registration), obtained using the ssv-scanner tool const TEST_OWNER_NONCE = 1; // The cluster owner address const TEST_OWNER_ADDRESS = '0x81592c3de184a3e2c0dcb5a261bc107bfa91f494'; async function main() { // Step 1: read keystore file const ssvKeys = new SSVKeys(); const { publicKey, privateKey } = await ssvKeys.extractKeys(keystore, keystorePassword); const operators = operatorKeys.map((operatorKey, index) => ({ id: operatorIds[index], operatorKey, })); // Step 2: Build shares from operator IDs and public keys const threshold = await ssvKeys.createThreshold(privateKey, operators); const encryptedShares = await ssvKeys.encryptShares(operators, threshold.shares); // Step 3: Build final web3 transaction payload and update keyshares file with payload data const keySharesItem = new KeySharesItem(); const payload = await keySharesItem.buildPayload({ publicKey, operators, encryptedShares, }, { ownerAddress: TEST_OWNER_ADDRESS, ownerNonce: TEST_OWNER_NONCE, privateKey }); console.debug('payload: ', payload); } void main();