Skip to main content

NeoCrypto

Struct NeoCrypto 

Source
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

Source

pub fn sha256(data: &NeoByteString) -> NeoResult<NeoByteString>

Source

pub fn ripemd160(data: &NeoByteString) -> NeoResult<NeoByteString>

Source

pub fn keccak256(data: &NeoByteString) -> NeoResult<NeoByteString>

Source

pub fn keccak512(data: &NeoByteString) -> NeoResult<NeoByteString>

Source

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.

Source

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.

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.