FK20 CUDA
fp_nonzero.cu
Go to the documentation of this file.
1 // bls12_381: Arithmetic for BLS12-381
2 // Copyright 2022 Dag Arne Osvik
3 
4 #include "fp.cuh"
5 
12 __device__ bool fp_nonzero(const fp_t &x) {
13  fp_t t;
14  fp_cpy(t, x);
15  fp_reduce6(t);
16 
17  return (t[5] | t[4] | t[3] | t[2] | t[1] | t[0]) != 0;
18 }
19 
20 // vim: ts=4 et sw=4 si
__device__ void fp_reduce6(fp_t &z)
Narrow reduction of a residue modulo p, reducing to the canonical representation.
Definition: fp_reduce6.cu:14
uint64_t fp_t[6]
Residue modulo p. Any 384-bit representative of each residue is allowed, and stored as a 6-element li...
Definition: fp.cuh:14
__device__ __host__ void fp_cpy(fp_t &z, const fp_t &x)
Copy from x into z.
Definition: fp_cpy.cu:14
__device__ bool fp_nonzero(const fp_t &x)
Check if the reduced input x is different from zero.
Definition: fp_nonzero.cu:12