Skip to content
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

add noble/curves for es256 jwt verification #1493

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 76 additions & 52 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"@fontsource/ibm-plex-mono": "^4.5.12",
"@fontsource/material-icons": "^4.5.4",
"@iota/crypto.js": "^1.8.6",
"@iota/identity-wasm": "^1.0.0",
"@iota/identity-wasm": "^1.3.1",
"@iota/iota.js": "^1.8.6",
"@iota/mam-legacy": "github:iotaledger/mam.js#fddc95f60539b9a31a4db1b5b56e0dedb8994883",
"@iota/mam.js": "^1.6.2",
"@iota/sdk-wasm-stardust": "npm:@iota/[email protected]",
"@iota/sdk-wasm-nova": "npm:@iota/sdk-wasm@^2.0.0-beta.1",
"@iota/sdk-wasm-stardust": "npm:@iota/[email protected]",
"@iota/util.js": "^1.8.6",
"@noble/curves": "^1.5.0",
"classnames": "^2.3.1",
"d3-array": "^3.2.1",
"d3-axis": "^3.0.0",
Expand Down
14 changes: 13 additions & 1 deletion client/src/app/components/identity/DIDResolver.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as identity from "@iota/identity-wasm/web";
import {
DomainLinkageConfiguration,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
EdDSAJwsVerifier,
JwtCredentialValidationOptions,
JwtDomainLinkageValidator,
LinkedDomainService,
IJwsVerifier,
} from "@iota/identity-wasm/web";
import { p256 } from "@noble/curves/p256";
import React, { Fragment, useEffect, useState } from "react";
import DIDDomainResolver from "./domains/DIDDomainResolver";
import { DIDResolverProps } from "./DIDResolverProps";
Expand Down Expand Up @@ -146,6 +149,15 @@ const IdentityStardustResolver: React.FC<DIDResolverProps> = ({ resolvedDID, net
// }
export default IdentityStardustResolver;

class EcDSAVerifier implements IJwsVerifier {
constructor() {}
verify(alg: identity.JwsAlgorithm, signingInput: Uint8Array, decodedSignature: Uint8Array, publicKey: identity.Jwk) {
// eslint-disable-next-line no-console
console.log(publicKey);
p256.verify(decodedSignature, signingInput, new Uint8Array());
}
}

async function constructVerifiedDomains(resolvedDID: IDIDResolverResponse): Promise<Map<string, Promise<void>>> {
const newVerifiedDomains = new Map<string, Promise<void>>();
const origin = window?.location?.origin ?? "";
Expand Down Expand Up @@ -178,7 +190,7 @@ async function constructVerifiedDomains(resolvedDID: IDIDResolverResponse): Prom
parsedConfigurationResource = DomainLinkageConfiguration.fromJSON(jsonResponse);

try {
new JwtDomainLinkageValidator(new EdDSAJwsVerifier()).validateLinkage(
new JwtDomainLinkageValidator(new EcDSAVerifier()).validateLinkage(
didDocument,
parsedConfigurationResource,
domain,
Expand Down
Loading