From ef5f88724f28e666e18c0f05aac922ab5a6327d7 Mon Sep 17 00:00:00 2001 From: Ruffiano Date: Wed, 22 Jun 2022 00:13:57 +0900 Subject: [PATCH 1/4] doc docs --- libraries/fula-sec/readme.md | 31 ++++++++----------------------- libraries/fula-sec/src/did.ts | 5 +++-- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/libraries/fula-sec/readme.md b/libraries/fula-sec/readme.md index 090106e..824336a 100644 --- a/libraries/fula-sec/readme.md +++ b/libraries/fula-sec/readme.md @@ -53,23 +53,8 @@ Install NPM package // Fulla DID const fullaDID = new FullaDID(); - // ... - // Create DID identity () => return {did|authDID, mnemonic, privateKey} - await fullaDID.create(); - - // You can also call backup option by using getter -> fullaDID.backup () => return {did|authDID, mnemonic, privateKey} - - // Import Options: - // 1. Import with mnemonic - // 2. Import with privateKey - - // Import existing mnemonic phrase () => return {did|authDID, privateKey} - // mnemonic example: 'mercy drip similar hole oil lock blast absent medal slam world sweet', - await fullaDID.importMnemonic(result.mnemonic); - - // Import existing privateKey () => return {did|authDID, privateKey} - // privateKey example: ff396d82b24b3f8f200cc240bb6d0770911c82e1d8c0199638373221efedabd5 - await fullaDID.importPrivateKey(result.privateKey); + // Create DID identity (_secretKey, signature) => return {did|authDID, mnemonic, privateKey} + await fullaDID.create(secretKey, signature); ```

(back to top)

@@ -81,12 +66,12 @@ Install NPM package // Alice creates own DID const AliceDID = new FullaDID(); - await AliceDID.create(); + await AliceDID.create(secretKey, signature); const taggedA = new TaggedEncryption(AliceDID.did); // Bob creates own DID const BobDID = new FullaDID(); - await BobDID.create(); + await BobDID.create(secretKey, signature); const taggedB = new TaggedEncryption(BobDID.did); // 1. Handshake |Alice DID| <--- |Bob DID| @@ -113,15 +98,15 @@ Install NPM package // Alice creates own DID (Issuer) const AliceDID = new FullaDID(); - await AliceDID.create(); + await AliceDID.create(secretKey, signature); // Set privateKey const asymEncA = new AsymEncryption(AliceDID.privateKey); // Bob creates own DID (Audience) - const BliceDID = new FullaDID(); - await BliceDID.create(); + const BobDID = new FullaDID(); + await BobDID.create(secretKey, signature); // Set privateKey - const asymEncB = new AsymEncryption(BliceDID.privateKey); + const asymEncB = new AsymEncryption(BobDID.privateKey); /* 1. Bob shares PublicKey with Alice diff --git a/libraries/fula-sec/src/did.ts b/libraries/fula-sec/src/did.ts index c1f0c32..f6f944f 100644 --- a/libraries/fula-sec/src/did.ts +++ b/libraries/fula-sec/src/did.ts @@ -32,9 +32,10 @@ export class FulaDID implements IFulaDID { return this.did.authenticate(); } /** - * Creates mnemocic phrase and private key + * Activate decentralized identity * @function create() - * @returns Object - { sauthDID } + * @property _secretKey: string, signature: string + * @returns Object - { authDID } */ async create (_secretKey: string, signature: string) { this.rootKey = sha3.keccak256(JSON.stringify({ From e3d9d448f0e644df24ffad16faf1417653d1ade9 Mon Sep 17 00:00:00 2001 From: Ruffiano Date: Sat, 25 Jun 2022 23:47:01 +0900 Subject: [PATCH 2/4] fixed #227 --- libraries/fula-sec/readme.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/fula-sec/readme.md b/libraries/fula-sec/readme.md index 824336a..4960804 100644 --- a/libraries/fula-sec/readme.md +++ b/libraries/fula-sec/readme.md @@ -49,12 +49,12 @@ Install NPM package ## Decentralized Identity (DID) ```js - import {FullaDID} from '@functionland/fula-sec' + import {FulaDID} from '@functionland/fula-sec' // Fulla DID - const fullaDID = new FullaDID(); + const fulaDID = new FulaDID(); // Create DID identity (_secretKey, signature) => return {did|authDID, mnemonic, privateKey} - await fullaDID.create(secretKey, signature); + await fulaDID.create(secretKey, signature); ```

(back to top)

