Skip to content

Commit

Permalink
Rename sig scheme
Browse files Browse the repository at this point in the history
Signed-off-by: lovesh <[email protected]>
  • Loading branch information
lovesh committed Jul 2, 2024
1 parent 574e2f2 commit e76882a
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 257 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
"dependencies": {
"@digitalcredentials/vc-status-list": "^8.0.0",
"@docknetwork/crypto-wasm-ts": "0.62.0",
"@docknetwork/crypto-wasm-ts": "0.63.0",
"@docknetwork/node-types": "^0.17.0",
"@juanelas/base64": "^1.0.5",
"@polkadot/api": "10.12.4",
Expand Down
10 changes: 5 additions & 5 deletions src/presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import {
Bls12381BBS23SigDockSigName,
Bls12381PSSigProofDockSigName,
Bls12381BBS23SigProofDockSigName,
Bls12381BBSSigProofDockSigName, Bls12381BDDT16MacDockName, Bls12381BDDT16MacProofDockName,
Bls12381BBSSigProofDockSigName, Bls12381BBDT16MacDockName, Bls12381BBDT16MacProofDockName,
} from './utils/vc/crypto/constants';
import defaultDocumentLoader from './utils/vc/document-loader';
import {
Bls12381BBSSignatureDock2023,
Bls12381PSSignatureDock2023,
} from './utils/vc/custom_crypto';
import Bls12381BDDT16MACDock2024 from './utils/vc/crypto/Bls12381BDDT16MACDock2024';
import Bls12381BBDT16MACDock2024 from './utils/vc/crypto/Bls12381BBDT16MACDock2024';

import { isCredVerGte060 } from './utils/vc/crypto/common/DockCryptoSignature';

Expand All @@ -34,7 +34,7 @@ const SIG_NAME_TO_PROOF_NAME = Object.setPrototypeOf(
[Bls12381BBSSigDockSigName]: Bls12381BBSSigProofDockSigName,
[Bls12381BBS23SigDockSigName]: Bls12381BBS23SigProofDockSigName,
[Bls12381PSSigDockSigName]: Bls12381PSSigProofDockSigName,
[Bls12381BDDT16MacDockName]: Bls12381BDDT16MacProofDockName,
[Bls12381BBDT16MacDockName]: Bls12381BBDT16MacProofDockName,
},
null,
);
Expand Down Expand Up @@ -124,8 +124,8 @@ export default class Presentation {
Signature = Bls12381PSSignatureDock2023;
PublicKey = PSPublicKey;
break;
case Bls12381BDDT16MacDockName:
Signature = Bls12381BDDT16MACDock2024;
case Bls12381BBDT16MacDockName:
Signature = Bls12381BBDT16MACDock2024;
PublicKey = undefined;
isKvac = true;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/vc/CredentialIssuancePurpose.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import jsonld from 'jsonld';
import jsigs from 'jsonld-signatures';
import { expandJSONLD } from './helpers';
import { Bls12381BDDT16MacProofDockName } from './crypto/constants';
import { Bls12381BBDT16MacProofDockName } from './crypto/constants';

const { AssertionProofPurpose } = jsigs.purposes;

Expand Down Expand Up @@ -54,7 +54,7 @@ export default class CredentialIssuancePurpose extends AssertionProofPurpose {
document, suite, verificationMethod, documentLoader, expansionMap,
}) {
try {
if (proof.type === Bls12381BDDT16MacProofDockName) {
if (proof.type === Bls12381BBDT16MacProofDockName) {
return { valid: true, error: null };
}
const result = await super.validate(proof, {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/vc/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import bbsV1Context from './contexts/bbs-v1.json';
import dockBBSV1Context from './contexts/dock-bbs-v1.json';
import dockBBS23V1Context from './contexts/dock-bbs23-v1.json';
import dockPSV1Context from './contexts/dock-ps-v1.json';
import dockBDDT16V1Context from './contexts/dock-bddt16-v1.json';
import dockBBDT16V1Context from './contexts/dock-bbdt16-v1.json';
import dockPrettyVCContext from './contexts/prettyvc.json';
import jws2020V1Context from './contexts/jws-2020-v1.json';
import statusList21Context from './contexts/status-list-21';
Expand All @@ -37,8 +37,8 @@ export default new Map([
dockPSV1Context,
],
[
'https://ld.dock.io/security/bddt16/v1',
dockBDDT16V1Context,
'https://ld.dock.io/security/bbdt16/v1',
dockBBDT16V1Context,
],
[
'https://w3id.org/security/bbs/v1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@
"@version": 1.1,
"id": "@id",
"type": "@type",
"dockBBS": "https://ld.dock.io/dock-bddt16",
"dockBBDT16": "https://ld.dock.io/dock-bbdt16",
"parsingOptions": {
"@id": "dockBDDT16:parsingOptions",
"@id": "dockBBDT16:parsingOptions",
"@type": "@id",
"@container": "@graph"
},
"cryptoVersion": {
"@id": "dockBDDT16:cryptoVersion",
"@id": "dockBBDT16:cryptoVersion",
"@type": "@id",
"@container": "@graph"
},
"presVersion": {
"@id": "dockBDDT16:presVersion",
"@id": "dockBBDT16:presVersion",
"@type": "@id",
"@container": "@graph"
},
"defaultDecimalPlaces": {
"@id": "dockBDDT16:defaultDecimalPlaces",
"@id": "dockBBDT16:defaultDecimalPlaces",
"@type": "@id",
"@container": "@graph"
},
"defaultMinimumInteger": {
"@id": "dockBDDT16:defaultMinimumInteger",
"@id": "dockBBDT16:defaultMinimumInteger",
"@type": "@id",
"@container": "@graph"
},
"defaultMinimumDate": {
"@id": "dockBDDT16:defaultMinimumDate",
"@id": "dockBBDT16:defaultMinimumDate",
"@type": "@id",
"@container": "@graph"
},
"useDefaults": {
"@id": "dockBDDT16:useDefaults",
"@id": "dockBBDT16:useDefaults",
"@type": "@id",
"@container": "@graph"
},
"version": {
"@id": "dockBDDT16:useDefaults",
"@id": "dockBBDT16:useDefaults",
"@type": "@id",
"@container": "@graph"
},
"details": {
"@id": "dockBDDT16:details",
"@id": "dockBBDT16:details",
"@type": "@id",
"@container": "@graph"
},
Expand Down Expand Up @@ -81,8 +81,8 @@
}
}
},
"Bls12381BDDT16MACProofDock2024": {
"@id": "https://ld.dock.io/security#Bls12381BDDT16Dock2024",
"Bls12381BBDT16MACProofDock2024": {
"@id": "https://ld.dock.io/security#Bls12381BBDT16Dock2024",
"@context": {
"@version": 1.1,
"@protected": true,
Expand Down Expand Up @@ -133,8 +133,8 @@
}
}
},
"Bls12381BDDT16MACDock2024": {
"@id": "https://ld.dock.io/security#Bls12381BDDT16MACDock2024",
"Bls12381BBDT16MACDock2024": {
"@id": "https://ld.dock.io/security#Bls12381BBDT16MACDock2024",
"@context": {
"@version": 1.1,
"@protected": true,
Expand Down
14 changes: 7 additions & 7 deletions src/utils/vc/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import {
Bls12381BBSSignatureProofDock2022,
Bls12381BBSSignatureProofDock2023,
Bls12381BBSSigProofDockSigName,
Bls12381BDDT16MacDockName,
Bls12381BDDT16MacProofDockName,
Bls12381BBDT16MacDockName,
Bls12381BBDT16MacProofDockName,
Bls12381PSSigDockSigName,
Bls12381PSSignatureDock2023,
Bls12381PSSignatureProofDock2023,
Expand All @@ -50,7 +50,7 @@ import {
Sr25519Signature2020,
} from './custom_crypto';
import { signJWS } from './jws';
import Bls12381BDDT16MACProofDock2024 from './crypto/Bls12381BDDT16MACProofDock2024';
import Bls12381BBDT16MACProofDock2024 from './crypto/Bls12381BBDT16MACProofDock2024';

export const VC_ISSUE_TYPE_JSONLD = 'jsonld';
export const VC_ISSUE_TYPE_PROOFVALUE = 'proofValue';
Expand Down Expand Up @@ -84,8 +84,8 @@ export function isAnoncredsProofType(verifiableCredential) {
|| proofType === Bls12381BBS23SigProofDockSigName
|| proofType === Bls12381PSSigProofDockSigName
|| proofType === Bls12381BBS23SigDockSigName
|| proofType === Bls12381BDDT16MacDockName
|| proofType === Bls12381BDDT16MacProofDockName
|| proofType === Bls12381BBDT16MacDockName
|| proofType === Bls12381BBDT16MacProofDockName
|| proofType === Bls12381PSSigDockSigName
);
}
Expand Down Expand Up @@ -378,8 +378,8 @@ export async function verifyCredential(
new Bls12381BBSSignatureProofDock2023(anoncredsParams),
new Bls12381PSSignatureDock2023(anoncredsParams),
new Bls12381PSSignatureProofDock2023(anoncredsParams),
// Only BDDT16MACProof is present and not BDDT16MAC since those aren't verified by the following
new Bls12381BDDT16MACProofDock2024(anoncredsParams),
// Only BBDT16MACProof is present and not BBDT16MAC since those aren't verified by the following
new Bls12381BBDT16MACProofDock2024(anoncredsParams),
...suite,
];

Expand Down
24 changes: 24 additions & 0 deletions src/utils/vc/crypto/Bls12381BBDT16KeyPairDock2024.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
BBDT16_MAC_PARAMS_LABEL_BYTES, BBDT16KeypairG1, BBDT16MacPublicKeyG1,
BBDT16Mac, BBDT16MacParams, BBDT16MacSecretKey,
} from '@docknetwork/crypto-wasm-ts';

import { Bls12381BBDT16DockVerKeyName } from './constants';
import DockCryptoKeyPair from './common/DockCryptoKeyPair';

export default class Bls12381BBDT16KeyPairDock2024 extends DockCryptoKeyPair {
constructor(options) {
super(options, Bls12381BBDT16DockVerKeyName);
}

static get paramGenerator() {
return this.SignatureParams.getMacParamsOfRequiredSize;
}
}

Bls12381BBDT16KeyPairDock2024.SecretKey = BBDT16MacSecretKey;
Bls12381BBDT16KeyPairDock2024.PublicKey = BBDT16MacPublicKeyG1;
Bls12381BBDT16KeyPairDock2024.SignatureParams = BBDT16MacParams;
Bls12381BBDT16KeyPairDock2024.Signature = BBDT16Mac;
Bls12381BBDT16KeyPairDock2024.KeyPair = BBDT16KeypairG1;
Bls12381BBDT16KeyPairDock2024.defaultLabelBytes = BBDT16_MAC_PARAMS_LABEL_BYTES;
48 changes: 48 additions & 0 deletions src/utils/vc/crypto/Bls12381BBDT16MACDock2024.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
BBDT16Credential,
BBDT16CredentialBuilder,
} from '@docknetwork/crypto-wasm-ts/';

import { Bls12381BBDT16MacDockName } from './constants';

import DockCryptoSignature from './common/DockCryptoSignature';
import Bls12381BBDT16KeyPairDock2024 from './Bls12381BBDT16KeyPairDock2024';

/**
* A BBDT16 signature suite for use with BLS12-381 Dock key pairs
*/
export default class Bls12381BBDT16MACDock2024 extends DockCryptoSignature {
/**
* Default constructor
* @param options {SignatureSuiteOptions} options for constructing the signature suite
*/
constructor(options = {}) {
super(
{
...options,
signer:
options.signer
|| Bls12381BBDT16MACDock2024.signerFactory(
options.keypair,
options.verificationMethod,
),
},
Bls12381BBDT16MacDockName,
Bls12381BBDT16KeyPairDock2024,
'https://ld.dock.io/security/bbdt16/v1',
);
}

static get paramGenerator() {
return this.KeyPair.SignatureParams.getMacParamsOfRequiredSize;
}
}

Bls12381BBDT16MACDock2024.KeyPair = Bls12381BBDT16KeyPairDock2024;
Bls12381BBDT16MACDock2024.CredentialBuilder = BBDT16CredentialBuilder;
Bls12381BBDT16MACDock2024.Credential = BBDT16Credential;
Bls12381BBDT16MACDock2024.proofType = [
Bls12381BBDT16MacDockName,
`sec:${Bls12381BBDT16MacDockName}`,
`https://w3id.org/security#${Bls12381BBDT16MacDockName}`,
];
41 changes: 41 additions & 0 deletions src/utils/vc/crypto/Bls12381BBDT16MACProofDock2024.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
Bls12381BBDT16MacProofDockName, Bls12381BBDT16MacDockName,
} from './constants';

import DockCryptoSignatureProof from './common/DockCryptoSignatureProof';
import Bls12381BBDT16KeyPairDock2024 from './Bls12381BBDT16KeyPairDock2024';
import Bls12381BBDT16MACDock2024 from './Bls12381BBDT16MACDock2024';

/**
* A BBDT16 signature suite for use with derived BBDT16 credentials aka BBDT16 presentations
*/
export default class Bls12381BBDT16MACProofDock2024 extends DockCryptoSignatureProof {
/**
* Default constructor
* @param options {SignatureSuiteOptions} options for constructing the signature suite
*/
constructor(options = {}) {
super(
options,
Bls12381BBDT16MacProofDockName,
Bls12381BBDT16KeyPairDock2024,
'https://ld.dock.io/security/bbdt16/v1',
);
}

/**
*
* @param _
* @returns {Promise<void>} - Public key isn't used for verifying KVACs
*/
// eslint-disable-next-line no-empty-function
async getVerificationMethod(_) {}
}

Bls12381BBDT16MACProofDock2024.Signature = Bls12381BBDT16MACDock2024;
Bls12381BBDT16MACProofDock2024.sigName = Bls12381BBDT16MacDockName;
Bls12381BBDT16MACProofDock2024.proofType = [
Bls12381BBDT16MacProofDockName,
`sec:${Bls12381BBDT16MacProofDockName}`,
`https://w3id.org/security#${Bls12381BBDT16MacProofDockName}`,
];
24 changes: 0 additions & 24 deletions src/utils/vc/crypto/Bls12381BDDT16KeyPairDock2024.js

This file was deleted.

48 changes: 0 additions & 48 deletions src/utils/vc/crypto/Bls12381BDDT16MACDock2024.js

This file was deleted.

Loading

0 comments on commit e76882a

Please sign in to comment.