11import * as _ from 'lodash' ;
22import BigNumber from 'bignumber.js' ;
3+ import blake2b from '@bitgo/blake2b' ;
34import {
45 AuditDecryptedKeyParams ,
56 BaseCoin ,
@@ -19,7 +20,7 @@ import {
1920import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
2021import utils from './lib/utils' ;
2122import { bip32 } from '@bitgo/secp256k1' ;
22- import { randomBytes } from 'crypto' ;
23+ import { randomBytes , Hash } from 'crypto' ;
2324import { KeyPair as EthKeyPair } from '@bitgo/abstract-eth' ;
2425import { TransactionBuilderFactory } from './lib' ;
2526import { ExplainTransactionOptions , VetParseTransactionOptions } from './lib/types' ;
@@ -216,4 +217,24 @@ export class Vet extends BaseCoin {
216217 /** https://bitgoinc.atlassian.net/browse/COIN-4213 */
217218 throw new Error ( 'Method not implemented.' ) ;
218219 }
220+
221+ /**
222+ * Function to get coin specific hash function used to generate transaction digests.
223+ * @returns {@see Hash } hash function if implemented, otherwise throws exception
224+ */
225+ getHashFunction ( ) : Hash {
226+ const blake = blake2b ( 32 ) ;
227+
228+ // We return an object that mimics the Hash interface
229+ return {
230+ update ( data : Buffer | Uint8Array ) {
231+ blake . update ( data ) ;
232+ return this ;
233+ } ,
234+ digest ( ) {
235+ const uint8Result = blake . digest ( ) ;
236+ return Buffer . from ( uint8Result ) ;
237+ } ,
238+ } as unknown as Hash ;
239+ }
219240}
0 commit comments