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:
| Producer | v encoding |
|---|---|
Sign::sign_hash / each chain’s inherent sign_transaction | 0 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
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
Schnorr
BIP-340 Schnorr signature accompanied by the x-only public key (Nostr / Taproot).
Implementations§
Source§impl SignOutput
impl SignOutput
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
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).
Sourcepub const fn public_key(&self) -> Option<&[u8]>
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.
Sourcepub const fn v(&self) -> Option<u8>
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.
Sourcepub fn with_v_offset(self, offset: u8) -> SignOutput
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
impl Clone for SignOutput
Source§fn clone(&self) -> SignOutput
fn clone(&self) -> SignOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignOutput
impl Debug for SignOutput
impl Eq for SignOutput
Source§impl PartialEq for SignOutput
impl PartialEq for SignOutput
Source§fn eq(&self, other: &SignOutput) -> bool
fn eq(&self, other: &SignOutput) -> bool
self and other values to be equal, and is used by ==.