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

Feat multiple vc #87

Merged
merged 34 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
39a57a0
new feat: add new vc version=2 to support multiple attesters
Aug 25, 2023
51dbd8a
fix: data.issuer now is Did[]
Aug 25, 2023
41acec6
fix: add DigestPayloadV2
Aug 25, 2023
300198d
add: vc.build() support moreIssuers parameters(optional)
Aug 25, 2023
d592a45
fix: check issuers
Aug 25, 2023
bf39112
Add: add encodeAsSol function and test
jonathanxuu Aug 25, 2023
d61c738
Add: add Param: version for function calcRoothash
jonathanxuu Aug 26, 2023
dfd33dc
Update function to check VC validity, add check: whether the attester…
jonathanxuu Aug 26, 2023
048d951
Replace isAttester function, remove unnecessary format
jonathanxuu Aug 26, 2023
4925c7a
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Aug 26, 2023
b9980de
feat: add proof function (static)
Aug 28, 2023
eb9d8f0
Update: update calcRoothash
jonathanxuu Aug 29, 2023
b9211f3
Update&fix: update VerifiableCredential interface, support the verifi…
jonathanxuu Aug 29, 2023
3bbb829
Update&Test: Update the VC&VP Verification method; add test for Versi…
jonathanxuu Aug 29, 2023
5ac3d90
Test: Add test for vp verification (version 2)
jonathanxuu Aug 29, 2023
d1a53da
Add: Add new error for type check
jonathanxuu Aug 30, 2023
973bb7e
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Aug 30, 2023
e454508
Feat: add new function
jonathanxuu Aug 30, 2023
0eb645a
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Aug 30, 2023
659e0fc
Fmt: adjust the format; move addProof to vcVerify
jonathanxuu Aug 30, 2023
9c99e2b
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Aug 30, 2023
b7d79b5
Test: Add 'extend' test for message.spec.ts
jonathanxuu Aug 31, 2023
85e44ac
Fix: The input cannot be empty, add more test
jonathanxuu Sep 1, 2023
58a9cc5
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Sep 4, 2023
d3cb078
add web3 lib
Sep 4, 2023
0dfbf95
Fix: turn web3 Local Mode, new yarn add
jonathanxuu Sep 4, 2023
51a7045
Merge branch 'feat-multiple-vc' of https://github.com/zCloak-Network/…
jonathanxuu Sep 4, 2023
531b576
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Sep 5, 2023
e9d9b87
Merge branch 'master' of github.com:zCloak-Network/zkid-sdk
Sep 5, 2023
183ce3e
Fix: replace yarn relese file to the old version
jonathanxuu Sep 5, 2023
49161d0
Merge branch 'master' into feat-multiple-vc
Sep 5, 2023
1b96cb0
Merge branch 'feat-multiple-vc' of github.com:zCloak-Network/zkid-sdk…
Sep 5, 2023
a3263b2
upgrade to 2.0.0
Sep 5, 2023
bd05b50
Fix: fix web3 import
jonathanxuu Sep 5, 2023
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
22 changes: 22 additions & 0 deletions .changeset/stupid-deers-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@zcloak/message": major
"@zcloak/verify": major
"@zcloak/vc": major
"@zcloak/login-did": major
"@zcloak/login-providers": major
"@zcloak/login-rpc": major
"@zcloak/login-rpc-defines": major
"@zcloak/login-verify": major
"@zcloak/ctype": major
"@zcloak/did": major
"@zcloak/did-resolver": major
"@zcloak/cross": major
"@zcloak/crypto": major
"@zcloak/keyring": major
"@zcloak/miden": major
"@zcloak/wasm": major
"@zcloak/wasm-asm": major
"@zcloak/wasm-bridge": major
---

[ upgrade to 2.0.0 ]
Empty file modified .yarn/releases/yarn-4.0.0-rc.40.cjs
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
},
"resolutions": {
"typescript": "^5.0.4"
},
"dependencies": {
"web3": "^4.1.1"
}
}
28 changes: 26 additions & 2 deletions packages/message/src/decrypt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ export function verifyMessageData(message: DecryptedMessage<MessageType>): void

