-
Notifications
You must be signed in to change notification settings - Fork 184
feat: change to gcp attestation verification #959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
a67fbd1
8e4aadb
cbe77f6
ac17f78
52a63ae
afb87f0
c28f03e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,10 @@ import { | |
| getCircuitNameFromPassportData, | ||
| getSolidityPackedUserContextData, | ||
| } from '@selfxyz/common/utils'; | ||
| import { getPublicKey, verifyAttestation } from '@selfxyz/common/utils/attest'; | ||
| import { | ||
| checkPCR0Mapping, | ||
| validatePKIToken, | ||
| } from '@selfxyz/common/utils/attest'; | ||
| import { | ||
| clientKey, | ||
| clientPublicKeyHex, | ||
|
|
@@ -336,9 +339,25 @@ export const useProvingStore = create<ProvingState>((set, get) => { | |
| trackEvent(ProofEvents.ATTESTATION_RECEIVED); | ||
| const attestationData = result.result.attestation; | ||
| set({ attestation: attestationData }); | ||
| const attestationToken = | ||
| Buffer.from(attestationData).toString('utf-8'); | ||
|
|
||
| const { userPubkey, serverPubkey, imageHash, verified } = | ||
| validatePKIToken(attestationToken, __DEV__); | ||
|
|
||
| const pcr0Mapping = await checkPCR0Mapping(imageHash); | ||
|
|
||
| if (!pcr0Mapping) { | ||
| console.error('PCR0 mapping not found'); | ||
| actor!.send({ type: 'CONNECT_ERROR' }); | ||
| return; | ||
| } | ||
|
|
||
Nesopie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const serverPubkey = getPublicKey(attestationData); | ||
| const verified = await verifyAttestation(attestationData); | ||
| if (clientPublicKeyHex !== userPubkey.toString('hex')) { | ||
| console.error('User public key does not match'); | ||
| actor!.send({ type: 'CONNECT_ERROR' }); | ||
| return; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Key Format Mismatch Blocks TEE ConnectionsThe public key comparison at line 559 can incorrectly fail because |
||
|
|
||
Nesopie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!verified) { | ||
| console.error('Attestation verification failed'); | ||
|
|
@@ -348,11 +367,11 @@ export const useProvingStore = create<ProvingState>((set, get) => { | |
|
|
||
| trackEvent(ProofEvents.ATTESTATION_VERIFIED); | ||
|
|
||
| const serverKey = ec.keyFromPublic(serverPubkey as string, 'hex'); | ||
| const serverKey = ec.keyFromPublic(serverPubkey, 'hex'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| const derivedKey = clientKey.derive(serverKey.getPublic()); | ||
|
|
||
| set({ | ||
| serverPublicKey: serverPubkey, | ||
| serverPublicKey: serverKey.getPublic(true, 'hex'), | ||
| sharedKey: Buffer.from(derivedKey.toArray('be', 32)), | ||
| }); | ||
Nesopie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| trackEvent(ProofEvents.SHARED_KEY_DERIVED); | ||
|
|
@@ -541,10 +560,7 @@ export const useProvingStore = create<ProvingState>((set, get) => { | |
| method: 'openpassport_hello', | ||
| id: 1, | ||
| params: { | ||
| user_pubkey: [ | ||
| 4, | ||
| ...Array.from(Buffer.from(clientPublicKeyHex, 'hex')), | ||
| ], | ||
| user_pubkey: [...Array.from(Buffer.from(clientPublicKeyHex, 'hex'))], | ||
| uuid: connectionUuid, | ||
| }, | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.