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 bs58 import #156

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/helpers/keyUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { INodePub, KEY_TYPE } from "@toruslabs/constants";
import { Ecies, encrypt } from "@toruslabs/eccrypto";
import BN from "bn.js";
import base58 from "bs58";
import * as base58 from "bs58";
import { curve, ec as EC } from "elliptic";
import { keccak256 as keccakHash } from "ethereum-cryptography/keccak";
import { sha512 } from "ethereum-cryptography/sha512";
Expand Down Expand Up @@ -142,7 +142,7 @@ function generateAddressFromEcKey(keyType: KeyType, key: EC.KeyPair): string {
return toChecksumAddress(evmAddressLower);
} else if (keyType === KEY_TYPE.ED25519) {
const publicKey = encodeEd25519Point(key.getPublic());
const address = base58.encode(publicKey);
const address = base58.default.encode(publicKey);
return address;
}
throw new Error(`Invalid keyType: ${keyType}`);
Expand Down
64 changes: 32 additions & 32 deletions test/sapphire_devnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,30 +777,30 @@ describe("torus utils sapphire devnet", function () {
const nodeDetails2 = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails2);
const torusNodeEndpoints1 = nodeDetails1.torusNodeSSSEndpoints;
const torusNodeEndpoints2 = nodeDetails1.torusNodeSSSEndpoints;
const result1 = await torus.retrieveShares(
torusNodeEndpoints1,
nodeDetails1.torusIndexes,
TORUS_TEST_AGGREGATE_VERIFIER,
{
const result1 = await torus.retrieveShares({
endpoints: torusNodeEndpoints1,
indexes: nodeDetails1.torusIndexes,
verifier: TORUS_TEST_AGGREGATE_VERIFIER,
verifierParams: {
verify_params: [{ verifier_id: email1, idtoken: idToken1 }],
sub_verifier_ids: [TORUS_TEST_VERIFIER],
verifier_id: email1,
},
hashedIdToken1.substring(2),
nodeDetails1.torusNodePub
);
const result2 = await torus.retrieveShares(
torusNodeEndpoints2,
nodeDetails2.torusIndexes,
TORUS_TEST_AGGREGATE_VERIFIER,
{
idToken: hashedIdToken1.substring(2),
nodePubkeys: nodeDetails1.torusNodePub,
});
const result2 = await torus.retrieveShares({
endpoints: torusNodeEndpoints2,
indexes: nodeDetails2.torusIndexes,
verifier: TORUS_TEST_AGGREGATE_VERIFIER,
verifierParams: {
verify_params: [{ verifier_id: email2, idtoken: idToken2 }],
sub_verifier_ids: [TORUS_TEST_VERIFIER],
verifier_id: email2,
},
hashedIdToken2.substring(2),
nodeDetails2.torusNodePub
);
idToken: hashedIdToken2.substring(2),
nodePubkeys: nodeDetails2.torusNodePub,
});
expect(result1.metadata.serverTimeOffset).lessThan(20);

expect(result1.finalKeyData.walletAddress).to.not.equal(null);
Expand Down Expand Up @@ -833,18 +833,18 @@ describe("torus utils sapphire devnet", function () {

const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.retrieveShares(
torusNodeEndpoints,
nodeDetails.torusIndexes,
TORUS_TEST_AGGREGATE_VERIFIER,
{
const result = await torus.retrieveShares({
endpoints: torusNodeEndpoints,
indexes: nodeDetails.torusIndexes,
verifier: TORUS_TEST_AGGREGATE_VERIFIER,
verifierParams: {
verify_params: [{ verifier_id: email, idtoken: idToken }],
sub_verifier_ids: [TORUS_TEST_VERIFIER],
verifier_id: email,
},
hashedIdToken.substring(2),
nodeDetails.torusNodePub
);
idToken: hashedIdToken.substring(2),
nodePubkeys: nodeDetails.torusNodePub,
});
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

Expand Down Expand Up @@ -873,18 +873,18 @@ describe("torus utils sapphire devnet", function () {

const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.retrieveShares(
torusNodeEndpoints,
nodeDetails.torusIndexes,
TORUS_TEST_AGGREGATE_VERIFIER,
{
const result = await torus.retrieveShares({
endpoints: torusNodeEndpoints,
indexes: nodeDetails.torusIndexes,
verifier: TORUS_TEST_AGGREGATE_VERIFIER,
verifierParams: {
verify_params: [{ verifier_id: email, idtoken: idToken }],
sub_verifier_ids: [TORUS_TEST_VERIFIER],
verifier_id: email,
},
hashedIdToken.substring(2),
nodeDetails.torusNodePub
);
idToken: hashedIdToken.substring(2),
nodePubkeys: nodeDetails.torusNodePub,
});
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

Expand Down
4 changes: 2 additions & 2 deletions test/sapphire_devnet_ed25519.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants";
import { NodeDetailManager } from "@toruslabs/fetch-node-details";
import BN from "bn.js";
import base58 from "bs58";
import * as base58 from "bs58";
import { expect } from "chai";
import faker from "faker";

Expand Down Expand Up @@ -74,7 +74,7 @@ describe("torus utils ed25519 sapphire devnet", function () {
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails({ verifier: TORUS_TEST_VERIFIER, verifierId: email });
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;

const decodedKey = Buffer.from(base58.decode(privB58));
const decodedKey = Buffer.from(base58.default.decode(privB58));
const seedKey = decodedKey.subarray(0, 32).toString("hex");
const result = await torus.importPrivateKey(
getImportKeyParams(
Expand Down