Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix utility func usage #67

Merged
merged 10 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/esbuild/main.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/esbuild/main.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions dist/tsc/src/lib/KeyShares/KeyShares.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tsc/src/lib/KeyShares/KeyShares.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/tsc/src/lib/KeyShares/KeySharesItem.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tsc/src/lib/KeyShares/KeySharesItem.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/lib/KeyShares/KeyShares.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import semver from 'semver';
import pkg from '../../../package.json';

import { IsOptional, ValidateNested, validateSync } from 'class-validator';

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (ubuntu-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_macos (macos-latest)

'ValidateNested' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'IsOptional' is defined but never used

Check warning on line 4 in src/lib/KeyShares/KeyShares.ts

View workflow job for this annotation

GitHub Actions / release_linux (windows-latest)

'ValidateNested' is defined but never used
import { KeySharesItem } from './KeySharesItem';
import { SSVKeysException } from '../../lib/exceptions/base';
import { SSVKeysException } from '../exceptions/base';

/**
* Represents a collection of KeyShares items with functionality for serialization,
Expand Down Expand Up @@ -60,11 +60,12 @@
const body = typeof content === 'string' ? JSON.parse(content) : content;
const extVersion = semver.parse(body.version);
const currentVersion = semver.parse(pkg.version);
const tmpPrevVersion = semver.parse('v1.1.0');

if (!extVersion || !currentVersion) {
if (!extVersion || !currentVersion || !tmpPrevVersion) {
throw new SSVKeysException(`The file for keyshares must contain a version mark provided by ssv-keys.`);
}
if (!extVersion || (currentVersion.major !== extVersion.major) || (currentVersion.minor !== extVersion.minor)) {
if (!extVersion || (currentVersion.major !== extVersion.major) || (currentVersion.minor !== extVersion.minor && tmpPrevVersion.minor !== extVersion.minor)) {
throw new SSVKeysException(`The keyshares file you are attempting to reuse does not have the same version (v${pkg.version}) as supported by ssv-keys`);
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/KeyShares/KeySharesItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ export class KeySharesItem {
const sharesPt = bytes.replace('0x', '').substring(SIGNATURE_LENGHT);

const pkSplit = sharesPt.substring(0, operatorCount * PUBLIC_KEY_LENGHT);
const pkArray = arrayify(pkSplit);
console.log(pkSplit);
const pkArray = arrayify('0x' + pkSplit);
const sharesPublicKeys = this.splitArray(operatorCount, pkArray)
.map(item => hexlify(item));

const eSplit = bytes.substring(operatorCount * PUBLIC_KEY_LENGHT);
const eArray = arrayify(eSplit);
const eArray = arrayify('0x' + eSplit);
const encryptedKeys = this.splitArray(operatorCount, eArray).map(item =>
Buffer.from(hexlify(item).replace('0x', ''), 'hex').toString(
'base64',
Expand Down
Loading