mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 23:18:48 +00:00
Token Upgrade시 챌린지를 거치도록 변경
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { constants, randomBytes, createPublicKey, publicEncrypt, verify } from "crypto";
|
||||
import { promisify } from "util";
|
||||
|
||||
export const generateRandomBytes = async (length: number) => {
|
||||
return await promisify(randomBytes)(length);
|
||||
};
|
||||
|
||||
const makePubKeyPem = (pubKey: string) =>
|
||||
`-----BEGIN PUBLIC KEY-----\n${pubKey}\n-----END PUBLIC KEY-----`;
|
||||
|
||||
@@ -32,3 +28,9 @@ export const verifySignature = (data: string, signature: string, sigPubKey: stri
|
||||
Buffer.from(signature, "base64"),
|
||||
);
|
||||
};
|
||||
|
||||
export const generateChallenge = async (length: number, encPubKey: string) => {
|
||||
const answer = await promisify(randomBytes)(length);
|
||||
const challenge = encryptAsymmetric(answer, encPubKey);
|
||||
return { answer, challenge };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user