-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add type validation for point arithmetic
- Loading branch information
1 parent
bb65064
commit 31607fa
Showing
6 changed files
with
91 additions
and
26 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
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,45 @@ | ||
from unittest import TestCase | ||
|
||
from ..curve import W25519 | ||
from ..point import Point | ||
|
||
|
||
class TestTypeValidation(TestCase): | ||
def test_type_validation_add(self): | ||
with self.assertRaises(TypeError): | ||
_ = Point.IDENTITY_ELEMENT + 2 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = W25519.G + 2 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 2 + Point.IDENTITY_ELEMENT | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 2 + W25519.G | ||
|
||
def test_type_validation_sub(self): | ||
with self.assertRaises(TypeError): | ||
_ = Point.IDENTITY_ELEMENT - 2 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = W25519.G - 2 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 2 - Point.IDENTITY_ELEMENT | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 2 - W25519.G | ||
|
||
def test_type_validation_mul(self): | ||
with self.assertRaises(TypeError): | ||
_ = Point.IDENTITY_ELEMENT * 1.5 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = W25519.G * 1.5 | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 1.5 * Point.IDENTITY_ELEMENT | ||
|
||
with self.assertRaises(TypeError): | ||
_ = 1.5 * W25519.G |
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