case 'Response_Approve_Attestation':
assert(isVC(data), `Expected message data with msgType:${msgType} is VerifiableCredential object`);
assert(isSameUri(sender, data.issuer), 'Message sender is not the issuer of VerifiableCredential');

if (typeof data.issuer === 'object') {
assert(
data.issuer.some((issuer) => isSameUri(sender, issuer)),
'Message sender is not the issuer of VerifiableCredential'
);
} else if (typeof data.issuer === 'string') {
assert(isSameUri(sender, data.issuer), 'Message sender is not the issuer VerifiableCredential');
} else {
const check: never = data.issuer;

return check;
}

break;

Expand Down Expand Up @@ -73,7 +85,19 @@ export function verifyMessageData(message: DecryptedMessage<MessageType>): void

case 'Send_issuedVC':
assert(isVC(data), `Expected message data with msgType:${msgType} is VerifiableCredential object`);
assert(isSameUri(sender, data.issuer), 'Message sender is not the issuer of VerifiableCredential');

if (typeof data.issuer === 'object') {
assert(
data.issuer.some((issuer) => isSameUri(sender, issuer)),
'Message sender is not the issuer of VerifiableCredential'
);
} else if (typeof data.issuer === 'string') {
assert(isSameUri(sender, data.issuer), 'Message sender is not the issuer VerifiableCredential');
} else {
const check: never = data.issuer;

throw new Error(`Message sender type wrong, the wrong issuer is : ${check}`);
}

break;

Expand Down
52 changes: 51 additions & 1 deletion packages/message/src/message.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import type { CType } from '@zcloak/ctype/types';
import type { RawCredential } from '@zcloak/vc/types';

import { alice, bob, testResolver } from 'test-support';
import { alice, bob, charlie, testResolver } from 'test-support';

import { initCrypto } from '@zcloak/crypto';
import { getPublish } from '@zcloak/ctype';
import { Raw, VerifiableCredentialBuilder } from '@zcloak/vc';
import { addProof } from '@zcloak/verify';

import { decryptMessage } from './decrypt';
import { encryptMessage } from './encrypt';
Expand Down Expand Up @@ -110,6 +111,55 @@ describe('message encrypt and decrypt', (): void => {
});

describe('Send Extends msgType', () => {
it('Send vc to be add proof', async () => {
const vc = await VerifiableCredentialBuilder.fromRawCredential(rawCredential, ctype)
.setExpirationDate(null)
.build(alice, false);

const message = await encryptMessage(
'Extends_Request_Comfirmation',
vc,
alice,
bob.getKeyUrl('keyAgreement'),
undefined,
testResolver
);
const decrypted = await decryptMessage(message, bob, testResolver);

expect(decrypted.data).toEqual(vc);
});

it('Send multiAttester VC', async () => {
const vc = await VerifiableCredentialBuilder.fromRawCredential(rawCredential, ctype)
.setExpirationDate(null)
.build(alice, false);

const message = await encryptMessage(
'Extends_Request_Comfirmation',
vc,
alice,
bob.getKeyUrl('keyAgreement'),
undefined,
testResolver
);
const decrypted = await decryptMessage(message, bob, testResolver);
const multiAttesterVC = await addProof(bob, decrypted.data);

expect(multiAttesterVC.issuer).toEqual([alice.getDocument().id, bob.getDocument().id]);

const messageSentToUser = await encryptMessage(
'Extends_Response_Approve_Attestation message',
multiAttesterVC,
bob,
charlie.getKeyUrl('keyAgreement'),
undefined,
testResolver
);
const decryptedMultiVC = await decryptMessage(messageSentToUser, charlie, testResolver);

expect(decryptedMultiVC.data).toEqual(multiAttesterVC);
});

it('Send string data', async () => {
const message = await encryptMessage(
'Extends_send_string',
Expand Down
Loading
Loading