Skip to content

Commit

Permalink
Use correct sha3 import (#4569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Mysten authored Sep 13, 2022
1 parent 7485592 commit 1665a55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions sdk/typescript/src/cryptography/ed25519-publickey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

import BN from 'bn.js';
import { Buffer } from 'buffer';
import { sha3_256 } from 'js-sha3';
import { checkPublicKeyData, PublicKeyInitData, SIGNATURE_SCHEME_TO_FLAG } from './publickey';
import sha3 from 'js-sha3';
import {
checkPublicKeyData,
PublicKeyInitData,
SIGNATURE_SCHEME_TO_FLAG,
} from './publickey';

const PUBLIC_KEY_SIZE = 32;

Expand Down Expand Up @@ -92,6 +96,6 @@ export class Ed25519PublicKey {
let tmp = new Uint8Array(PUBLIC_KEY_SIZE + 1);
tmp.set([SIGNATURE_SCHEME_TO_FLAG['ED25519']]);
tmp.set(this.toBytes(), 1);
return sha3_256(tmp).slice(0, 40);
return sha3.sha3_256(tmp).slice(0, 40);
}
}
11 changes: 8 additions & 3 deletions sdk/typescript/src/cryptography/secp256k1-publickey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@

import BN from 'bn.js';
import { Buffer } from 'buffer';
import { sha3_256 } from 'js-sha3';
import { checkPublicKeyData, PublicKey, PublicKeyInitData, SIGNATURE_SCHEME_TO_FLAG } from './publickey';
import sha3 from 'js-sha3';
import {
checkPublicKeyData,
PublicKey,
PublicKeyInitData,
SIGNATURE_SCHEME_TO_FLAG,
} from './publickey';

const SECP256K1_PUBLIC_KEY_SIZE = 33;

Expand Down Expand Up @@ -92,6 +97,6 @@ export class Secp256k1PublicKey implements PublicKey {
let tmp = new Uint8Array(SECP256K1_PUBLIC_KEY_SIZE + 1);
tmp.set([SIGNATURE_SCHEME_TO_FLAG['Secp256k1']]);
tmp.set(this.toBytes(), 1);
return sha3_256(tmp).slice(0, 40);
return sha3.sha3_256(tmp).slice(0, 40);
}
}

0 comments on commit 1665a55

Please sign in to comment.