Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
wnaf.test.cpp File Reference
#include "wnaf.hpp"
#include "../curves/bn254/fr.hpp"
#include "barretenberg/numeric/random/engine.hpp"
#include <gtest/gtest.h>

Go to the source code of this file.

Functions

 TEST (wnaf, WnafZero)
 
 TEST (wnaf, WnafTwoBitWindow)
 
 TEST (wnaf, WnafFixed)
 
 TEST (wnaf, WnafFixedSimpleLo)
 
 TEST (wnaf, WnafFixedSimpleHi)
 
 TEST (wnaf, WnafFixedWithEndoSplit)
 

Function Documentation

◆ TEST() [1/6]

TEST ( wnaf  ,
WnafFixed   
)

Definition at line 106 of file wnaf.test.cpp.

◆ TEST() [2/6]

TEST ( wnaf  ,
WnafFixedSimpleHi   
)

Definition at line 133 of file wnaf.test.cpp.

◆ TEST() [3/6]

TEST ( wnaf  ,
WnafFixedSimpleLo   
)

Definition at line 120 of file wnaf.test.cpp.

◆ TEST() [4/6]

TEST ( wnaf  ,
WnafFixedWithEndoSplit   
)

Definition at line 146 of file wnaf.test.cpp.

◆ TEST() [5/6]

TEST ( wnaf  ,
WnafTwoBitWindow   
)

We compute the 2-bit windowed NAF form of input.

For representing even numbers, we define a skew:

   / false   if input is odd

skew = | \ true if input is even

The i-th quad value is defined as:

   / -(2b + 1)   if sign = 1

q[i] = | \ (2b + 1) if sign = 0

where sign = ((wnaf[i] >> 31) == 0) and b = (wnaf[i] & 1). We can compute back the original number from the quads as:

127

\ R = -skew + | 4^{127 - i} . q[i].

/

i=0

Definition at line 52 of file wnaf.test.cpp.

◆ TEST() [6/6]

TEST ( wnaf  ,
WnafZero   
)

Definition at line 37 of file wnaf.test.cpp.