Last active
August 4, 2022 10:01
-
-
Save KardanovIR/8bc8381a900a3be8cf8099c6db3b12ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { address as decodeAddress, concat, stringToBytes, verifySignature } from '@waves/ts-lib-crypto'; | |
import { verifyCustomData } from '@waves/waves-transactions'; | |
export function verifyAuthentication(signature: string, publicKey: string, address: string): string | null { | |
const signedByAddress = decodeAddress({ publicKey }); | |
const messageBytes = stringToBytes(address); | |
const authDataString = concat([255, 255, 255, 1], messageBytes); | |
if ( | |
verifyCustomData({ | |
// KEEPERHUIPER | |
version: 2, | |
signature, | |
publicKey, | |
data, | |
} as any) | |
) { | |
return address; | |
} | |
return verifySignature(publicKey, authDataString, signature) ? address : null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment