Skip to content

Instantly share code, notes, and snippets.

@KardanovIR
Last active August 4, 2022 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KardanovIR/8bc8381a900a3be8cf8099c6db3b12ee to your computer and use it in GitHub Desktop.
Save KardanovIR/8bc8381a900a3be8cf8099c6db3b12ee to your computer and use it in GitHub Desktop.
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