feat: use crypto-hash instead of hasha
This commit is contained in:
committed by
Michael Vines
parent
bd7e802e46
commit
402c160ae9
@@ -2,7 +2,7 @@
|
||||
|
||||
import BN from 'bn.js';
|
||||
import bs58 from 'bs58';
|
||||
import hasha from 'hasha';
|
||||
import {sha256} from 'crypto-hash';
|
||||
|
||||
/**
|
||||
* A public key
|
||||
@@ -80,17 +80,17 @@ export class PublicKey {
|
||||
/**
|
||||
* Derive a public key from another key, a seed, and a programId.
|
||||
*/
|
||||
static createWithSeed(
|
||||
static async createWithSeed(
|
||||
fromPublicKey: PublicKey,
|
||||
seed: string,
|
||||
programId: PublicKey,
|
||||
): PublicKey {
|
||||
): Promise<PublicKey> {
|
||||
const buffer = Buffer.concat([
|
||||
fromPublicKey.toBuffer(),
|
||||
Buffer.from(seed),
|
||||
programId.toBuffer(),
|
||||
]);
|
||||
const hash = hasha(buffer, {algorithm: 'sha256'});
|
||||
const hash = await sha256(new Uint8Array(buffer));
|
||||
return new PublicKey('0x' + hash);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user