Skip to content

Commit

Permalink
feat: encrypt one of the shares using gcp kms module and store it in db
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulbarmann committed Sep 18, 2024
1 parent 794e40f commit f1fd402
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/actions/pvtKeyEncryptMgmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import prisma from '@/db'
import { authOptions } from '@/lib/auth'
import { aesEncrypt } from '@/services/aes-module'
import { awsEncrypt } from '@/services/aws-kms-module'
import { gcpEncrypt } from '@/services/gcp-kms-module'
import { splitSecret } from '@/services/keyShardingService'
import { getServerSession } from 'next-auth'

Expand All @@ -18,21 +19,22 @@ export async function pvtKeyEncryptionManager(privateKey: string) {
const aesEncryptedShare = aesEncrypt(aesShareString)
//AWS Share 2 -> share encryption AWS module
const awsEncryptedShare = await awsEncrypt(awsShareString, {
purpose: "tiplink",
country: "India"
});
purpose: 'tiplink',
country: 'India',
})

//GCP Share 3 -> share encryption GCP module

const gcpEncryptedShare = await gcpEncrypt(gcpShareString)
// DB write

const response = await prisma.user.update({
await prisma.user.update({
where: {
id: userId,
},
data: {
aesShare: aesEncryptedShare,
awsShare: awsEncryptedShare
awsShare: awsEncryptedShare,
gcpShare: gcpEncryptedShare,
},
})
}

0 comments on commit f1fd402

Please sign in to comment.