Skip to content

Commit

Permalink
fix guardian
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Apr 3, 2024
1 parent d1a8f04 commit 26913e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/storage/blockchain/state.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RootInfo, StateProof } from './../entities/state';
import { ZKProof } from '@iden3/js-jwz';
import { IStateStorage, UserStateTransitionInfo } from '../interfaces/state';
import { Contract, ContractTransaction, JsonRpcProvider, Signer, TransactionRequest } from 'ethers';
import { Contract, JsonRpcProvider, Signer, TransactionRequest } from 'ethers';
import { StateInfo } from '../entities/state';
import { StateTransitionPubSignals } from '../../circuits';
import { byteEncoder } from '../../utils';
Expand Down Expand Up @@ -165,7 +165,8 @@ export class EthStateStorage implements IStateStorage {
signer: Signer,
userStateTranstionInfo: UserStateTransitionInfo
): Promise<string> {
const { userId, oldUserState, newUserState, isOldStateGenesis, methodId, methodParams } = userStateTranstionInfo;
const { userId, oldUserState, newUserState, isOldStateGenesis, methodId, methodParams } =
userStateTranstionInfo;
const { stateContract, provider } = this.getStateContractAndProviderForId(userId.bigInt());
const contract = stateContract.connect(signer) as Contract;
const feeData = await provider.getFeeData();
Expand Down
18 changes: 3 additions & 15 deletions tests/utils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { expect } from 'chai';
import {
AbstractPrivateKeyStore,
buildDIDFromEthPubKey,
InMemoryPrivateKeyStore,
JSONObject,
KmsKeyType,
mergeObjects,
Sec256k1Provider
} from '../../src';
import { buildDIDFromEthPubKey, JSONObject, mergeObjects } from '../../src';
import { Blockchain, buildDIDType, DidMethod, NetworkId } from '@iden3/js-iden3-core';

describe('merge credential subjects to create query', () => {
Expand Down Expand Up @@ -161,12 +153,8 @@ describe('merge credential subjects to create query', () => {

describe('build did from ethereum public key', () => {
it.only('should build did from ethereum public key correctly', async () => {
const privateKey = 'ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const keyStore: AbstractPrivateKeyStore = new InMemoryPrivateKeyStore();
const secp256k1 = new Sec256k1Provider(KmsKeyType.Secp256k1, keyStore);
const keyIdEth = await secp256k1.newPrivateKeyFromSeed(Buffer.from(privateKey, 'hex'));
const pubKeyHexEth = (await secp256k1.publicKey(keyIdEth)).slice(2); // 04 + x + y (uncompressed key)

const pubKeyHexEth =
'8318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5';
const didType = buildDIDType(DidMethod.Iden3, Blockchain.Polygon, NetworkId.Amoy);
const did = buildDIDFromEthPubKey(didType, pubKeyHexEth);

Expand Down

0 comments on commit 26913e9

Please sign in to comment.