Skip to content

Commit

Permalink
Merge branch 'master' into feat/ed25519-2020-support
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder authored Apr 25, 2024
2 parents fb526d7 + 9252b69 commit cbd5f40
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/sdk",
"version": "8.1.2",
"version": "8.1.3",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
28 changes: 27 additions & 1 deletion src/utils/vc/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ import {
Bls12381BBSSignatureProofDock2022,
Bls12381BBSSignatureDock2023,
Bls12381BBSSignatureProofDock2023,
Bls12381BBS23SigProofDockSigName,
Bls12381PSSigProofDockSigName,
JsonWebSignature2020,
Bls12381PSSigDockSigName,
Bls12381BBSSigDockSigName,
Bls12381BBSSigProofDockSigName,
Bls12381BBS23SigDockSigName,
Bls12381BDDT16MacDockName,
Bls12381BDDT16MacProofDockName,
} from './custom_crypto';
import { signJWS } from './jws';
import Bls12381BDDT16MACProofDock2024 from './crypto/Bls12381BDDT16MACProofDock2024';
Expand Down Expand Up @@ -69,6 +77,20 @@ function dateStringToTimestamp(dateStr) {
return Math.floor(Date.parse(dateStr) / 1000);
}

export function isAnoncredsProofType(verifiableCredential) {
const proofType = verifiableCredential.proof && verifiableCredential.proof.type;
return (
proofType === Bls12381BBSSigDockSigName
|| proofType === Bls12381BBSSigProofDockSigName
|| proofType === Bls12381BBS23SigProofDockSigName
|| proofType === Bls12381PSSigProofDockSigName
|| proofType === Bls12381BBS23SigDockSigName
|| proofType === Bls12381BDDT16MacDockName
|| proofType === Bls12381BDDT16MacProofDockName
|| proofType === Bls12381PSSigDockSigName
);
}

export function formatToJWTPayload(keyDoc, cred) {
const kid = keyDoc.id;
const credentialIssuer = cred.issuer;
Expand Down Expand Up @@ -294,7 +316,11 @@ export async function verifyCredential(
documentLoader: docLoader,
});

if (!skipSchemaCheck) {
// Determine if we should validate the schema when verifying
// NOTE: derived anoncreds do not need JSON schema validation as the anoncreds library validates it
// and it can fail when required attributes are not revealed
const isAnoncredsDerived = isAnoncredsProofType(credential);
if (!skipSchemaCheck && !isAnoncredsDerived) {
await getAndValidateSchemaIfPresent(
expandedCredential,
credential[credentialContextField],
Expand Down
4 changes: 4 additions & 0 deletions src/utils/vc/custom_crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
Bls12381PSDockVerKeyName,
Bls12381PSSigDockSigName,
Bls12381PSSigProofDockSigName,
Bls12381BDDT16MacDockName,
Bls12381BDDT16MacProofDockName,
} from './crypto/constants';

import EcdsaSecp256k1VerificationKey2019 from './crypto/EcdsaSecp256k1VerificationKey2019';
Expand Down Expand Up @@ -64,5 +66,7 @@ export {
Bls12381PSDockVerKeyName,
Bls12381PSSigDockSigName,
Bls12381PSSigProofDockSigName,
Bls12381BDDT16MacDockName,
Bls12381BDDT16MacProofDockName,
JsonWebSignature2020,
};
2 changes: 1 addition & 1 deletion tests/integration/anoncreds/derived-credentials.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const residentCardSchema = {
minimum: 0,
},
},
required: [],
required: ['givenName', 'familyName', 'lprNumber'],
},
},
};
Expand Down

0 comments on commit cbd5f40

Please sign in to comment.