Skip to content

Commit

Permalink
Merge pull request #219 from docknetwork/feat/bbs+revocation-integrat…
Browse files Browse the repository at this point in the history
…ion-example

examples for bbs+ revocation
  • Loading branch information
maycon-mello authored Mar 4, 2024
2 parents 46eb246 + 8a2471f commit 56959f9
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"version": "0.0.1",
"name": "@docknetwork/wallet-sdk-cli",
"scripts": {
"cli": "ts-node src/index.ts"
"cli": "ts-node src/index.ts",
"test:bbs": "ts-node src/bbs-verification.ts",
"test:revocation": "ts-node src/bbs-revocation.ts"

},
"dependencies": {
"@docknetwork/wallet-sdk-core": "^0.4.3",
Expand Down
264 changes: 264 additions & 0 deletions packages/cli/src/bbs-revocation.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/cli/src/commands/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ verificationCommands
clipboardy.write(JSON.stringify(presentation, null, 2));
console.log('Presentation generated:');
console.log(JSON.stringify(presentation, null, 2));


const result = await controller.submitPresentation(presentation);

console.log(JSON.stringify(result, null, 2));
console.log('Verifying presentation...');
});

Expand Down
54 changes: 54 additions & 0 deletions packages/cli/src/fixtures/bbs-plus-revocation-credential.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
"dk": "https://ld.dock.io/credentials#",
"BasicCredential": "dk:BasicCredential",
"name": "dk:name"
}
],
"id": "https://creds-staging.dock.io/c11336afd12b904f75f3575d13e08ecce293a6b30cb66b6ac04cc02af7821736",
"type": [
"VerifiableCredential",
"BasicCredential"
],
"credentialSubject": {
"id": "did:key:z6MkqmzjatLbLqXgUubeHHY9cYJsRLV8YgSL86EYJpiPR1zm",
"name": "Test"
},
"issuanceDate": "2023-11-01T15:43:59.361Z",
"issuer": {
"name": "Profile bbs",
"id": "did:dock:5CDpZeS2fAas4Du87f2VyTj1BospmvQ5BZwZrKFtb3GeAppq"
},
"name": "Test2",
"credentialSchema": {
"id": "data:application/json;charset=utf-8,%7B%22%24schema%22%3A%22http%3A%2F%2Fjson-schema.org%2Fdraft-07%2Fschema%23%22%2C%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22credentialSubject%22%3A%7B%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22id%22%3A%7B%22type%22%3A%22string%22%7D%2C%22name%22%3A%7B%22type%22%3A%22string%22%7D%7D%7D%2C%22proof%22%3A%7B%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22type%22%3A%7B%22type%22%3A%22string%22%7D%2C%22%40context%22%3A%7B%22type%22%3A%22array%22%2C%22items%22%3A%5B%7B%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22sec%22%3A%7B%22type%22%3A%22string%22%7D%2C%22proof%22%3A%7B%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22%40id%22%3A%7B%22type%22%3A%22string%22%7D%2C%22%40type%22%3A%7B%22type%22%3A%22string%22%7D%2C%22%40container%22%3A%7B%22type%22%3A%22string%22%7D%7D%7D%7D%7D%2C%7B%22type%22%3A%22string%22%7D%5D%7D%2C%22created%22%3A%7B%22type%22%3A%22string%22%2C%22format%22%3A%22date-time%22%7D%2C%22verificationMethod%22%3A%7B%22type%22%3A%22string%22%7D%2C%22proofPurpose%22%3A%7B%22type%22%3A%22string%22%7D%7D%7D%2C%22cryptoVersion%22%3A%7B%22type%22%3A%22string%22%7D%2C%22credentialSchema%22%3A%7B%22type%22%3A%22string%22%7D%2C%22%40context%22%3A%7B%22type%22%3A%22string%22%7D%2C%22id%22%3A%7B%22type%22%3A%22string%22%7D%2C%22issuanceDate%22%3A%7B%22type%22%3A%22string%22%2C%22format%22%3A%22date-time%22%7D%2C%22issuer%22%3A%7B%22type%22%3A%22object%22%2C%22properties%22%3A%7B%22name%22%3A%7B%22type%22%3A%22string%22%7D%2C%22id%22%3A%7B%22type%22%3A%22string%22%7D%7D%7D%2C%22name%22%3A%7B%22type%22%3A%22string%22%7D%2C%22type%22%3A%7B%22type%22%3A%22string%22%7D%7D%2C%22definitions%22%3A%7B%22encryptableString%22%3A%7B%22type%22%3A%22string%22%7D%2C%22encryptableCompString%22%3A%7B%22type%22%3A%22string%22%7D%7D%7D",
"type": "JsonSchemaValidator2018",
"parsingOptions": {
"useDefaults": false,
"defaultMinimumInteger": -4294967295,
"defaultMinimumDate": -17592186044415,
"defaultDecimalPlaces": 0
},
"version": "0.0.3"
},
"proof": {
"@context": [
{
"sec": "https://w3id.org/security#",
"proof": {
"@id": "sec:proof",
"@type": "@id",
"@container": "@graph"
}
},
"https://ld.dock.io/security/bbs/v1"
],
"type": "Bls12381BBS+SignatureDock2022",
"created": "2023-11-02T15:54:33Z",
"verificationMethod": "did:dock:5CDpZeS2fAas4Du87f2VyTj1BospmvQ5BZwZrKFtb3GeAppq#keys-2",
"proofPurpose": "assertionMethod",
"proofValue": "zRBMddUsjkovgMmbJqMmiSUvxc8WWAnxWFEHs32ZjwTw1fnQGfZSqXwuti4CtcJ9eMvCw9P96GWCjsrBQzspKCF2Gy8XwiyRPq61Nzu4BCarTVLFAxZfEhECvdVSx42Mpxbg6x8E64fbwHQ6qT2RmpDiD7"
}
}
5 changes: 2 additions & 3 deletions packages/wasm/src/services/credential/bbs-revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AccumulatorPublicKey,
dockAccumulatorParams,
MembershipWitness,
Encoder,
} from '@docknetwork/crypto-wasm-ts';
import dock from '@docknetwork/sdk';

Expand Down Expand Up @@ -38,9 +39,7 @@ export const getWitnessDetails = async (
hexToU8a(queriedAccumulator.accumulated),
);

const encodedRevId = Accumulator.encodePositiveNumberAsAccumulatorMember(
Number(revocationIndex),
);
const encodedRevId = Encoder.defaultEncodeFunc()(revocationIndex.toString());

const publicKey = await dock.accumulatorModule.getPublicKeyByHexDid(
queriedAccumulator.keyRef[0],
Expand Down

0 comments on commit 56959f9

Please sign in to comment.