-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1257 from CityOfZion/CU-86dthgzj6
CU-86dthgzj6 - Update CryptoLib native contract
- Loading branch information
Showing
45 changed files
with
275 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from boa3.internal.neo3.contracts.namedcurve import NamedCurve | ||
from boa3.internal.neo3.contracts.namedcurvehash import NamedCurveHash | ||
|
||
__all__ = ['NamedCurve'] | ||
__all__ = ['NamedCurveHash'] |
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
12 changes: 12 additions & 0 deletions
12
boa3/internal/model/builtin/interop/crypto/keccak256method.py
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,12 @@ | ||
from boa3.internal.model.builtin.interop.nativecontract import CryptoLibMethod | ||
from boa3.internal.model.variable import Variable | ||
|
||
|
||
class Keccak256Method(CryptoLibMethod): | ||
|
||
def __init__(self): | ||
from boa3.internal.model.type.type import Type | ||
identifier = 'keccak256' | ||
native_identifier = 'keccak256' | ||
args: dict[str, Variable] = {'key': Variable(Type.bytes)} | ||
super().__init__(identifier, native_identifier, args, return_type=Type.bytes) |
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
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 was deleted.
Oops, something went wrong.
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,38 @@ | ||
from enum import IntFlag | ||
|
||
|
||
class NamedCurveHash(IntFlag): | ||
""" | ||
Represents the named curve used in ECDSA. | ||
Check out `Neo's Documentation <https://developers.neo.org/docs/n3/foundation/Cryptography/encryption_algorithm#ecdsa-signing>`__ | ||
to learn more about ECDSA signing. | ||
""" | ||
|
||
SECP256K1SHA256 = 22 | ||
""" | ||
The secp256k1 curve and SHA256 hash algorithm. | ||
:meta hide-value: | ||
""" | ||
|
||
SECP256R1SHA256 = 23 | ||
""" | ||
The secp256r1 curve, which known as prime256v1 or nistP-256, and SHA256 hash algorithm. | ||
:meta hide-value: | ||
""" | ||
|
||
SECP256K1KECCAK256 = 122 | ||
""" | ||
The secp256k1 curve and Keccak256 hash algorithm. | ||
:meta hide-value: | ||
""" | ||
|
||
SECP256R1KECCAK256 = 123 | ||
""" | ||
The secp256r1 curve, which known as prime256v1 or nistP-256, and Keccak256 hash algorithm. | ||
:meta hide-value: | ||
""" |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from boa3.sc.compiletime import public | ||
from boa3.sc.contracts import CryptoLib | ||
from boa3.sc.types import ECPoint, NamedCurve | ||
from boa3.sc.types import ECPoint, NamedCurveHash | ||
|
||
|
||
@public | ||
def Main(message: bytes, pubkey: ECPoint, signature: bytes, curve: NamedCurve) -> bool: | ||
def Main(message: bytes, pubkey: ECPoint, signature: bytes, curve: NamedCurveHash) -> bool: | ||
return CryptoLib.verify_with_ecdsa(message, pubkey, signature, curve) |
4 changes: 2 additions & 2 deletions
4
...cryptolib/VerifyWithECDsaSecp256k1Bool.py → ...pto/VerifyWithECDsaSecp256k1Sha256Bool.py
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from boa3.sc.contracts import CryptoLib | ||
from boa3.sc.types import ECPoint, NamedCurve | ||
from boa3.sc.types import ECPoint, NamedCurveHash | ||
|
||
|
||
def Main(): | ||
CryptoLib.verify_with_ecdsa(False, ECPoint(b'0123456789ABCDEFGHIJKLMNOPQRSTUVW'), b'signature', NamedCurve.SECP256K1) | ||
CryptoLib.verify_with_ecdsa(False, ECPoint(b'0123456789ABCDEFGHIJKLMNOPQRSTUVW'), b'signature', NamedCurveHash.SECP256K1SHA256) |
Oops, something went wrong.