File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 44package secp256r1
55
66import (
7+ "crypto/elliptic"
78 crand "crypto/rand"
89 "fmt"
910 "math/big"
@@ -405,6 +406,37 @@ func TestG1AffineOps(t *testing.T) {
405406 properties .TestingRun (t , gopter .ConsoleReporter (false ))
406407}
407408
409+ func TestG1CrossImplementations (t * testing.T ) {
410+ t .Parallel ()
411+ parameters := gopter .DefaultTestParameters ()
412+ if testing .Short () {
413+ parameters .MinSuccessfulTests = nbFuzzShort
414+ } else {
415+ parameters .MinSuccessfulTests = nbFuzz
416+ }
417+
418+ properties := gopter .NewProperties (parameters )
419+
420+ properties .Property ("[SECP256R1] ScalarMultiplication should output the same result as crypto/elliptic" , prop .ForAll (
421+ func (s fr.Element ) bool {
422+ curve := elliptic .P256 ()
423+ Gx , Gy := curve .Params ().Gx , curve .Params ().Gy
424+ var S big.Int
425+ s .BigInt (& S )
426+ Qx , Qy := curve .ScalarMult (Gx , Gy , S .Bytes ())
427+ var Q G1Affine
428+ Q .ScalarMultiplication (& g1GenAff , & S )
429+ var qx , qy fp.Element
430+ qx .SetBigInt (Qx )
431+ qy .SetBigInt (Qy )
432+ return Q .X .Equal (& qx ) && Q .Y .Equal (& qy )
433+ },
434+ GenFr (),
435+ ))
436+
437+ properties .TestingRun (t , gopter .ConsoleReporter (false ))
438+ }
439+
408440// ------------------------------------------------------------
409441// benches
410442
You can’t perform that action at this time.
0 commit comments