@@ -62,15 +62,15 @@ Install NPM package ## Tagged Encryption (Tagged DID) ```js - import {FullaDID, TaggedEncryption} from '@functionland/fula-sec' + import {FulaDID, TaggedEncryption} from '@functionland/fula-sec' // Alice creates own DID - const AliceDID = new FullaDID(); + const AliceDID = new FulaDID(); await AliceDID.create(secretKey, signature); const taggedA = new TaggedEncryption(AliceDID.did); // Bob creates own DID - const BobDID = new FullaDID(); + const BobDID = new FulaDID(); await BobDID.create(secretKey, signature); const taggedB = new TaggedEncryption(BobDID.did); @@ -94,16 +94,16 @@ Install NPM package ## Asymmetric Encryption ```js - import {FullaDID, AsymEncryption} from '@functionland/fula-sec' + import {FulaDID, AsymEncryption} from '@functionland/fula-sec' // Alice creates own DID (Issuer) - const AliceDID = new FullaDID(); + const AliceDID = new FulaDID(); await AliceDID.create(secretKey, signature); // Set privateKey const asymEncA = new AsymEncryption(AliceDID.privateKey); // Bob creates own DID (Audience) - const BobDID = new FullaDID(); + const BobDID = new FulaDID(); await BobDID.create(secretKey, signature); // Set privateKey const asymEncB = new AsymEncryption(BobDID.privateKey); @@ -138,7 +138,7 @@ Run doc cmd npx typedoc --out docs -[Fulla Sec DOC](http://127.0.0.1:5500/libraries/fula-sec/docs/classes/FullaDID.html) +[Fulla Sec DOC](http://127.0.0.1:5500/libraries/fula-sec/docs/classes/FulaDID.html) From a7c1f7f9a2aaeafd497e6d0ea0aac95c01fdd4d2 Mon Sep 17 00:00:00 2001 From: Ruffiano Date: Sat, 25 Jun 2022 23:51:19 +0900 Subject: [PATCH 3/4] fixed #229 --- libraries/fula-sec/src/tagged.enc.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/fula-sec/src/tagged.enc.ts b/libraries/fula-sec/src/tagged.enc.ts index d893275..3121ac6 100644 --- a/libraries/fula-sec/src/tagged.enc.ts +++ b/libraries/fula-sec/src/tagged.enc.ts @@ -7,7 +7,7 @@ interface ITagEncryption { didAudience: string; CID: string; - symetricKey: string; + symetricKey: any; encrypt(symetricKey: string, CID: string, didAudience: Array): Promise; decrypt(jwe: any): Promise; } @@ -16,7 +16,7 @@ export class TaggedEncryption implements ITagEncryption { private _did: any; didAudience!: string; CID!: string; - symetricKey!: string + symetricKey!: any constructor (DID: any) { this._did = DID; @@ -28,8 +28,8 @@ export class TaggedEncryption implements ITagEncryption { * @property symetricKey: string, CID: string, didAudience: array * @returns jwe {} */ - async encrypt(symetricKey: string, CID: string, didAudience: Array): Promise { - return await this._did.createDagJWE({ symetricKey: symetricKey, CID: CID}, didAudience) + async encrypt(symetricKey: any, CID: string, didAudience: Array): Promise { + return await this._did.createDagJWE({symetricKey, CID}, didAudience) } /** From d9bc3a60e0ba75902523f9b213b50cfb06af7541 Mon Sep 17 00:00:00 2001 From: ruffiano89 <98644365+ruffiano89@users.noreply.github.com> Date: Sun, 26 Jun 2022 00:04:24 +0900 Subject: [PATCH 4/4] symetricKey should be object not string --- libraries/fula-sec/src/tagged.enc.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/fula-sec/src/tagged.enc.ts b/libraries/fula-sec/src/tagged.enc.ts index 3121ac6..99bc037 100644 --- a/libraries/fula-sec/src/tagged.enc.ts +++ b/libraries/fula-sec/src/tagged.enc.ts @@ -8,7 +8,7 @@ interface ITagEncryption { didAudience: string; CID: string; symetricKey: any; - encrypt(symetricKey: string, CID: string, didAudience: Array): Promise; + encrypt(symetricKey: any, CID: string, didAudience: Array): Promise; decrypt(jwe: any): Promise; } @@ -25,7 +25,7 @@ export class TaggedEncryption implements ITagEncryption { /** * This function encrtps user`s CID and shared symetric keys * @function encrypt() - * @property symetricKey: string, CID: string, didAudience: array + * @property symetricKey: object, CID: string, didAudience: array * @returns jwe {} */ async encrypt(symetricKey: any, CID: string, didAudience: Array): Promise { @@ -36,9 +36,9 @@ export class TaggedEncryption implements ITagEncryption { * This function encrtps user`s CID and shared symetric keys * @function decrypt() * @property jwe {} - * @returns decrypted message {symetricKey: string, CID: string} + * @returns decrypted message {symetricKey: object, CID: string} */ async decrypt(jwe: any): Promise { return await this._did.decryptDagJWE(jwe); } -} \ No newline at end of file +}