Skip to content

Commit

Permalink
refactor: Add isCryptoKey function to check crypto key
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Apr 24, 2024
1 parent b4d20cd commit dfd99ca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/privateRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import crypto from 'crypto';
import type { PrivateState } from '../types';
import { getActivePublicKey } from './arweaveHelper';
import { getWallet, initArweave } from './common';
import { isCryptoKey } from 'util/types';

const arweave = initArweave();

function isCryptoKey(obj: any) {
try {
// @ts-ignore
return obj instanceof CryptoKey;
} catch (e) {
return obj instanceof crypto.webcrypto.CryptoKey;
}
}

async function deriveAddress(publicKey: string) {
const pubKeyBuf = arweave.utils.b64UrlToBuffer(publicKey);
const sha512DigestBuf = await crypto.subtle.digest('SHA-512', pubKeyBuf);
Expand Down

0 comments on commit dfd99ca

Please sign in to comment.