Skip to content

Commit

Permalink
fix: straggling 2018 references and key parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Sep 11, 2024
1 parent 214fcac commit 7bf6607
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Ed25519Signature2020 extends JwsLinkedDataSignature {
*/
public constructor(options: Ed25519Signature2020Options) {
super({
type: 'Ed25519Signature2018',
type: 'Ed25519Signature2020',
algorithm: 'EdDSA',
LDKeyClass: options.LDKeyClass,
contextUrl: ED25519_SUITE_CONTEXT_URL_2020,
Expand All @@ -57,7 +57,7 @@ export class Ed25519Signature2020 extends JwsLinkedDataSignature {
date: options.date,
useNativeCanonize: options.useNativeCanonize,
})
this.requiredKeyType = 'Ed25519VerificationKey2018'
this.requiredKeyType = 'Ed25519VerificationKey2020'
}

public async assertVerificationMethod(document: JsonLdDoc) {
Expand Down Expand Up @@ -95,15 +95,18 @@ export class Ed25519Signature2020 extends JwsLinkedDataSignature {
// convert Ed25519VerificationKey2020 to Ed25519VerificationKey2018
if (_isEd2020Key(verificationMethod) && _includesEd2020Context(verificationMethod)) {
// -- convert multibase to base58 --
const publicKeyBuffer = MultiBaseEncoder.decode(verificationMethod.publicKeyMultibase)
let publicKeyBuffer = MultiBaseEncoder.decode(verificationMethod.publicKeyMultibase).data
if ((verificationMethod.publicKeyMultibase as string).startsWith("z6Mk")) {

Check failure on line 99 in packages/core/src/modules/vc/data-integrity/signature-suites/ed25519/Ed25519Signature2020.ts

View workflow job for this annotation

GitHub Actions / Validate

Replace `"z6Mk"` with `'z6Mk'`
publicKeyBuffer = publicKeyBuffer.slice(2)

Check failure on line 100 in packages/core/src/modules/vc/data-integrity/signature-suites/ed25519/Ed25519Signature2020.ts

View workflow job for this annotation

GitHub Actions / Validate

Delete `·`
}

// -- update type
verificationMethod.type = 'Ed25519VerificationKey2018'

verificationMethod = {
...verificationMethod,
publicKeyMultibase: undefined,
publicKeyBase58: TypedArrayEncoder.toBase58(publicKeyBuffer.data),
publicKeyBase58: TypedArrayEncoder.toBase58(publicKeyBuffer),
}
}

Expand Down Expand Up @@ -201,7 +204,7 @@ export class Ed25519Signature2020 extends JwsLinkedDataSignature {
if (!(options.proof.proofValue && typeof options.proof.proofValue === 'string')) {
throw new TypeError('The proof does not include a valid "proofValue" property.')
}
const signature = MultiBaseEncoder.decode(options.proof.proofValue)
const signature = MultiBaseEncoder.decode(options.proof.proofValue).data

let { verifier } = this
if (!verifier) {
Expand Down

0 comments on commit 7bf6607

Please sign in to comment.