crypto

class NamedCurve(value)

Bases: enum.IntFlag

Represents the named curve used in ECDSA.

SECP256K1

The secp256k1 curve.

SECP256R1

The secp256r1 curve, which known as prime256v1 or nistP-256.

sha256(key: Any)bytes

Encrypts a key using SHA-256.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

ripemd160(key: Any)bytes

Encrypts a key using RIPEMD-160.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

hash160(key: Any)bytes

Encrypts a key using HASH160.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

hash256(key: Any)bytes

Encrypts a key using HASH256.

Parameters

key (Any) – the key to be encrypted

Returns

a byte value that represents the encrypted key

Return type

bytes

check_sig(pub_key: boa3.builtin.type.ECPoint, signature: bytes)bool

Checks the signature for the current script container.

Parameters
  • pub_key (ECPoint) – the public key of the account

  • signature (bytes) – the signature of the current script container

Returns

whether the signature is valid or not

Return type

bool

check_multisig(pubkeys: List[boa3.builtin.type.ECPoint], signatures: List[bytes])bool

Checks the signatures for the current script container.

Parameters
  • pubkeys (List[ECPoint]) – a list of public keys

  • signatures (List[bytes]) – a list of signatures

Returns

a boolean value that represents whether the signatures were validated

Return type

bool

verify_with_ecdsa(message: bytes, pubkey: boa3.builtin.type.ECPoint, signature: bytes, curve: boa3.internal.neo3.contracts.namedcurve.NamedCurve)bool

Using the elliptic curve, it checks if the signature of the message was originally produced by the public key.

Parameters
  • message (bytes) – the encrypted message

  • pubkey (ECPoint) – the public key that might have created the item

  • signature (bytes) – the signature of the item

  • curve (NamedCurve) – the curve that will be used by the ecdsa

Returns

a boolean value that represents whether the signature is valid

Return type

bool

murmur32(data: bytes, seed: int)bytes

Computes the hash value for the specified byte array using the murmur32 algorithm.

Parameters
  • data (bytes) – the input to compute the hash code for

  • seed (int) – the seed of the murmur32 hash function

Returns

the hash value

Return type

bytes