pub struct NeoCrypto;Expand description
Crypto helpers for Neo N3 smart contracts.
Hash functions (sha256, ripemd160, keccak256, keccak512) are
fully implemented using standard crates and produce correct output.
Signature verification functions (verify_signature, verify_with_ecdsa,
verify_signature_with_recovery) are test stubs only. They validate input
shapes (lengths) but do not perform real cryptographic verification.
In a deployed contract these map to NeoVM syscalls (Neo.Crypto.CheckSig,
Neo.Crypto.VerifyWithECDsa) which perform real verification on-chain.
Implementations§
Source§impl NeoCrypto
impl NeoCrypto
pub fn sha256(data: &NeoByteString) -> NeoResult<NeoByteString>
pub fn ripemd160(data: &NeoByteString) -> NeoResult<NeoByteString>
pub fn keccak256(data: &NeoByteString) -> NeoResult<NeoByteString>
pub fn keccak512(data: &NeoByteString) -> NeoResult<NeoByteString>
Sourcepub fn murmur32(data: &NeoByteString, seed: NeoInteger) -> NeoResult<NeoInteger>
pub fn murmur32(data: &NeoByteString, seed: NeoInteger) -> NeoResult<NeoInteger>
Non-standard hash — not MurmurHash (D10). This helper multiplies by
Murmur’s constant but is otherwise unrelated to any reference Murmur
implementation, and its output will not match Neo.Crypto.Murmur128
(the on-chain native is 128-bit). Do NOT use it for any cross-system
compatibility. It is retained only for legacy sample code; new code
should call the on-chain CryptoLib murmur32 method via
System.Contract.Call.
Sourcepub fn verify_signature(
message: &NeoByteString,
signature: &NeoByteString,
public_key: &NeoByteString,
) -> NeoResult<NeoBoolean>
pub fn verify_signature( message: &NeoByteString, signature: &NeoByteString, public_key: &NeoByteString, ) -> NeoResult<NeoBoolean>
Test stub only. Validates input shapes but does NOT perform real
ECDSA verification. On-chain this maps to Neo.Crypto.CheckSig.
Returns FALSE by default even for well-shaped input (D11: the previous
shape-check returned TRUE for any well-formed forgery, a security
footgun that disagreed with the syscall mock’s secure default). Tests
that need a positive result should route through NeoVMSyscall’s
set_crypto_verification_results host hook.
Sourcepub fn verify_with_ecdsa(
message: &NeoByteString,
public_key: &NeoByteString,
signature: &NeoByteString,
curve: NeoInteger,
) -> NeoResult<NeoBoolean>
pub fn verify_with_ecdsa( message: &NeoByteString, public_key: &NeoByteString, signature: &NeoByteString, curve: NeoInteger, ) -> NeoResult<NeoBoolean>
Test stub only. Validates input shapes but does NOT perform real
ECDSA verification. On-chain this maps to Neo.Crypto.VerifyWithECDsa.
Returns FALSE by default (D11 — see verify_signature).
Sourcepub fn verify_signature_with_recovery(
_message: &NeoByteString,
signature: &NeoByteString,
) -> NeoResult<NeoByteString>
pub fn verify_signature_with_recovery( _message: &NeoByteString, signature: &NeoByteString, ) -> NeoResult<NeoByteString>
Test stub only. Returns a zero-padded 33-byte “public key” derived from the signature bytes. Does NOT perform real ECDSA recovery.