-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mul, add, sub, neg, eq of Scalar
Multliplication took the place of multiplying with point. To multiply a scalar with a point use multiply operator of the point instead.
- Loading branch information
Showing
3 changed files
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from curve25519_dalek.ristretto import RistrettoPoint, CompressedRistretto | ||
from curve25519_dalek.scalar import Scalar | ||
|
||
zero = Scalar.from_u64(0) | ||
zero2 = Scalar.from_u64(0) | ||
one = Scalar.from_u64(1) | ||
two = Scalar.from_u64(2) | ||
five = Scalar.from_u64(5) | ||
ten = Scalar.from_u64(10) | ||
|
||
def test_scalar_eq(): | ||
assert zero == zero2 | ||
assert zero2 == zero | ||
assert zero != one | ||
assert ten != one | ||
|
||
def test_sub(): | ||
assert one - one == zero | ||
assert one - zero == one | ||
assert ten - five == five | ||
|
||
def test_add(): | ||
assert one + one == two | ||
assert two + two + one == five | ||
assert zero + zero == zero | ||
assert one + zero == one | ||
|
||
def test_scalar_mul(): | ||
assert one * one == one | ||
assert one * zero == zero | ||
assert zero * ten == zero | ||
assert one * ten == ten | ||
assert five * two == ten |