Fula Security Layer (FSL)
Fula Security Layer Includes Decentralized Identity and Encryption.
The Fula-sec library allows you to create DID (Decentrlized-ID) and Encript/Decypt by using Ed25519
and EDHD
algorithms.
Ed25519
KeyPairs are used for creating DID, JWE/JWET/JWT signing identity of token which is passed as iss:
attribyte of the payload. In same way opposite side user can verify or/and decrypt by passing their own KeyPair.
Installation
Install NPM package
npm install @functionland/fula-sec --save
(back to top)
Decentralized Identity (DID)
import {HDKEY, DID} from '@functionland/fula-sec'
let password = '123456789'
let signedKey = '9d7020006cf....f33a32adb81ae';
const ed = new HDKEY(password);
const chainCode = ed.chainCode;
`type:base64pad APSWnk8ULP/v//oseMeSEDadMBSSeX/SOxOREYhjQ7g=`
const keyPair = ed.createEDKeyPair(signedKey);
`secretkey: Uint8Array(64) [
98, 47, 78, 171, 169, 201, 236, 231, 196, 23, 134,
135, 78, 180, 195, 93, 22, 57, 41, 213, 53, 86,
248, 34, 83, 162, 233, 128, 89, 128, 207, 173, 247,
94, 235, 66, 181, 212, 204, 168, 133, 182, 87, 227,
217, 233, 122, 169, 145, 20, 42, 110, 229, 233, 239,
112, 55, 203, 18, 112, 50, 251, 239, 219
],
pubkey: Uint8Array(32) [
247, 94, 235, 66, 181, 212, 204,
168, 133, 182, 87, 227, 217, 233,
122, 169, 145, 20, 42, 110, 229,
233, 239, 112, 55, 203, 18, 112,
50, 251, 239, 219
]`
const did = new DID(keyPair.secretKey);
did.did();
`did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh`
(back to top)
Json Web Encrypted Token / Time Based Encryption
import { EncryptJWT, DecryptJWT } from '@functionland/fula-sec'
const jwet = await new EncryptJWT({ any: 'your sensitive data to encrypt'})
.setIssuedAt()
.setNotBefore(Math.floor(Date.now() / 1000))
.setIssuer(did.did())
.setAudience(did.did())
.setExpirationTime('3s')
.encrypt(keyPair.secretKey);
const payload = await new DecryptJWT(keyPair.secretKey).verify(jwet)
`payload: {
aud: 'did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh',
exp: 1669043742,
iat: 1669043738,
iss: 'did:key:z6MknwZL7aFNFGoq7ZaZv47LF7tiqtwV3ZrYRbAJEmUWRRkh',
nbf: 1669043738,
any: 'your sensitive data to encrypt'
}
`
(back to top)
Content
See the open issues for a full list of proposed features (and known issues).
(back to top)
Development
Maintainers
License
See LICENSE
for more information.
(back to top)