Skip to content

Commit

Permalink
wasm example
Browse files Browse the repository at this point in the history
  • Loading branch information
UMR1352 committed Jan 23, 2024
1 parent f076118 commit 8b53ddb
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions bindings/wasm/examples/src/1_advanced/7_status_list_2021.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@

import {
Credential,
EdDSAJwsVerifier,
FailFast,
IJwsVerifier,
IotaIdentityClient,
Jwk,
JwkMemStore,
JwsAlgorithm,
JwsSignatureOptions,
JwtCredentialValidationOptions,
JwtCredentialValidator,
Expand All @@ -20,7 +17,6 @@ import {
StatusList2021Entry,
StatusPurpose,
Storage,
verifyEd25519,
} from "@iota/identity-wasm/node";
import { Client, MnemonicSecretManager, Utils } from "@iota/sdk-wasm/node";
import { API_ENDPOINT, createDid } from "../util";
Expand Down Expand Up @@ -115,7 +111,7 @@ export async function statusList2021() {
const validationOptions = new JwtCredentialValidationOptions({ status: StatusCheck.SkipUnsupported });
// The validator has no way of retrieving the status list to check for the
// revocation of the credential. Let's skip that pass and perform the operation manually.
let jwtCredentialValidator = new JwtCredentialValidator(new Ed25519JwsVerifier());
let jwtCredentialValidator = new JwtCredentialValidator(new EdDSAJwsVerifier());
jwtCredentialValidator.validate(
credentialJwt,
issuerDocument,
Expand Down Expand Up @@ -154,16 +150,3 @@ export async function statusList2021() {
console.log(`Error during validation: ${e}`);
}
}

// A custom JWS Verifier capabale of verifying EdDSA signatures with curve Ed25519.
class Ed25519JwsVerifier implements IJwsVerifier {
verify(alg: JwsAlgorithm, signingInput: Uint8Array, decodedSignature: Uint8Array, publicKey: Jwk) {
switch (alg) {
case JwsAlgorithm.EdDSA:
// This verifies that the curve is Ed25519 so we don't need to check ourselves.
return verifyEd25519(alg, signingInput, decodedSignature, publicKey);
default:
throw new Error(`unsupported jws algorithm ${alg}`);
}
}
}

0 comments on commit 8b53ddb

Please sign in to comment.