Skip to content
Meshline
SDK 1.1.0 · TypeView source on GitHub

Developer guide · API index

Members on this page

Meshline.Sdk

Meshline.Identity

RelayIdentity Class

Derives Neo relay identifiers and validates relay identities and signatures.

public static class RelayIdentity

Inheritance System.Object → RelayIdentity

Methods

RelayIdentity.GetRelayId(ReadOnlySpan<byte>) Method

Derives the relay's lowercase Neo script-hash identifier from its public key.

public static string GetRelayId(System.ReadOnlySpan<byte> publicKey);

Parameters

publicKey System.ReadOnlySpan<System.Byte>

The public key in the encoding required by the identity's signature algorithm.

Returns

System.String
A lowercase 0x-prefixed 160-bit relay script hash.

Exceptions

System.FormatException
The public key is not a valid 33-byte compressed Neo N3 P-256 key.

RelayIdentity.ValidateRelayId(string) Method

Checks that a relay identifier is a canonical lowercase Neo script hash.

public static Meshline.Validation.ProtocolViolation? ValidateRelayId(string relayId);

Parameters

relayId System.String

The relay's canonical lowercase Neo script-hash identifier.

Returns

ProtocolViolation
The first detected protocol violation, or null if the implemented checks pass.

RelayIdentity.VerifySignature(string, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>) Method

Verifies the signature and its binding to the supplied identity.

public static bool VerifySignature(string relayId, System.ReadOnlySpan<byte> publicKey, System.ReadOnlySpan<byte> data, System.ReadOnlySpan<byte> signature);

Parameters

relayId System.String

The relay's canonical lowercase Neo script-hash identifier.

publicKey System.ReadOnlySpan<System.Byte>

The public key in the encoding required by the identity's signature algorithm.

data System.ReadOnlySpan<System.Byte>

The exact bytes to sign or verify.

signature System.ReadOnlySpan<System.Byte>

The signature bytes to verify against the supplied input.

Returns

System.Boolean
true if the signature is valid and the public key matches the supplied identifier; otherwise, false.

Exceptions

System.Security.Cryptography.CryptographicException
The cryptographic provider cannot create or use the P-256 signature verifier; an invalid signature normally returns false.

RelayIdentity.VerifySignature(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>) Method

Verifies the signature using the public key and identity algorithm.

public static bool VerifySignature(System.ReadOnlySpan<byte> publicKey, System.ReadOnlySpan<byte> data, System.ReadOnlySpan<byte> signature);

Parameters

publicKey System.ReadOnlySpan<System.Byte>

The public key in the encoding required by the identity's signature algorithm.

data System.ReadOnlySpan<System.Byte>

The exact bytes to sign or verify.

signature System.ReadOnlySpan<System.Byte>

The signature bytes to verify against the supplied input.

Returns

System.Boolean
true if the signature is valid; otherwise, false.

Exceptions

System.Security.Cryptography.CryptographicException
The cryptographic provider cannot create or use the P-256 signature verifier; an invalid signature normally returns false.