Skip to content
Open
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
11 changes: 5 additions & 6 deletions examples/ts/key/auditKeyExample.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BitGoAPI } from '@bitgo/sdk-api';
import { Tltc } from '@bitgo/sdk-coin-ltc';
import * as sjcl from '@bitgo/sjcl';
require('dotenv').config({ path: '../../.env' });

const bitgo = new BitGoAPI({
Expand All @@ -16,11 +15,11 @@ async function main() {
const baseCoin = bitgo.coin(coin);
const keyPair = baseCoin.generateKeyPair();
const walletPassphrase = 'myStrongPassphrase';
const encryptedPrv = sjcl.encrypt(walletPassphrase, keyPair.prv);
const encryptedPrv = await bitgo.encrypt({ input: keyPair.prv, password: walletPassphrase });

// 2. Call the function with valid arguments so that the function validates the created key
try {
baseCoin.assertIsValidKey({
await baseCoin.assertIsValidKey({
encryptedPrv,
walletPassphrase,
publicKey: keyPair.pub,
Expand All @@ -32,7 +31,7 @@ async function main() {

// 3. Call the function with the incorrect passphrase, console log the captured error and explain it's the wrong password
try {
baseCoin.assertIsValidKey({
await baseCoin.assertIsValidKey({
encryptedPrv,
walletPassphrase: 'wrongPassphrase',
publicKey: keyPair.pub,
Expand All @@ -45,7 +44,7 @@ async function main() {
// 4. Call the function with a modified encryptedPrv, console log the captured error and explain that the prv is wrong
try {
const tamperedEncryptedPrv = encryptedPrv.slice(0, -1) + (encryptedPrv.slice(-1) === 'a' ? 'b' : 'a');
baseCoin.assertIsValidKey({
await baseCoin.assertIsValidKey({
encryptedPrv: tamperedEncryptedPrv,
walletPassphrase,
publicKey: keyPair.pub,
Expand All @@ -59,7 +58,7 @@ async function main() {
try {
// Generate a new key pair to get a different public key
const anotherKeyPair = baseCoin.generateKeyPair();
baseCoin.assertIsValidKey({
await baseCoin.assertIsValidKey({
encryptedPrv,
walletPassphrase,
publicKey: anotherKeyPair.pub, // mismatched public key
Expand Down
5 changes: 4 additions & 1 deletion modules/bitgo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export * from './bitgo';
/** @deprecated */
export { bitcoin } from '@bitgo/sdk-core';

/** @deprecated */
/**
* @deprecated SJCL is unmaintained and this export may be removed in a future major release.
* Use `bitgo.encrypt` / `bitgo.decrypt`, or native crypto, instead.
*/
export const sjcl = require('@bitgo/sjcl');

export { Buffer } from 'buffer';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@bitgo/abstract-eth": "^25.5.2",
"@bitgo/sdk-core": "^40.2.0",
"@bitgo/secp256k1": "^1.11.1",
"@bitgo/sjcl": "^1.1.0",
"@bitgo/statics": "^59.25.0",
"@ethereumjs/common": "^2.6.5",
"bignumber.js": "^9.1.2",
Expand All @@ -53,6 +52,7 @@
},
"devDependencies": {
"@bitgo/sdk-api": "^3.1.4",
"@bitgo/sjcl": "^1.1.0",
"@bitgo/sdk-test": "^9.1.89",
"secp256k1": "5.0.1"
},
Expand Down
1 change: 0 additions & 1 deletion modules/web-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"@bitgo/sdk-hmac": "^1.9.2",
"@bitgo/sdk-lib-mpc": "^11.6.0",
"@bitgo/sdk-opensslbytes": "^2.1.0",
"@bitgo/sjcl": "^1.1.0",
"@bitgo/statics": "^59.25.0",
"bitgo": "^54.2.2",
"lodash": "^4.18.0",
Expand Down
6 changes: 3 additions & 3 deletions modules/web-demo/src/components/KeyCard/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateKeycard } from '@bitgo/key-card';
import { KeyCurve, coins } from '@bitgo/statics';
import { Keychain } from '@bitgo/sdk-core';
import { DklsDkg, DklsTypes } from '@bitgo/sdk-lib-mpc';
import * as sjcl from '@bitgo/sjcl';
import { encrypt } from '@bitgo/sdk-api';

function downloadKeycardImage(coinFamily: string): Promise<HTMLImageElement> {
return new Promise<HTMLImageElement>((resolve, reject) => {
Expand Down Expand Up @@ -61,7 +61,7 @@ export async function downloadKeycardForDKLsTSS() {
const commonKeychain = DklsTypes.getCommonKeychain(userKeyShare);
const userCompressed = user.getReducedKeyShare();
const backupCompressed = backup.getReducedKeyShare();
const encryptedUser = sjcl.encrypt(
const encryptedUser = await encrypt(
't3stSicretly!',
btoa(
String.fromCharCode.apply(
Expand All @@ -70,7 +70,7 @@ export async function downloadKeycardForDKLsTSS() {
),
),
);
const encryptedBackup = sjcl.encrypt(
const encryptedBackup = await encrypt(
't3stSicretly!',
btoa(
String.fromCharCode.apply(
Expand Down
Loading