33 BaseCoin ,
44 BaseTransaction ,
55 BitGoBase ,
6+ InvalidAddressError ,
67 KeyPair ,
78 MPCAlgorithm ,
89 MultisigType ,
@@ -15,6 +16,9 @@ import {
1516} from '@bitgo/sdk-core' ;
1617import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics' ;
1718import utils from './lib/utils' ;
19+ import { bip32 } from '@bitgo/secp256k1' ;
20+ import { randomBytes } from 'crypto' ;
21+ import { KeyPair as EthKeyPair } from '@bitgo/abstract-eth' ;
1822
1923/**
2024 * Full Name: Vechain
@@ -79,7 +83,12 @@ export class Vet extends BaseCoin {
7983 }
8084
8185 async isWalletAddress ( params : VerifyAddressOptions ) : Promise < boolean > {
82- throw new Error ( 'Method not implemented' ) ;
86+ const { address : newAddress } = params ;
87+
88+ if ( ! this . isValidAddress ( newAddress ) ) {
89+ throw new InvalidAddressError ( `invalid address: ${ newAddress } ` ) ;
90+ }
91+ return true ;
8392 }
8493
8594 async parseTransaction ( ) : Promise < ParsedTransaction > {
@@ -95,11 +104,28 @@ export class Vet extends BaseCoin {
95104 }
96105
97106 generateKeyPair ( seed ?: Buffer ) : KeyPair {
98- throw new Error ( 'Method not implemented' ) ;
107+ if ( ! seed ) {
108+ // An extended private key has both a normal 256 bit private key and a 256
109+ // bit chain code, both of which must be random. 512 bits is therefore the
110+ // maximum entropy and gives us maximum security against cracking.
111+ seed = randomBytes ( 512 / 8 ) ;
112+ }
113+ const extendedKey = bip32 . fromSeed ( seed ) ;
114+ const xpub = extendedKey . neutered ( ) . toBase58 ( ) ;
115+ return {
116+ pub : xpub ,
117+ prv : extendedKey . toBase58 ( ) ,
118+ } ;
99119 }
100120
101121 isValidPub ( pub : string ) : boolean {
102- throw new Error ( 'Method not implemented.' ) ;
122+ let valid = true ;
123+ try {
124+ new EthKeyPair ( { pub } ) ;
125+ } catch ( e ) {
126+ valid = false ;
127+ }
128+ return valid ;
103129 }
104130
105131 isValidAddress ( address : string ) : boolean {
0 commit comments