Skip to main content

SignOutput

Enum SignOutput 

Source
pub enum SignOutput {
    Ecdsa {
        signature: [u8; 64],
        v: u8,
    },
    EcdsaDer(Vec<u8>),
    Ed25519([u8; 64]),
    Ed25519WithPubkey {
        signature: [u8; 64],
        public_key: [u8; 32],
    },
    Schnorr {
        signature: [u8; 64],
        xonly_public_key: [u8; 32],
    },
}
Expand description

Signature output across every scheme the workspace supports.

Each variant mirrors a concrete wire format; callers pattern-match on the variant rather than inspect optional metadata.

Variants§

§

Ecdsa

secp256k1 ECDSA with a single-byte tail (EVM, BTC, Cosmos, Filecoin, Tron, Spark).

Flat bytes: signature || v (65 B total). The exact meaning of v depends on the producing call site and chain; every producer in the workspace documents its encoding explicitly:

Producerv encoding
Sign::sign_hash / each chain’s inherent sign_transaction0 or 1 (raw parity)
signer_evm::Signer::{sign_message, sign_typed_data} (EIP-191)27 or 28
signer_tron::Signer::sign_message (TRON message prefix)27 or 28
signer_btc::Signer::sign_message (BIP-137, compressed P2PKH)31 or 32
signer_btc::Signer::sign_message_with (BIP-137, caller-selected)27..=42 per BIP-137
signer_spark::Signer::sign_message (same BIP-137 encoding as BTC)31 or 32

The encodings collide across chains: 27|28 means both EIP-191 (EVM) and TRON’s message prefix, and 31|32 means BIP-137 compressed on both BTC and Spark. Consumers therefore cannot identify the producing chain from the v byte alone — the verifier must already know which chain / scheme the signature was produced against.

Fields

§signature: [u8; 64]

64-byte compact r || s.

§v: u8

v byte. The raw parity is always in the low bit; producers that need the chain’s on-wire header (EIP-191, BIP-137, …) add the appropriate constant before constructing this variant.

§

EcdsaDer(Vec<u8>)

secp256k1 ECDSA encoded as ASN.1 DER (XRPL).

Variable length (typically 70–72 B).

§

Ed25519([u8; 64])

Ed25519 signature (Solana, TON).

§

Ed25519WithPubkey

Ed25519 signature accompanied by the signer’s public key (Sui, Aptos).

Fields

§signature: [u8; 64]

64-byte Ed25519 signature.

§public_key: [u8; 32]

32-byte Ed25519 public key.

§

Schnorr

BIP-340 Schnorr signature accompanied by the x-only public key (Nostr / Taproot).

Fields

§signature: [u8; 64]

64-byte BIP-340 Schnorr signature.

§xonly_public_key: [u8; 32]

32-byte x-only public key.

Implementations§

Source§

impl SignOutput

Source

pub fn to_bytes(&self) -> Vec<u8>

Flat signature bytes in the chain’s native wire layout.

  • Ecdsa → 65 bytes (r || s || v).
  • EcdsaDer → DER-encoded (variable length).
  • Ed25519 → 64 bytes.
  • Ed25519WithPubkey → 64 bytes (the public key is carried separately).
  • Schnorr → 64 bytes (the x-only public key is carried separately).
Source

pub fn to_hex(&self) -> String

Hex-encode the flat signature bytes returned by to_bytes.

Source

pub const fn public_key(&self) -> Option<&[u8]>

The public key attached to the signature, if any.

Only Ed25519WithPubkey and Schnorr carry a public key; other variants return None.

Source

pub const fn v(&self) -> Option<u8>

v byte (secp256k1 ECDSA recoverable format only).

See SignOutput::Ecdsa for the chain-specific meaning of this byte.

Source

pub fn with_v_offset(self, offset: u8) -> SignOutput

Add offset to the v byte of an Ecdsa variant.

Used by chains whose on-wire v encoding is a fixed offset over the raw parity bit (EIP-191 adds 27; BIP-137 adds 27, 31, 35, or 39 depending on the address type; TRON adds 27). Non-Ecdsa variants are returned unchanged.

The offset is applied with wrapping arithmetic; callers choose the offset per their chain’s encoding table.

§Example
use signer_primitives::SignOutput;

let raw = SignOutput::Ecdsa { signature: [0u8; 64], v: 1 };
let eip191 = raw.with_v_offset(27);
assert_eq!(eip191.v(), Some(28));

Trait Implementations§

Source§

impl Clone for SignOutput

Source§

fn clone(&self) -> SignOutput

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SignOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for SignOutput

Source§

impl PartialEq for SignOutput

Source§

fn eq(&self, other: &SignOutput) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SignOutput

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.