Skip to content

Commit 898afd3

Browse files
committed
refactor!: rename didResolveKey param to dereferenceDidUrl
1 parent 259528e commit 898afd3

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/messaging/interface/attestation/response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function requestAttestation(
7979
const { did: receiver } = Did.parse(receiverEncryptionKeyUri)
8080

8181
if (attesterQuote) {
82-
verifyAttesterSignedQuote(attesterQuote, { didResolveKey: dereferenceDidUrl })
82+
verifyAttesterSignedQuote(attesterQuote, { dereferenceDidUrl })
8383

8484
quote = await createQuoteAgreement(attesterQuote, rootHash, authenticationSigner, sender, {
8585
dereferenceDidUrl,

src/quote/Quote.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
* @packageDocumentation
1616
*/
1717

18-
import type { ICredential, Did, SignerInterface, DidUrl } from '@kiltprotocol/types'
18+
import { dereference, signatureFromJson, verifyDidSignature } from '@kiltprotocol/did'
19+
import type { Did, DidUrl, ICredential, SignerInterface } from '@kiltprotocol/types'
1920
import { Crypto, JsonSchema, Signers } from '@kiltprotocol/utils'
21+
import { IQuote, IQuoteAgreement, IQuoteAttesterSigned } from '../types/Quote.js'
2022
import * as QuoteError from './Error.js'
21-
import { dereference, verifyDidSignature, signatureFromJson } from '@kiltprotocol/did'
2223
import { QuoteSchema } from './QuoteSchema.js'
23-
import { IQuote, IQuoteAgreement, IQuoteAttesterSigned } from '../types/Quote.js'
2424

2525
/**
2626
* Validates the quote against the meta schema and quote data against the provided schema.
@@ -81,19 +81,21 @@ export async function createAttesterSignedQuote(
8181
export async function verifyAttesterSignedQuote(
8282
quote: IQuoteAttesterSigned,
8383
{
84-
didResolveKey,
84+
dereferenceDidUrl,
8585
}: {
86-
didResolveKey?: typeof dereference
86+
dereferenceDidUrl?: typeof dereference
8787
} = {}
8888
): Promise<void> {
8989
const { attesterSignature, ...basicQuote } = quote
90+
const { keyUri, signature } = signatureFromJson(attesterSignature)
9091
await verifyDidSignature({
91-
...signatureFromJson(attesterSignature),
92+
signerUrl: keyUri,
93+
signature,
9294
message: Crypto.hashStr(Crypto.encodeObjectAsStr(basicQuote)),
9395
expectedSigner: basicQuote.attesterDid,
9496
expectedVerificationRelationship: 'authentication',
9597
// @ts-expect-error this is dumb
96-
dereferenceDidUrl: didResolveKey,
98+
dereferenceDidUrl,
9799
})
98100

99101
const messages: string[] = []
@@ -161,21 +163,23 @@ export async function createQuoteAgreement(
161163
export async function verifyQuoteAgreement(
162164
quote: IQuoteAgreement,
163165
{
164-
didResolveKey,
166+
dereferenceDidUrl,
165167
}: {
166-
didResolveKey?: typeof dereference
168+
dereferenceDidUrl?: typeof dereference
167169
} = {}
168170
): Promise<void> {
169171
const { claimerSignature, claimerDid, rootHash, ...attesterSignedQuote } = quote
170172
// verify attester signature
171-
await verifyAttesterSignedQuote(attesterSignedQuote, { didResolveKey })
173+
await verifyAttesterSignedQuote(attesterSignedQuote, { dereferenceDidUrl })
172174
// verify claimer signature
175+
const { keyUri, signature } = signatureFromJson(claimerSignature)
173176
await verifyDidSignature({
174-
...signatureFromJson(claimerSignature),
177+
signature,
178+
signerUrl: keyUri,
175179
message: Crypto.hashStr(Crypto.encodeObjectAsStr({ ...attesterSignedQuote, claimerDid, rootHash })),
176180
expectedSigner: claimerDid,
177181
expectedVerificationRelationship: 'authentication',
178182
// @ts-expect-error why would this complain?
179-
dereferenceDidUrl: didResolveKey,
183+
dereferenceDidUrl,
180184
})
181185
}

0 commit comments

Comments
 (0)