Skip to content

Commit

Permalink
update getMyDID helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ghorbani-m committed Nov 29, 2022
1 parent 4deb39e commit aa4ae7d
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions app/utils/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as Keychain from 'react-native-keychain'
import { FulaDID, TaggedEncryption } from '@functionland/fula-sec'

import { HDKEY, DID, EncryptJWT, DecryptJWT } from '@functionland/fula-sec'
export const translateOrigin = (center: number, d: number) => center - d / 2
export const convertDurationToTime = (duration: number): string => {
const h = Math.floor(duration / 3600)
Expand All @@ -20,14 +18,11 @@ export const getWalletImage = (walletName: string) => {
}
}

export const getMyDID = async () => {
const gPassword = await Keychain.getGenericPassword()
const myDID = new FulaDID()
if (gPassword) {
await myDID.create(gPassword.password, gPassword.password)
return myDID
}
return null
export const getMyDID = (password: string, signiture: string): string => {
const ed = new HDKEY(password)
const keyPair = ed.createEDKeyPair(signiture)
const did = new DID(keyPair.secretKey)
return did.did()
}

export const decryptJWE = async (
Expand All @@ -37,11 +32,11 @@ export const decryptJWE = async (
CID: string
symetricKey: { id: string; iv: SVGFESpecularLightingElement; key: string }
} => {
if (DID && jwe) {
const myTag = new TaggedEncryption(DID)
const dec_jwe = await myTag.decrypt(jwe)
return dec_jwe
}
// if (DID && jwe) {
// const myTag = new TaggedEncryption(DID)
// const dec_jwe = await myTag.decrypt(jwe)
// return dec_jwe
// }
return null
}

Expand Down

0 comments on commit aa4ae7d

Please sign in to comment.