@ssv-labs/ssv-sdk 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/KeyShares-7biQfDev.js +19422 -0
  2. package/dist/KeyShares-DEqBZits.mjs +19423 -0
  3. package/dist/api/subgraph/index.d.ts +15 -54
  4. package/dist/config/chains.d.ts +18 -10
  5. package/dist/contract-interactions/types.d.ts +3 -1
  6. package/dist/globals-BZbDG7rK.mjs +472 -0
  7. package/dist/globals-iY-Y-uDY.js +471 -0
  8. package/dist/graphql/graphql.d.ts +10 -33
  9. package/dist/keys.js +9 -0
  10. package/dist/keys.mjs +9 -0
  11. package/dist/libs/api/index.d.ts +9 -69
  12. package/dist/libs/cluster/index.d.ts +11 -5632
  13. package/dist/libs/cluster/methods/deposit.d.ts +1 -1
  14. package/dist/libs/cluster/methods/exit-validators.d.ts +1 -1
  15. package/dist/libs/cluster/methods/index.d.ts +1 -1
  16. package/dist/libs/cluster/methods/liquidate-cluster.d.ts +1 -1
  17. package/dist/libs/cluster/methods/reactivate-cluster.d.ts +1 -1
  18. package/dist/libs/cluster/methods/register-validators.d.ts +6 -4
  19. package/dist/libs/cluster/methods/remove-validators.d.ts +1 -1
  20. package/dist/libs/cluster/methods/set-fee-recipient.d.ts +1 -1
  21. package/dist/libs/cluster/methods/withdraw.d.ts +1 -1
  22. package/dist/libs/operator/index.d.ts +119 -901
  23. package/dist/libs/operator/methods.d.ts +3 -3
  24. package/dist/libs/ssv-keys/BLS/index.d.ts +2 -0
  25. package/dist/libs/ssv-keys/Encryption/Encryption.d.ts +7 -0
  26. package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +3 -0
  27. package/dist/libs/ssv-keys/Encryption/utils.d.ts +55 -0
  28. package/dist/libs/ssv-keys/EthereumKeyStore/EthereumKeyStore.d.ts +23 -0
  29. package/dist/libs/ssv-keys/EthereumKeyStore/index.d.ts +1 -0
  30. package/dist/libs/ssv-keys/KeyShares/KeyShares.d.ts +32 -0
  31. package/dist/libs/ssv-keys/KeyShares/KeySharesData/KeySharesData.d.ts +21 -0
  32. package/dist/libs/ssv-keys/KeyShares/KeySharesData/KeySharesPayload.d.ts +32 -0
  33. package/dist/libs/ssv-keys/KeyShares/KeySharesData/OperatorData.d.ts +10 -0
  34. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/encrypted-key.d.ts +6 -0
  35. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/index.d.ts +6 -0
  36. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/match.d.ts +6 -0
  37. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/operator-public-key.d.ts +6 -0
  38. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/operator-unique.d.ts +6 -0
  39. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/owner-address.d.ts +6 -0
  40. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/owner-nonce.d.ts +6 -0
  41. package/dist/libs/ssv-keys/KeyShares/KeySharesData/validators/public-key.d.ts +6 -0
  42. package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +60 -0
  43. package/dist/libs/ssv-keys/SSVKeys.d.ts +66 -0
  44. package/dist/libs/ssv-keys/Threshold/Threshold.d.ts +28 -0
  45. package/dist/libs/ssv-keys/Threshold/__test__/helper/share_signatures.d.ts +7 -0
  46. package/dist/libs/ssv-keys/Threshold/index.d.ts +1 -0
  47. package/dist/libs/ssv-keys/exceptions/base.d.ts +4 -0
  48. package/dist/libs/ssv-keys/exceptions/bls.d.ts +9 -0
  49. package/dist/libs/ssv-keys/exceptions/index.d.ts +2 -0
  50. package/dist/libs/ssv-keys/exceptions/keyshares.d.ts +5 -0
  51. package/dist/libs/ssv-keys/exceptions/keystore.d.ts +27 -0
  52. package/dist/libs/ssv-keys/exceptions/operator.d.ts +22 -0
  53. package/dist/libs/ssv-keys/helpers/operator.helper.d.ts +7 -0
  54. package/dist/libs/ssv-keys/helpers/web3.helper.d.ts +36 -0
  55. package/dist/libs/ssv-keys/index.d.ts +4 -0
  56. package/dist/libs/ssv-keys/interfaces/IEncryptShare.d.ts +5 -0
  57. package/dist/libs/ssv-keys/interfaces/IKeySharesData.d.ts +18 -0
  58. package/dist/libs/ssv-keys/interfaces/IKeySharesPayload.d.ts +13 -0
  59. package/dist/libs/ssv-keys/interfaces/IOperator.d.ts +4 -0
  60. package/dist/libs/ssv-keys/interfaces/IOperatorData.d.ts +5 -0
  61. package/dist/libs/ssv-keys/interfaces/IShares.d.ts +10 -0
  62. package/dist/libs/ssv-keys/interfaces/index.d.ts +6 -0
  63. package/dist/libs/ssv-keys/validators/index.d.ts +2 -0
  64. package/dist/libs/ssv-keys/validators/operatorPublicKey.validator.d.ts +1 -0
  65. package/dist/libs/ssv-keys/validators/operatorsLength.validator.d.ts +1 -0
  66. package/dist/libs/utils/index.d.ts +8 -18
  67. package/dist/libs/utils/methods/keyshares.d.ts +5 -2
  68. package/dist/libs/utils/methods/keystores.d.ts +2 -2
  69. package/dist/main.d.ts +1 -0
  70. package/dist/main.js +3862 -34136
  71. package/dist/main.mjs +3920 -34193
  72. package/dist/mock/api.d.ts +1 -1
  73. package/dist/types/contract-interactions.d.ts +2 -2
  74. package/dist/utils/cluster.d.ts +1 -1
  75. package/dist/utils/contract.d.ts +2 -1
  76. package/dist/utils/keyshares.d.ts +2 -2
  77. package/dist/utils/number.d.ts +1 -1
  78. package/dist/utils/zod/config.d.ts +1 -1
  79. package/dist/utils.js +1 -1
  80. package/dist/utils.mjs +34 -34
  81. package/package.json +29 -14
  82. package/dist/globals-DsbufPrE.mjs +0 -5541
  83. package/dist/globals-fh7gkHKO.js +0 -5539
