Skip to content

Commit

Permalink
Merge pull request #357 from docknetwork/upgrade/crypto-wasm-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder authored Sep 5, 2023
2 parents 2ed62f5 + 1b2ddd8 commit aa76a57
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 21 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/sdk",
"version": "6.0.0",
"version": "6.1.0",
"main": "index.js",
"license": "MIT",
"repository": {
Expand All @@ -18,7 +18,7 @@
"@babel/preset-env": "^7.15.6",
"@comunica/actor-init-sparql-rdfjs": "^1.22.3",
"@comunica/types": "^1.0.0",
"@docknetwork/crypto-wasm": "^0.18.0",
"@docknetwork/crypto-wasm": "^0.19.0",
"@polkadot/x-bigint": "10.1.11",
"@polkadot/x-bundle": "10.1.11",
"@polkadot/x-global": "10.1.11",
Expand Down Expand Up @@ -110,7 +110,7 @@
},
"dependencies": {
"@digitalbazaar/vc-status-list": "^4.0.0",
"@docknetwork/crypto-wasm-ts": "^0.33.3",
"@docknetwork/crypto-wasm-ts": "^0.38.1",
"@docknetwork/node-types": "^0.16.0",
"@juanelas/base64": "^1.0.5",
"@polkadot/api": "9.7.1",
Expand Down
3 changes: 3 additions & 0 deletions src/presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ export default class Presentation {
context: presentation.context,
attributeCiphertexts: presentation.attributeCiphertexts,
attributeEqualities: presentation.spec.attributeEqualities,
boundedPseudonyms: presentation.spec.boundedPseudonyms,
unboundedPseudonyms: presentation.spec.unboundedPseudonyms,
version: credential.version,
sigType: credential.sigType,
},
};
});
Expand Down
3 changes: 3 additions & 0 deletions src/utils/vc/contexts/dock-bbs-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
},
"domain": "https://ld.dock.io/security#domain",
"context": "https://ld.dock.io/security#context",
"sigType": "https://ld.dock.io/security#sigType",
"boundedPseudonyms": "https://ld.dock.io/security#boundedPseudonyms",
"unboundedPseudonyms": "https://ld.dock.io/security#unboundedPseudonyms",
"attributeCiphertexts": "https://ld.dock.io/security#attributeCiphertexts",
"attributeEqualities": "https://ld.dock.io/security#attributeEqualities",
"proofValue": "https://ld.dock.io/security#proofValue",
Expand Down
3 changes: 3 additions & 0 deletions src/utils/vc/contexts/dock-bbs23-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
},
"domain": "https://ld.dock.io/security#domain",
"context": "https://ld.dock.io/security#context",
"sigType": "https://ld.dock.io/security#sigType",
"boundedPseudonyms": "https://ld.dock.io/security#boundedPseudonyms",
"unboundedPseudonyms": "https://ld.dock.io/security#unboundedPseudonyms",
"attributeCiphertexts": "https://ld.dock.io/security#attributeCiphertexts",
"attributeEqualities": "https://ld.dock.io/security#attributeEqualities",
"proofValue": "https://ld.dock.io/security#proofValue",
Expand Down
3 changes: 3 additions & 0 deletions src/utils/vc/contexts/dock-ps-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
},
"domain": "https://ld.dock.io/security#domain",
"context": "https://ld.dock.io/security#context",
"sigType": "https://ld.dock.io/security#sigType",
"boundedPseudonyms": "https://ld.dock.io/security#boundedPseudonyms",
"unboundedPseudonyms": "https://ld.dock.io/security#unboundedPseudonyms",
"attributeCiphertexts": "https://ld.dock.io/security#attributeCiphertexts",
"attributeEqualities": "https://ld.dock.io/security#attributeEqualities",
"proofValue": "https://ld.dock.io/security#proofValue",
Expand Down
3 changes: 3 additions & 0 deletions src/utils/vc/crypto/common/DockCryptoSignatureProof.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default withExtendedStaticProperties(
spec: {
credentials: [
{
sigType: proof.sigType,
version: proof.version,
schema: JSON.stringify(credentialSchema),
revealedAttributes: {
Expand All @@ -116,6 +117,8 @@ export default withExtendedStaticProperties(
},
],
attributeEqualities: proof.attributeEqualities,
boundedPseudonyms: proof.boundedPseudonyms,
unboundedPseudonyms: proof.unboundedPseudonyms,
},
attributeCiphertexts: proof.attributeCiphertexts,
proof: proof.proofValue,
Expand Down
24 changes: 23 additions & 1 deletion tests/integration/anoncreds/derived-credentials.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ for (const {
'credentialSubject.type.1',
]);

// Begin to derive a credential from the above issued one
const presentationInstance2 = new Presentation();
const idx2 = await presentationInstance2.addCredentialToPresent(
credential,
{ resolver },
);

// Reveal subject attributes
await presentationInstance2.addAttributeToReveal(idx2, [
'credentialSubject.lprNumber',
]);

// NOTE: revealing subject type because of JSON-LD processing for this certain credential
// you may not always need to do this depending on your JSON-LD contexts
await presentationInstance2.addAttributeToReveal(idx2, [
'credentialSubject.type.0',
]);
await presentationInstance2.addAttributeToReveal(idx2, [
'credentialSubject.type.1',
]);

// Derive a W3C Verifiable Credential JSON from the above presentation
const credentials = await presentationInstance.deriveCredentials(
presentationOptions,
Expand All @@ -253,9 +274,10 @@ for (const {

// Ensure reconstructing presentation from credential matches
// NOTE: ignoring proof here as itll differ when signed twice as above
const presentation = await presentationInstance.createPresentation(
const presentation = await presentationInstance2.createPresentation(
presentationOptions,
);

const reconstructedPres = convertToPresentation(credentials[0]);
expect(reconstructedPres.proof).toBeDefined();
expect({
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/anoncreds/r1cs-circom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,32 +162,30 @@ for (const {
const queriedPk = await getModule(dock).getPublicKey(issuerDid, 2, false);
const sigPk = new PublicKey(hexToU8a(queriedPk.bytes));

credential1 = SignatureParams.signMessageObject(
credential1 = Signature.signMessageObject(
attributes1,
issuerSchemeKeypair.secretKey,
labelBytes,
encoder,
);
expect(
SignatureParams.verifyMessageObject(
credential1.signature.verifyMessageObject(
attributes1,
credential1.signature,
sigPk,
labelBytes,
encoder,
).verified,
).toBe(true);

credential2 = SignatureParams.signMessageObject(
credential2 = Signature.signMessageObject(
attributes2,
issuerSchemeKeypair.secretKey,
labelBytes,
encoder,
);
expect(
SignatureParams.verifyMessageObject(
credential2.signature.verifyMessageObject(
attributes2,
credential2.signature,
sigPk,
labelBytes,
encoder,
Expand Down
31 changes: 20 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2481,22 +2481,26 @@
jsonld "^5.2.0"
jsonld-signatures "^9.3.0"

"@docknetwork/crypto-wasm-ts@^0.33.3":
version "0.33.3"
resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm-ts/-/crypto-wasm-ts-0.33.3.tgz#28f86d454e0f4170ef52aed9220e3b270ee49711"
integrity sha512-T8IBmi9fExCHOvdWeOzsLphPXi4/DTtXkDGngSsDqKGT2tuMgIswXlu5UCJoNa8qKnbmrUs/S/Vw7tDid4eyiA==
"@docknetwork/crypto-wasm-ts@^0.38.1":
version "0.38.1"
resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm-ts/-/crypto-wasm-ts-0.38.1.tgz#36742c1cf694de67b5838b1df51332b9982f2d68"
integrity sha512-Vfbo75UoHXiT12Hcz/Hd6JNkCiE3AX6HKmkxo+dU6XYjyh5DlvD2OAJdCWWR54UILefji570lUyEA+U0MoU/4g==
dependencies:
"@docknetwork/crypto-wasm" "^0.18.0"
"@docknetwork/crypto-wasm" "0.19.0"
"@types/flat" "^5.0.2"
"@types/lodash" "^4.14.195"
bs58 "5.0.0"
flat "^5.0.2"
json-pointer "^0.6.2"
lzutf8 "^0.6.3"
lodash "^4.17.21"
lzutf8 "0.6.3"

"@docknetwork/crypto-wasm@^0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm/-/crypto-wasm-0.18.0.tgz#f38678812b23a677afe00c57ff20792a256f1799"
integrity sha512-dipHJlZcoi60x/cBDfkhGXx5VCtLyHPyzVF/sjLl8PX7pC3TlyRRApW1uh3peRLG/klP34dneG2jC/x6u2iDcw==
"@docknetwork/[email protected]", "@docknetwork/crypto-wasm@^0.19.0":
version "0.19.0"
resolved "https://registry.yarnpkg.com/@docknetwork/crypto-wasm/-/crypto-wasm-0.19.0.tgz#64905fa517135a53ca61b2d1cc6c8267212d7bc6"
integrity sha512-ubk104MHeEBlH/jXKiNQ6xClaDMzu6WwK7AkNyMqtRcxJ7y5088LGekQwCdfOja85hTOKwx0LR/CRDBwQVRMRQ==
dependencies:
buffer "^6.0.3"

"@docknetwork/node-types@^0.16.0":
version "0.16.0"
Expand Down Expand Up @@ -4063,6 +4067,11 @@
resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-3.0.2.tgz#fd2cd2edbaa7eaac7e7f3c1748b52a19143846c9"
integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==

"@types/lodash@^4.14.195":
version "4.14.197"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b"
integrity sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==

"@types/long@^4.0.1":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
Expand Down Expand Up @@ -9238,7 +9247,7 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lzutf8@^0.6.3:
[email protected]:
version "0.6.3"
resolved "https://registry.yarnpkg.com/lzutf8/-/lzutf8-0.6.3.tgz#37a2ebe80922a8405f1e3f24c6c2b74c3e430981"
integrity sha512-CAkF9HKrM+XpB0f3DepQ2to2iUEo0zrbh+XgBqgNBc1+k8HMM3u/YSfHI3Dr4GmoTIez2Pr/If1XFl3rU26AwA==
Expand Down

0 comments on commit aa76a57

Please sign in to comment.