feat(crypto): 新增 validatePgpPrivateKey 校验函数

This commit is contained in:
2026-03-10 15:07:07 +08:00
parent 8be32bf15b
commit 1945417f28
2 changed files with 5 additions and 1 deletions

View File

@@ -28,6 +28,10 @@ export const generatePgpKeyPair = async (
* @param armoredPrivateKey - ASCII-armored private key
* @returns ASCII-armored detached signature (signature.asc content)
*/
export const validatePgpPrivateKey = async (armoredKey: string): Promise<void> => {
await openpgp.readPrivateKey({ armoredKey })
}
export const pgpSignDetached = async (data: Uint8Array, armoredPrivateKey: string): Promise<string> => {
const privateKey = await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey })
const message = await openpgp.createMessage({ binary: data })