@@ -7,7 +7,7 @@ type WithdrawArgs = SmartFnWriteOptions<{
7
7
  amount: bigint;
8
8
  }>;
9
9
  export declare const withdraw: (config: ConfigReturnType, { args: { operatorId, amount }, ...writeOptions }: WithdrawArgs) => Promise<{
10
- hash: `0x${string}`;
10
+ hash: import('viem').Hash;
11
11
  wait: () => Promise<import('viem').TransactionReceipt & {
12
12
  events: ({
13
13
  eventName: "AdminChanged";
@@ -287,7 +287,7 @@ type RegisterOperatorArgs = SmartFnWriteOptions<{
287
287
  publicKey: string;
288
288
  }>;
289
289
  export declare const registerOperator: (config: ConfigReturnType, { args: { isPrivate, yearlyFee, publicKey }, ...writeOptions }: RegisterOperatorArgs) => Promise<{
290
- hash: `0x${string}`;
290
+ hash: import('viem').Hash;
291
291
  wait: () => Promise<import('viem').TransactionReceipt & {
292
292
  events: ({
293
293
  eventName: "AdminChanged";
@@ -566,7 +566,7 @@ type SetOperatorWhitelistsArgs = SmartFnWriteOptions<{
566
566
  contractAddress: Address;
567
567
  }>;
568
568
  export declare const setOperatorWhitelists: (config: ConfigReturnType, { args: { operatorIds, contractAddress }, ...writeOptions }: SetOperatorWhitelistsArgs) => Promise<{
569
- hash: `0x${string}`;
569
+ hash: import('viem').Hash;
570
570
  wait: () => Promise<import('viem').TransactionReceipt & {
571
571
  events: ({
572
572
  eventName: "AdminChanged";
@@ -0,0 +1,2 @@
1
+ import { default as bls } from 'bls-eth-wasm';
2
+ export default bls;
@@ -0,0 +1,7 @@
1
+ import { IEncryptShare, IShares } from '../interfaces';
2
+ export default class Encryption {
3
+ private readonly operatorPublicKeys;
4
+ private readonly shares;
5
+ constructor(operatorPublicKeys: string[], shares: IShares[]);
6
+ encrypt(): IEncryptShare[];
7
+ }
@@ -0,0 +1,3 @@
1
+ declare const publicKeys: string[];
2
+ declare const privateKeys: string[];
3
+ export { privateKeys, publicKeys, };
@@ -0,0 +1,55 @@
1
+ import * as forge from 'node-forge';
2
+ /**
3
+ * Node-forge implementation of JSEncrypt-like functionality
4
+ * Designed to match JSEncrypt's behavior exactly, including permissive key validation
5
+ */
6
+ export declare class ForgeEncrypt {
7
+ private publicKey;
8
+ private privateKey;
9
+ constructor();
10
+ /**
11
+ * Set the public key (equivalent to JSEncrypt.setPublicKey)
12
+ * Matches JSEncrypt's permissive behavior - doesn't throw on invalid keys
13
+ */
14
+ setPublicKey(publicKeyPem: string): void;
15
+ /**
16
+ * Set the private key (equivalent to JSEncrypt.setPrivateKey)
17
+ * Matches JSEncrypt's permissive behavior - doesn't throw on invalid keys
18
+ */
19
+ setPrivateKey(privateKeyPem: string): void;
20
+ /**
21
+ * Encrypt data with public key (equivalent to JSEncrypt.encrypt)
22
+ * Returns base64 encoded encrypted data or false if encryption fails
23
+ */
24
+ encrypt(data: string): string | false;
25
+ /**
26
+ * Decrypt data with private key (equivalent to JSEncrypt.decrypt)
27
+ * Expects base64 encoded encrypted data, returns false if decryption fails
28
+ */
29
+ decrypt(encryptedData: string): string | false;
30
+ /**
31
+ * Get the public key in PEM format
32
+ */
33
+ getPublicKey(): string;
34
+ /**
35
+ * Get the private key in PEM format
36
+ */
37
+ getPrivateKey(): string;
38
+ }
39
+ /**
40
+ * Validate RSA public key using node-forge (equivalent to JSEncrypt validation)
41
+ * Note: This function is more strict than JSEncrypt for external validation
42
+ */
43
+ export declare function validateRsaPublicKey(publicKeyPem: string): boolean;
44
+ /**
45
+ * Generate a new RSA key pair (for testing purposes)
46
+ */
47
+ export declare function generateRsaKeyPair(keySize?: number): {
48
+ publicKey: string;
49
+ privateKey: string;
50
+ };
51
+ /**
52
+ * Convert PEM key to node-forge key object
53
+ */
54
+ export declare function pemToPublicKey(pem: string): forge.pki.rsa.PublicKey;
55
+ export declare function pemToPrivateKey(pem: string): forge.pki.rsa.PrivateKey;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Decrypt private key from key store data
3
+ * Supports key store versions: v1, v3, v4
4
+ *
5
+ * Example of usage (Node env):
6
+ *
7
+ * const keyStoreFilePath = path.join(process.cwd(), 'validator_keys', 'keystore.json');
8
+ * const keyStoreString: string = fs.readFileSync(keyStoreFilePath).toString();
9
+ * const keyStoreData = JSON.parse(keyStoreString);
10
+ * const keyStore = new EthereumKeyStore(keyStoreData);
11
+ * const password = 'testtest';
12
+ * console.log('Private Key:', await keyStore.getPrivateKey(password));
13
+ */
14
+ declare class EthereumKeyStore {
15
+ private readonly keyStoreData;
16
+ private privateKey;
17
+ constructor(keyStoreData: any);
18
+ getPrivateKey(password?: string): Promise<string>;
19
+ private fromV3;
20
+ private fromCustomV4;
21
+ private runCipherBuffer;
22
+ }
23
+ export default EthereumKeyStore;
@@ -0,0 +1 @@
1
+ export { default } from './EthereumKeyStore';
@@ -0,0 +1,32 @@
1
+ import { KeySharesItem } from './KeySharesItem';
2
+ /**
3
+ * Represents a collection of KeyShares items with functionality for serialization,
4
+ * deserialization, and validation.
5
+ */
6
+ export declare class KeyShares {
7
+ private shares;
8
+ constructor(shares?: KeySharesItem[]);
9
+ /**
10
+ * Add a single KeyShares item to the collection.
11
+ * @param keySharesItem The KeyShares item to add.
12
+ */
13
+ add(keySharesItem: KeySharesItem): void;
14
+ list(): KeySharesItem[];
15
+ /**
16
+ * Validate the KeyShares instance using class-validator.
17
+ * @returns The validation result.
18
+ */
19
+ validate(): any;
20
+ /**
21
+ * Converts the KeyShares instance to a JSON string.
22
+ * @returns The JSON string representation of the KeyShares instance.
23
+ */
24
+ toJson(): string;
25
+ /**
26
+ * Initialize the KeyShares instance from JSON or object data.
27
+ * @param content The JSON string or object to initialize from.
28
+ * @returns The KeyShares instance.
29
+ * @throws Error if the version is incompatible or the shares array is invalid.
30
+ */
31
+ static fromJson(content: string | any): Promise<KeyShares>;
32
+ }
@@ -0,0 +1,21 @@
1
+ import { IKeySharesData, IKeySharesPartialData } from '../../interfaces';
2
+ import { OperatorData } from './OperatorData';
3
+ export declare class KeySharesData implements IKeySharesData {
4
+ ownerNonce?: number | null;
5
+ ownerAddress?: string | null;
6
+ publicKey?: string | null;
7
+ operators?: OperatorData[] | null;
8
+ update(data: IKeySharesPartialData): void;
9
+ /**
10
+ * Do all possible validations.
11
+ */
12
+ validate(): Promise<any>;
13
+ /**
14
+ * Get the list of operators IDs.
15
+ */
16
+ get operatorIds(): number[];
17
+ /**
18
+ * Get the list of operators public keys.
19
+ */
20
+ get operatorPublicKeys(): string[];
21
+ }
@@ -0,0 +1,32 @@
1
+ import { IKeySharesPartialPayload, IKeySharesPayload } from '../../interfaces';
2
+ /**
3
+ * Key Shares Payload
4
+ */
5
+ export declare class KeySharesPayload implements IKeySharesPayload {
6
+ sharesData: string;
7
+ publicKey: string;
8
+ operatorIds: number[];
9
+ /**
10
+ * Converts arrays of public and private keys to a single hexadecimal string.
11
+ * @param publicKeys Array of public keys.
12
+ * @param privateKeys Array of private keys.
13
+ * @returns Hexadecimal string representation of keys.
14
+ */
15
+ private _sharesToBytes;
16
+ /**
17
+ * Updates the payload with new data and validates it.
18
+ * @param data Partial key shares payload to update.
19
+ */
20
+ update(data: IKeySharesPartialPayload): void;
21
+ /**
22
+ * Validates the current state of the instance.
23
+ * @returns {void | ValidationError[]} Validation errors if any, otherwise undefined.
24
+ */
25
+ validate(): any;
26
+ /**
27
+ * Builds the payload from the given data.
28
+ * @param data Data to build the payload.
29
+ * @returns {KeySharesPayload} The current instance for chaining.
30
+ */
31
+ build(data: any): KeySharesPayload;
32
+ }
@@ -0,0 +1,10 @@
1
+ import { IOperator, IOperatorData } from '../../interfaces';
2
+ export declare class OperatorData implements IOperatorData {
3
+ id: number;
4
+ operatorKey: string;
5
+ constructor(data: IOperator);
6
+ /**
7
+ * Validate operator id and public key
8
+ */
9
+ validate(): void;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions } from 'class-validator';
2
+ export declare class EncryptedKeyValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: any): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function EncryptedKeyValidator(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ export { OpeatorsListValidator } from './operator-unique';
2
+ export { PublicKeyValidator } from './public-key';
3
+ export { OwnerAddressValidator } from './owner-address';
4
+ export { OwnerNonceValidator } from './owner-nonce';
5
+ export { MatchLengthValidator } from './match';
6
+ export { OperatorPublicKeyValidatorConstraint } from './operator-public-key';
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions, ValidationArguments } from 'class-validator';
2
+ export declare class MatchLengthValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: any, args: ValidationArguments): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function MatchLengthValidator(property: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ import { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
2
+ export declare class OperatorPublicKeyValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: string): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function OperatorPublicKeyValidator(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions } from 'class-validator';
2
+ export declare class OpeatorsListValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(operatorsList: any): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function OpeatorsListValidator(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions } from 'class-validator';
2
+ export declare class OwnerAddressValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: any): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function OwnerAddressValidator(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions } from 'class-validator';
2
+ export declare class OwnerNonceValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: any): boolean;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function OwnerNonceValidator(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,6 @@
1
+ import { ValidatorConstraintInterface, ValidationOptions } from 'class-validator';
2
+ export declare class PublicKeyValidatorConstraint implements ValidatorConstraintInterface {
3
+ validate(value: any): Promise<boolean>;
4
+ defaultMessage(): string;
5
+ }
6
+ export declare function PublicKeyValidator(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
@@ -0,0 +1,60 @@
1
+ import { IEncryptShare, IKeySharesPartialData, IOperator } from '../interfaces';
2
+ import { KeySharesData } from './KeySharesData/KeySharesData';
3
+ import { SSVKeysException } from '../exceptions/base';
4
+ import { KeySharesPayload } from './KeySharesData/KeySharesPayload';
5
+ export interface IKeySharesPayloadData {
6
+ publicKey: string;
7
+ operators: IOperator[];
8
+ encryptedShares: IEncryptShare[];
9
+ }
10
+ export interface IKeySharesToSignatureData {
11
+ ownerAddress: string;
12
+ ownerNonce: number;
13
+ privateKey: string;
14
+ }
15
+ export interface IKeySharesFromSignatureData {
16
+ ownerAddress: string;
17
+ ownerNonce: number;
18
+ publicKey: string;
19
+ }
20
+ /**
21
+ * Key shares file data interface.
22
+ */
23
+ export declare class KeySharesItem {
24
+ data: KeySharesData;
25
+ payload: KeySharesPayload;
26
+ error: SSVKeysException | undefined;
27
+ constructor();
28
+ /**
29
+ * Build payload from operators list, encrypted shares and validator public key
30
+ */
31
+ buildPayload(metaData: IKeySharesPayloadData, toSignatureData: IKeySharesToSignatureData): Promise<any>;
32
+ validateSingleShares(shares: string, fromSignatureData: IKeySharesFromSignatureData): Promise<void>;
33
+ /**
34
+ * Build shares from bytes string and operators list length
35
+ * @param bytes
36
+ * @param operatorCount
37
+ */
38
+ buildSharesFromBytes(bytes: string, operatorCount: number): {
39
+ sharesPublicKeys: string[];
40
+ encryptedKeys: string[];
41
+ };
42
+ /**
43
+ * Updates the current instance with partial data and payload, and validates.
44
+ */
45
+ update(data: IKeySharesPartialData): void;
46
+ /**
47
+ * Validate everything
48
+ */
49
+ validate(): void;
50
+ /**
51
+ * Stringify key shares to be ready for saving in file.
52
+ */
53
+ toJson(): string;
54
+ private splitArray;
55
+ /**
56
+ * Initialise from JSON or object data.
57
+ */
58
+ static fromJson(content: string | unknown): Promise<KeySharesItem>;
59
+ }
60
+ export type IKeySharesItem = InstanceType<typeof KeySharesItem>;
@@ -0,0 +1,66 @@
1
+ import { IOperator, IShares, ISharesKeyPairs, IEncryptShare } from './interfaces';
2
+ export interface ExtractedKeys {
3
+ privateKey: string;
4
+ publicKey: string;
5
+ }
6
+ interface ISharesValidation {
7
+ shares: string;
8
+ operatorsCount: number;
9
+ validatorPublicKey: string;
10
+ isAccountExists: boolean;
11
+ ownerAddress: string;
12
+ ownerNonce: number;
13
+ blockNumber: number;
14
+ }
15
+ /**
16
+ * SSVKeys class provides high-level methods to easily work with entire flow:
17
+ * - getting private key from keystore file using password
18
+ * - creating shares threshold
19
+ * - creating final shares
20
+ * - building final payload which is ready to be used in web3 transaction
21
+ */
22
+ export declare class SSVKeys {
23
+ protected threshold: ISharesKeyPairs | undefined;
24
+ /**
25
+ * Extract private key from keystore data using keystore password.
26
+ * Generally can be used in browsers when the keystore data has been provided by browser.
27
+ * @param data
28
+ * @param password
29
+ */
30
+ extractKeys(data: string, password: string): Promise<ExtractedKeys>;
31
+ /**
32
+ * Build threshold using private key and list of operators.
33
+ * @param privateKey
34
+ * @param operators
35
+ */
36
+ createThreshold(privateKey: string, operators: IOperator[]): Promise<ISharesKeyPairs>;
37
+ /**
38
+ * Encrypt operators shares using operators list (id, publicKey).
39
+ * @param operators
40
+ * @param shares
41
+ */
42
+ encryptShares(operators: IOperator[], shares: IShares[]): Promise<IEncryptShare[]>;
43
+ /**
44
+ * Build shares from private key, operators list
45
+ * @param privateKey
46
+ * @param operators
47
+ */
48
+ buildShares(privateKey: string, operators: IOperator[]): Promise<IEncryptShare[]>;
49
+ /**
50
+ * Getting threshold if it has been created before.
51
+ */
52
+ getThreshold(): ISharesKeyPairs | undefined;
53
+ validateSharesPostRegistration({ shares, operatorsCount, validatorPublicKey, isAccountExists, ownerAddress, ownerNonce, blockNumber }: ISharesValidation): Promise<{
54
+ isValid: boolean;
55
+ isSharesValid: boolean;
56
+ sharesPublicKeys: string[] | undefined;
57
+ encryptedKeys: string[] | undefined;
58
+ memo: {
59
+ message: string;
60
+ error: string;
61
+ data: string;
62
+ blockNumber: number;
63
+ }[];
64
+ }>;
65
+ }
66
+ export {};
@@ -0,0 +1,28 @@
1
+ import { SSVKeysException } from '../exceptions/base';
2
+ import { ISharesKeyPairs } from '../interfaces';
3
+ export declare class ThresholdInvalidOperatorsLengthError extends SSVKeysException {
4
+ operators: number[];
5
+ constructor(operators: number[], message: string);
6
+ }
7
+ export declare class ThresholdInvalidOperatorIdError extends SSVKeysException {
8
+ operator: any;
9
+ constructor(operator: any, message: string);
10
+ }
11
+ /**
12
+ * Building threshold for list of operator IDs
13
+ */
14
+ declare class Threshold {
15
+ protected publicKey: any;
16
+ protected privateKey: any;
17
+ protected shares: Array<any>;
18
+ static get DEFAULT_THRESHOLD_NUMBER(): number;
19
+ /**
20
+ * Receives list of operators IDs.
21
+ * len(operator IDs) := 3 * F + 1
22
+ *
23
+ * If F calculated from this formula is not integer number - it will raise exception.
24
+ * Generate keys and return promise
25
+ */
26
+ create(privateKeyString: string, operatorIds: number[]): Promise<ISharesKeyPairs>;
27
+ }
28
+ export default Threshold;
@@ -0,0 +1,7 @@
1
+ export interface Shares {
2
+ privateKey: any;
3
+ publicKey: any;
4
+ signatures: any[];
5
+ ids: any[];
6
+ }
7
+ export declare const sharesSignatures: (_privateKey: string, operators: number[], message: string, isThreshold: boolean) => Promise<Shares>;
@@ -0,0 +1 @@
1
+ export { default as Threshold } from './Threshold';
@@ -0,0 +1,4 @@
1
+ export declare class SSVKeysException extends Error {
2
+ trace: any;
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,9 @@
1
+ import { SSVKeysException } from './base';
2
+ export declare class BLSDeserializeError extends SSVKeysException {
3
+ publicKey: string;
4
+ constructor(publicKey: string, message: string);
5
+ }
6
+ export declare class SingleSharesSignatureInvalid extends SSVKeysException {
7
+ data: string;
8
+ constructor(data: string, message: string);
9
+ }
@@ -0,0 +1,2 @@
1
+ export { OperatorPublicKeyError, OperatorsCountsMismatchError } from './operator';
2
+ export { SSVKeysException } from './base';
@@ -0,0 +1,5 @@
1
+ import { SSVKeysException } from './base';
2
+ export declare class KeySharesAbiDecodeError extends SSVKeysException {
3
+ data: any;
4
+ constructor(data: any, message: string);
5
+ }
@@ -0,0 +1,27 @@
1
+ import { SSVKeysException } from './base';
2
+ export declare class KeyStoreDataFormatError extends SSVKeysException {
3
+ data: any;
4
+ constructor(data: any, message: string);
5
+ }
6
+ export declare class KeyStoreInvalidError extends SSVKeysException {
7
+ data: any;
8
+ constructor(data: any, message: string);
9
+ }
10
+ export declare class KeyStorePasswordError extends SSVKeysException {
11
+ constructor(message: string);
12
+ }
13
+ export declare class EthereumWalletError extends SSVKeysException {
14
+ constructor(message: string);
15
+ }
16
+ export declare class PrivateKeyFormatError extends SSVKeysException {
17
+ data: any;
18
+ constructor(data: any, message: string);
19
+ }
20
+ export declare class OwnerAddressFormatError extends SSVKeysException {
21
+ data: any;
22
+ constructor(data: any, message: string);
23
+ }
24
+ export declare class OwnerNonceFormatError extends SSVKeysException {
25
+ data: any;
26
+ constructor(data: any, message: string);
27
+ }
@@ -0,0 +1,22 @@
1
+ import { SSVKeysException } from './base';
2
+ import { IOperatorData } from '../interfaces';
3
+ export declare class DuplicatedOperatorIdError extends SSVKeysException {
4
+ operator: IOperatorData;
5
+ constructor(operator: IOperatorData, message: string);
6
+ }
7
+ export declare class DuplicatedOperatorPublicKeyError extends SSVKeysException {
8
+ operator: IOperatorData;
9
+ constructor(operator: IOperatorData, message: string);
10
+ }
11
+ export declare class OperatorsCountsMismatchError extends SSVKeysException {
12
+ listOne: any[] | null | undefined;
13
+ listTwo: any[] | null | undefined;
14
+ constructor(propertyListOne: any[] | null | undefined, propertyListTwo: any[] | null | undefined, message: string);
15
+ }
16
+ export declare class OperatorPublicKeyError extends SSVKeysException {
17
+ operator: any;
18
+ constructor(operator: {
19
+ rsa: string;
20
+ base64: string | boolean;
21
+ }, message: string);
22
+ }
@@ -0,0 +1,7 @@
1
+ import { IOperator } from '../interfaces/IOperator.ts';
2
+ import { OperatorData } from '../KeyShares/KeySharesData/OperatorData';
3
+ /**
4
+ * Sort operators input.
5
+ * @param operators list
6
+ */
7
+ export declare const operatorSortedList: (operators: IOperator[]) => OperatorData[];
@@ -0,0 +1,36 @@
1
+ /**
2
+ * This function transforms an array of hexadecimal strings into a single Node.js Buffer.
3
+ * It employs viem.toBytes to convert each hex string into a Uint8Array, flattens them into a single array, and converts that to a Buffer.
4
+ *
5
+ * @param {string[]} hexArr - An array of hexadecimal strings. Each string can represent bytes of arbitrary length. *
6
+ * @returns {Buffer} - A Node.js Buffer that concatenates the bytes represented by the hexadecimal strings in the input array.
7
+ *
8
+ */
9
+ declare const hexArrayToBytes: (hexArr: string[]) => Buffer;
10
+ /**
11
+ * Asynchronously creates a BLS signature for given data using a private key.
12
+ *
13
+ * @param {string} dataToSign - The data to be signed.
14
+ * @param {string} privateKeyHex - Hexadecimal representation of the private key.
15
+ * @returns {Promise<string>} - A promise that resolves to the BLS signature in hexadecimal format.
16
+ *
17
+ * The function initializes the BLS library if needed, deserializes the private key from a hexadecimal string,
18
+ * computes the Keccak-256 hash of the data, signs the hashed data using the deserialized private key,
19
+ * and returns the signature in hexadecimal format, prefixed with '0x'.
20
+ */
21
+ declare const buildSignature: (dataToSign: string, privateKeyHex: string) => Promise<string>;
22
+ /**
23
+ * Asynchronously validates a BLS signature for given signed data.
24
+ *
25
+ * @param {string} signedData - Data that has been signed.
26
+ * @param {string} signatureHex - Hexadecimal representation of the BLS signature.
27
+ * @param {string} publicKey - Hexadecimal representation of the public key.
28
+ * @throws {SingleSharesSignatureInvalid} - Throws an error if the signature is invalid.
29
+ * @returns {Promise<void>} - Resolves when the signature is successfully verified.
30
+ *
31
+ * The function initializes the BLS library if needed, deserializes the public key and signature from hexadecimal strings,
32
+ * computes the Keccak-256 hash of the signed data, and verifies the signature using the deserialized public key.
33
+ */
34
+ declare const validateSignature: (signedData: string, signatureHex: string, publicKey: string) => Promise<void>;
35
+ export declare const privateToPublicKey: (privateKey: string) => Promise<string>;
36
+ export { hexArrayToBytes, buildSignature, validateSignature };
@@ -0,0 +1,4 @@
1
+ export { SSVKeys } from './SSVKeys';
2
+ export { KeySharesItem } from './KeyShares/KeySharesItem';
3
+ export { KeyShares } from './KeyShares/KeyShares';
4
+ export { SSVKeysException, OperatorPublicKeyError, OperatorsCountsMismatchError } from './exceptions';
@@ -0,0 +1,5 @@
1
+ export interface IEncryptShare {
2
+ operatorPublicKey: string;
3
+ privateKey: string;
4
+ publicKey: string;
5
+ }
@@ -0,0 +1,18 @@
1
+ import { IOperator } from './IOperator.ts';
2
+ import { IOperatorData } from './IOperatorData.ts';
3
+ export interface IKeySharesData {
4
+ ownerNonce?: number | null;
5
+ ownerAddress?: string | null;
6
+ publicKey?: string | null;
7
+ operators?: IOperatorData[] | null;
8
+ update(data: IKeySharesPartialData): void;
9
+ validate(): void;
10
+ get operatorIds(): number[];
11
+ get operatorPublicKeys(): string[];
12
+ }
13
+ export interface IKeySharesPartialData {
14
+ ownerNonce?: number | null;
15
+ ownerAddress?: string | null;
16
+ publicKey?: string | null;
17
+ operators?: IOperator[] | null;
18
+ }
@@ -0,0 +1,13 @@
1
+ export interface IKeySharesPayload {
2
+ sharesData: string;
3
+ publicKey: string;
4
+ operatorIds: number[];
5
+ update(data: any): any;
6
+ validate(): void;
7
+ build(data: any): any;
8
+ }
9
+ export interface IKeySharesPartialPayload {
10
+ sharesData: string;
11
+ publicKey: string;
12
+ operatorIds: number[];
13
+ }
@@ -0,0 +1,4 @@
1
+ export interface IOperator {
2
+ id: number;
3
+ operatorKey: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ export interface IOperatorData {
2
+ id: number | undefined;
3
+ operatorKey: string | undefined;
4
+ validate(): void;
5
+ }