Skip to content

Commit

Permalink
Merge pull request #28 from fireblocks/eddsa-support
Browse files Browse the repository at this point in the history
Eddsa support
  • Loading branch information
yuval-fireblocks authored Apr 11, 2024
2 parents 6198c86 + 73e279a commit 235f739
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 25 deletions.
9 changes: 1 addition & 8 deletions .env
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
# VITE_AUTOMATE_INITIALIZATION=true

# SANDBOX
VITE_BACKEND_BASE_URL=https://ncw-demo-dev.2uaqu5aka49io.eu-central-1.cs.amazonlightsail.com
VITE_BACKEND_BASE_URL=https://api-sb.ncw-demo.com
VITE_NCW_SDK_ENV=sandbox
VITE_CLOUDKIT_APITOKEN=18be8b0ef50c77b1adf9b3795948806d4ee3e1fb23a3d30ee6bd672d2db21a56
VITE_CLOUDKIT_CONTAINER_ID=iCloud.com.fireblocks.ncw.demo
VITE_CLOUDKIT_ENV=production

# DEV9
# VITE_BACKEND_BASE_URL=https://dev9-ncw-demo.waterballoons.xyz
# VITE_NCW_SDK_ENV=dev9
# VITE_CLOUDKIT_APITOKEN=572a0b5cfcb8992031640d1a14fd0ac3bb7c774cc929a0e23cb00af415da51cd
# VITE_CLOUDKIT_CONTAINER_ID=iCloud.com.fireblocks.ncw.demo
# VITE_CLOUDKIT_ENV=development
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"preview": "vite preview"
},
"dependencies": {
"@fireblocks/ncw-js-sdk": "12.0.0",
"@fireblocks/ncw-js-sdk": "12.1.1",
"base58-js": "^2.0.0",
"classnames": "^2.3.2",
"js-base64": "^3.7.5",
Expand Down
10 changes: 9 additions & 1 deletion src/AppStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,19 @@ export const useAppStore = create<IAppState>()((set, get) => {

set((state) => ({ ...state, web3Connections: state.web3Connections.filter((s) => s.id !== sessionId) }));
},
/**
* By default, workspaces are not enabled with EdDSA so you may remove `MPC_CMP_EDDSA_ED25519` when calling generateMPCKeys
* Please ask your CSM or in the https://community.fireblocks.com/ to enable your workspace to support EdDSA if you wish to work with EdDSA chains.
*/
generateMPCKeys: async () => {
if (!fireblocksNCW) {
throw new Error("fireblocksNCW is not initialized");
}
const ALGORITHMS = new Set<TMPCAlgorithm>(["MPC_CMP_ECDSA_SECP256K1"]);
const ALGORITHMS = new Set<TMPCAlgorithm>([
//
"MPC_CMP_ECDSA_SECP256K1",
"MPC_CMP_EDDSA_ED25519",
]);
await fireblocksNCW.generateMPCKeys(ALGORITHMS);
},
stopMpcDeviceSetup: async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/BackupAndRecover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const BackupAndRecover: React.FC = () => {
};

const secP256K1Status = keysStatus?.MPC_CMP_ECDSA_SECP256K1?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_EDDSA_ED25519?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_CMP_EDDSA_ED25519?.keyStatus ?? null;
const hasReadyAlgo = secP256K1Status === "READY" || ed25519Status === "READY";

const googleBackupAction: ICardAction = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FireblocksNCWExampleActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Logs } from "./Logs";
export const FireblocksNCWExampleActions: React.FC = () => {
const { keysStatus, joinExistingWalletMode } = useAppStore();
const secP256K1Status = keysStatus?.MPC_CMP_ECDSA_SECP256K1?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_EDDSA_ED25519?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_CMP_EDDSA_ED25519?.keyStatus ?? null;

const hasAKey = secP256K1Status === "READY" || ed25519Status === "READY";

Expand Down
20 changes: 18 additions & 2 deletions src/components/GenerateMPCKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const GenerateMPCKeys: React.FC = () => {
};

const secP256K1Status = keysStatus?.MPC_CMP_ECDSA_SECP256K1?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_CMP_EDDSA_ED25519?.keyStatus ?? null;
const statusToProgress = (status: TKeyStatus | null) => {
switch (status) {
case "INITIATED":
Expand All @@ -60,11 +61,12 @@ export const GenerateMPCKeys: React.FC = () => {
}
};
const secP256K1Ready = secP256K1Status === "READY";
const ed25519Ready = ed25519Status === "READY";

const generateAction: IActionButtonProps = {
label: "Generate MPC Keys",
action: doGenerateMPCKeys,
isDisabled: isGenerateInProgress || secP256K1Ready,
isDisabled: isGenerateInProgress || (secP256K1Ready && ed25519Ready),
isInProgress: isGenerateInProgress,
};

Expand All @@ -78,7 +80,7 @@ export const GenerateMPCKeys: React.FC = () => {
const approveJoinWalletAction: IActionButtonProps = {
label: "Approve Joining Wallet",
action: approveJoinWallet,
isDisabled: (isStopInProgress || isGenerateInProgress) && secP256K1Ready,
isDisabled: (isStopInProgress || isGenerateInProgress) && (ed25519Ready || secP256K1Ready),
};
const stopApproveWalletAction: IActionButtonProps = {
label: "Stop Join Process",
Expand Down Expand Up @@ -119,6 +121,20 @@ export const GenerateMPCKeys: React.FC = () => {
</td>
</tr>
</tbody>
<tbody>
<tr>
<th>
<span className="label-text">EDDSA ED25519</span>
</th>
<td colSpan={5}>
<progress
className="progress progress-primary"
value={statusToProgress(ed25519Status)}
max="100"
></progress>
</td>
</tr>
</tbody>
</table>
</div>
{generateMPCKeysResult && (
Expand Down
16 changes: 16 additions & 0 deletions src/components/JoinExistingWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const JoinExistingWallet: React.FC = () => {
};

const secP256K1Status = keysStatus?.MPC_CMP_ECDSA_SECP256K1?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_CMP_EDDSA_ED25519?.keyStatus ?? null;
const statusToProgress = (status: TKeyStatus | null) => {
switch (status) {
case "INITIATED":
Expand All @@ -53,6 +54,7 @@ export const JoinExistingWallet: React.FC = () => {
}
};
const secP256K1Ready = secP256K1Status === "READY";
const ed25519Ready = secP256K1Status === "READY";

const generateAction: IActionButtonProps = {
label: "Join",
Expand Down Expand Up @@ -105,6 +107,20 @@ export const JoinExistingWallet: React.FC = () => {
</td>
</tr>
</tbody>
<tbody>
<tr>
<th>
<span className="label-text">ECDSA ED25519</span>
</th>
<td colSpan={5}>
<progress
className="progress progress-primary"
value={statusToProgress(ed25519Status)}
max="100"
></progress>
</td>
</tr>
</tbody>
</table>
</div>
{joinExistingWalletResult && (
Expand Down
6 changes: 4 additions & 2 deletions src/services/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ export class ApiService {
body: JSON.stringify(body ?? {}),
});

const responseJson = await response.json();
if (!response.ok) {
throw new Error(`A call to "${path}" failed with status ${response.status}`);
throw new Error(
`A call to "${path}" failed with status ${response.status}, data: ${JSON.stringify(responseJson)}`,
);
}
const responseJson = await response.json();
return responseJson;
}

Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,19 @@
resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.10.5.tgz#cd9897680d0a2f1bce8d8c23a590e5874f4617c5"
integrity sha512-eSkJsnhBWv5kCTSU1tSUVl9mpFu+5NXXunZc83le8GMjMlsWwQArSc7cJJ4yl+aDFY0NGLi0AjZWMn1axOrkRg==

"@fireblocks/[email protected].17":
version "1.0.17"
resolved "https://registry.yarnpkg.com/@fireblocks/ncw-js-infra/-/ncw-js-infra-1.0.17.tgz#e7de3e3c9d2da37dd3e30ef0b4a9044ef7da6d8a"
integrity sha512-nhg5fGGG1DkEz7DA7Qz46S+fqf2fKNHhxxUwabMEm8u18pzs3eeI232ZYXBE26tx/6MEbzMXFQyk14DnWLCJcQ==
"@fireblocks/[email protected].19":
version "1.0.19"
resolved "https://registry.yarnpkg.com/@fireblocks/ncw-js-infra/-/ncw-js-infra-1.0.19.tgz#b95ce94c930b9d89565164138b17e5531662d4cd"
integrity sha512-ROogCO7li4Ouevunm4sBiw/4hNuUxynxNPSUymKPV3GrKJBSRaTp6+/KXnDkYG2PHW3vlowE/ndKXSMVx1wUEg==
dependencies:
"@types/emscripten" "^1.39.7"

"@fireblocks/ncw-js-sdk@12.0.0":
version "12.0.0"
resolved "https://registry.yarnpkg.com/@fireblocks/ncw-js-sdk/-/ncw-js-sdk-12.0.0.tgz#7754ac7251910c27e757ac7129abab853486a3b4"
integrity sha512-UOWOY30JQeJBBqpEgZ6+HwbCOAaSatK+M6HkA9FSdqdvknwL4uo5cvf5pRboIuASX82EK3+oEF+hcAShmvFaQQ==
"@fireblocks/ncw-js-sdk@12.1.1":
version "12.1.1"
resolved "https://registry.yarnpkg.com/@fireblocks/ncw-js-sdk/-/ncw-js-sdk-12.1.1.tgz#8657cc4c5d774bcb0e5edc92d4c893c2b938d4d8"
integrity sha512-IDO7rRxLUxCOMCA7qa9GKAUKegzwQ92kI5MRQ38kIpAwDbqLj7pANoCn+Modb2OJN57yHwbXVjdDH8wcoWc+7Q==
dependencies:
"@fireblocks/ncw-js-infra" "1.0.17"
"@fireblocks/ncw-js-infra" "1.0.19"
jwt-decode "^3.1.2"
node-forge "^1.3.1"

Expand Down

0 comments on commit 235f739

Please sign in to comment.