* Verify public key `pub` can be decoded.
* @returns 0 if public key fails to decode, else return pointer to A
*/
-export function crypto_verify_decodepubkey (pub: StaticArray<u8>): usize {
+export function crypto_verify_decodepubkey (pub: StaticArray<u8>): ge_p3 | null {
// fail if public key cannot be decoded
- if (ge_frombytes_negate_vartime(A, pub) != 0) return 0
- return changetype<usize>(A)
+ return (ge_frombytes_negate_vartime(A, pub) != 0) ? null : A
}
/**
* set `A` for the scalar multiplication step before checking `sB = R + hA`.
* @returns -1 if signature fails to verify, else return 0 if signature is good
*/
-export function crypto_verify_relaxed (s: StaticArray<u8>, M: StaticArray<u8>, A: usize, pub: StaticArray<u8>): i32 {
+export function crypto_verify_relaxed (s: StaticArray<u8>, M: StaticArray<u8>, A: ge_p3, pub: StaticArray<u8>): i32 {
// fail if private scalar `S` is out of range (`2²⁵³ ≤ S`)
if ((s[63] & 224) != 0) return -1
// Verify public key before proceeding with signature verification
const A = crypto_verify_decodepubkey(pub)
- if (A != 0) {
+ if (A != null) {
// Iterate over block signature/hash pairs
for (let i = 0, ptr = changetype<usize>(INPUT_MSG); i < count; i++, ptr += SIGNEDBLOCK_BYTELENGTH) {
// Copy block signature/hash from message buffer to locals