Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #463 from AztecProtocol/feat-fix-aztec-sig
Browse files Browse the repository at this point in the history
feat(sdk): fix
  • Loading branch information
Joe Andrews authored Jan 31, 2020
2 parents 3cb88c7 + bde9d52 commit 8dea0a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ const AZTECAccount = [
name: 'linkedPublicKey',
type: 'bytes',
},
{
name: 'AZTECaddress',
type: 'address',
},
];

export default ({
address,
linkedPublicKey,
aliasAddress,
}) => {
const accountRegistryContract = Web3Service.contract('AccountRegistry');

Expand All @@ -40,6 +45,7 @@ export default ({

const message = {
account: address,
AZTECaddress: aliasAddress,
linkedPublicKey,
};

Expand All @@ -59,6 +65,7 @@ export default ({
export const generateTypedData = ({
address,
linkedPublicKey,
aliasAddress,
}) => {
const accountRegistryContract = Web3Service.contract('AccountRegistry');

Expand All @@ -70,9 +77,18 @@ export const generateTypedData = ({

const message = {
account: address,
AZTECaddress: aliasAddress,
linkedPublicKey,
};

console.log({
types: {
EIP712Domain: domainParams,
AZTECAccount,
},
domain: domainData,
primaryType: 'AZTECAccount',
message,
});
return {
types: {
EIP712Domain: domainParams,
Expand Down
12 changes: 12 additions & 0 deletions packages/extension/src/ui/apis/auth/linkAccountToMetaMask.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import secp256k1 from '@aztec/secp256k1';
import decodePrivateKey from '~/background/utils/decodePrivateKey';
import AuthService from '~/background/services/AuthService';
import ConnectionService from '~/ui/services/ConnectionService';

export default async function linkAccountToMetaMask({
address,
linkedPublicKey,
}) {
const keyStore = await AuthService.getKeyStore();
const {
pwDerivedKey,
} = await AuthService.getSession(address) || {};
const privateKey = '0x'.concat(decodePrivateKey(keyStore, pwDerivedKey));
const {
address: aliasAddress,
} = secp256k1.accountFromPrivateKey(privateKey);
const {
publicKey: spendingPublicKey,
signature,
Expand All @@ -13,6 +24,7 @@ export default async function linkAccountToMetaMask({
data: {
address,
linkedPublicKey,
aliasAddress,
},
}) || {};

Expand Down

0 comments on commit 8dea0a5

Please sign in to comment.