This commit is contained in:
3lLobo
2022-09-24 17:07:34 +02:00
parent ec3f3a6844
commit 74b312264d
5 changed files with 813 additions and 931 deletions

View File

@@ -14,7 +14,7 @@ const uriSuffix = '&issuer=zkAuth'
/**
* Prepares Merkle Tree of hashes of [time, OTP(time)] and stores it on storage
*
* @returns an array containing the uri of TOTP, the secret of the TOTP and the root of the merkle tree
* @returns an array containing the uri of TOTP, the secret of the TOTP, the root of the merkle tree and the encrypted hashes
*/
export async function prepareMerkleTree() {
const SECRET = prepareSecret()
@@ -56,6 +56,7 @@ export async function prepareMerkleTree() {
* Generates inputs for on Chain OTP verification.
*
* @param otp - The otp entered by the user to verify
* @param encryptedHashes - the user specific encrypted hashes
* @returns a formatted object ready to use with contract verification
*/
export async function generateInput(otp: string | number, encryptedHashes: string) {
@@ -162,8 +163,6 @@ export async function encryptMetamask(data: string): Promise<string | undefined>
method: 'eth_getEncryptionPublicKey',
params: [from[0]],
})
console.log("🚀 ~ file: utils.ts ~ line 157 ~ encryptMetamask ~ encryptionPublicKey", encryptionPublicKey, data)
if (encryptionPublicKey) {
const encryptedData = await encrypt(

View File

@@ -14,7 +14,7 @@ async function connectCeramic({ address, connect, setConnecting }: { address: st
})
}
// A hook combining login and fetching data. Gets trigered when a eth address is passed.
// A hook combining login and fetching data. Gets triggered when a eth address is passed.
export function useCeramic(address: string | null): {
ceramicData: ViewerRecord<any>,
ceramicStatus: string

View File

@@ -51,7 +51,7 @@
"autoprefixer": "^10.4.8",
"eslint": "8.23.0",
"eslint-config-next": "12.3.0",
"graphql": "16.1.0",
"graphql": "^16.6.0",
"postcss": "^8.4.16",
"postcss-import": "^15.0.0",
"prettier": "^2.7.1",

View File

@@ -20,6 +20,12 @@ function demoEncryption() {
}
console.log("Record: ", ceramicData)
console.log("ceramicStatus", ceramicStatus)
// @danial How to read the data
if (ceramicData.content) {
console.log("Read the hashes: ", ceramicData.content.MerkleTree)
}
}, [ceramicData, ceramicStatus])
const topSecret = "TopSecret🔐"

File diff suppressed because it is too large Load Diff