# Trait signed::SignedObject

> A signed object type: its canonical encoding (format byte first) and its context.

`zaun_community_protocol::signed::SignedObject` · Trait

```rust
pub trait SignedObject { … }
```

A signed object type: its canonical encoding (format byte first) and its context.

## Methods

### `to_bytes`

```rust
fn to_bytes(&self) -> Result<Vec<u8>, EncodeError>;
```

The canonical bytes `B`.

# Errors
`EncodeError` when a field breaks its rule.

### `decode_unverified`

```rust
fn decode_unverified(bytes: &[u8]) -> Result<Self, DecodeError>;
```

Decodes canonical bytes **without verifying** them. Receivers use
`Signed::verify_and_decode`.

# Errors
`DecodeError` for non-canonical input or a broken field rule.

### `sign`

```rust
fn sign(self, sk: &SecretKey) -> Result<Signed<Self>, SignedError>;
```

Encodes and signs (hedged).

# Errors
`SignedError` when the object does not encode or signing fails.

### `sign_deterministic`

```rust
fn sign_deterministic(self, sk: &SecretKey) -> Result<Signed<Self>, SignedError>;
```

Encodes and signs deterministically. **Golden test vectors only.**

# Errors
`SignedError` when the object does not encode or signing fails.

[Full rustdoc page](/docs/api/rust/zaun-community-protocol/zaun_community_protocol/signed/object/trait.SignedObject.html)
