@@ -7,15 +7,13 @@ import {
7
7
ClaimOptions ,
8
8
DID ,
9
9
DidMethod ,
10
- genesisFromEthAddress ,
11
10
getUnixTimestamp ,
12
11
Id ,
13
12
NetworkId ,
14
13
SchemaHash
15
14
} from '@iden3/js-iden3-core' ;
16
15
import { poseidon , PublicKey , sha256 , Signature , Hex , getRandomBytes } from '@iden3/js-crypto' ;
17
16
import { Hash , hashElems , ZERO_HASH } from '@iden3/js-merkletree' ;
18
-
19
17
import { generateProfileDID , subjectPositionIndex } from './common' ;
20
18
import * as uuid from 'uuid' ;
21
19
import { JSONSchema , JsonSchemaValidator , cacheLoader } from '../schema-processor' ;
@@ -44,15 +42,14 @@ import {
44
42
TreesModel
45
43
} from '../credentials' ;
46
44
import { TreeState } from '../circuits' ;
47
- import { byteEncoder } from '../utils' ;
45
+ import { buildDIDFromEthPubKey , byteEncoder } from '../utils' ;
48
46
import { Options } from '@iden3/js-jsonld-merklization' ;
49
47
import { TransactionReceipt } from 'ethers' ;
50
48
import {
51
49
CredentialStatusPublisherRegistry ,
52
50
Iden3SmtRhsCredentialStatusPublisher
53
51
} from '../credentials/status/credential-status-publisher' ;
54
52
import { ProofService } from '../proof' ;
55
- import { keccak256 } from 'js-sha3' ;
56
53
57
54
/**
58
55
* DID creation options
@@ -636,16 +633,7 @@ export class IdentityWallet implements IIdentityWallet {
636
633
637
634
const keyIdEth = await this . _kms . createKeyFromSeed ( KmsKeyType . Secp256k1 , opts . seed ) ;
638
635
const pubKeyHexEth = ( await this . _kms . publicKey ( keyIdEth ) ) . slice ( 2 ) ; // 04 + x + y (uncompressed key)
639
- // Use Keccak-256 hash function to get public key hash
640
- const hashOfPublicKey = keccak256 ( Buffer . from ( pubKeyHexEth , 'hex' ) ) ;
641
- // Convert hash to buffer
642
- const ethAddressBuffer = Buffer . from ( hashOfPublicKey , 'hex' ) ;
643
- // Ethereum Address is '0x' concatenated with last 20 bytes
644
- // of the public key hash
645
- const ethAddr = ethAddressBuffer . slice ( - 20 ) ;
646
- const genesis = genesisFromEthAddress ( ethAddr ) ;
647
- const identifier = new Id ( didType , genesis ) ;
648
- const did = DID . parseFromId ( identifier ) ;
636
+ const did = buildDIDFromEthPubKey ( didType , pubKeyHexEth ) ;
649
637
650
638
await this . _storage . mt . createIdentityMerkleTrees ( did . string ( ) ) ;
651
639
0 commit comments