oas-attestation · signer
Declared module signatures, types, configuration, and source documentation.
Source: oas/oas/oas-attestation/src/signer.rs. SHA-256: d2a2ec0b3933204d3390bd7082e07d8f69c3dae636de1758df836561b09db857.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
signer::ALG_EDDSA
JOSE algorithm identifier for Ed25519 (EdDSA).
pub const ALG_EDDSA: &str;Source line: 58.
signer::Signer
A cryptographic signer for OAS attestation and presentation proofs.
Implementations are stateless with respect to the message being signed:
the same Signer instance can be reused across many sign calls. They are
Send + Sync so they can be shared across threads and stored as
Box<dyn Signer> trait objects in proof format dispatch tables.
The trait is intentionally minimal — algorithm(), sign(),
public_key_bytes() — so it can adapt to any of the algorithm families
referenced by the OAS proof format registry (Ed25519 / ECDSA P-256
RSA / BBS+ / etc.).
Examples
use oas_attestation::signer::{OasKeyPairSigner, Signer};
use oas_crypto::keypair::OasKeyPair;
let keypair = OasKeyPair::generate();
let signer = OasKeyPairSigner::new(&keypair);
let signature = signer.sign(b"hello").unwrap();
assert!(!signature.is_empty());pub trait Signer: Send + Sync {
/// Returns the JOSE-style algorithm identifier for this signer
/// (e.g., `"EdDSA"`, `"ES256"`, `"RS256"`).
///
/// Verifiers consume this string to route the signature bytes to a
/// matching verification routine.
fn algorithm(&self) -> &'static str;
/// Signs the given message and returns the raw signature bytes.
///
/// # Arguments
///
/// * `message` - The message bytes to sign. Typically this is the
/// JCS-canonicalized credential or presentation payload.
///
/// # Returns
///
/// The signature bytes in the algorithm's natural binary form (not
/// base-encoded). For Ed25519 this is 64 bytes.
///
/// # Errors
///
/// Returns [`AttestationError`] if the underlying signing operation
/// fails. Pure-software signers typically do not fail; HSM-backed or
/// remote signers may.
fn sign(&self, message: &[u8]) -> Result<Vec<u8>, AttestationError>;
/// Returns the public key bytes for this signer in the algorithm's
/// canonical form.
///
/// For Ed25519 this is the 32-byte verifying key. For ECDSA P-256 this
/// is typically the SEC1 uncompressed point. The caller decides how to
/// encode the bytes for transport.
fn public_key_bytes(&self) -> Vec<u8>;
}Source line: 87.
signer::Verifier
A cryptographic verifier for OAS attestation and presentation proofs.
Like [Signer], Verifier is stateless and Send + Sync. It exposes
the same algorithm identifier so dispatch tables can match a credential's
declared proof format against a registered verifier.
pub trait Verifier: Send + Sync {
/// Returns the JOSE-style algorithm identifier for this verifier.
fn algorithm(&self) -> &'static str;
/// Verifies that `signature` is a valid signature over `message` under
/// this verifier's public key.
///
/// # Arguments
///
/// * `message` - The message bytes that were signed.
/// * `signature` - The raw signature bytes.
///
/// # Errors
///
/// Returns [`AttestationError::InvalidProofSignature`] if the signature
/// fails verification for any reason (wrong key, tampered message,
/// malformed signature, etc.).
fn verify(&self, message: &[u8], signature: &[u8]) -> Result<(), AttestationError>;
}Source line: 132.
signer::OasKeyPairSigner
Adapter that implements [Signer] for an existing
[oas_crypto::keypair::OasKeyPair].
This is the bridge between the existing Ed25519-only OAS APIs and the
algorithm-agnostic Signer trait. It uses the "EdDSA" JOSE algorithm
identifier and the existing OasKeyPair::sign routine, so producing a
signature through this adapter is byte-equivalent to calling the keypair
directly.
The adapter borrows the keypair, so the signer's lifetime is tied to the keypair's lifetime. This avoids any clone or zeroize concerns for the secret key material.
Examples
use oas_attestation::signer::{OasKeyPairSigner, Signer, ALG_EDDSA};
use oas_crypto::keypair::OasKeyPair;
let keypair = OasKeyPair::generate();
let signer = OasKeyPairSigner::new(&keypair);
assert_eq!(signer.algorithm(), ALG_EDDSA);
let signature = signer.sign(b"hello").unwrap();
assert_eq!(signature.len(), 64); // Ed25519 signatures are 64 bytes#[derive(Debug)]
pub struct OasKeyPairSigner<'a> {
}Source line: 183.
signer::OasKeyPairSigner<'a>::new
Creates a new Ed25519 signer from an [OasKeyPair] reference.
pub fn new(keypair: &'a OasKeyPair) -> Self;Source line: 189.
signer::OasKeyPairVerifier
Adapter that implements [Verifier] for a borrowed Ed25519 public key.
Verification uses the existing
[oas_crypto::keypair::OasKeyPair::verify_with_key] routine, so accepting
a signature through this adapter is byte-equivalent to calling the
underlying function directly.
Examples
use oas_attestation::signer::{OasKeyPairSigner, OasKeyPairVerifier, Signer, Verifier};
use oas_crypto::keypair::OasKeyPair;
let keypair = OasKeyPair::generate();
let signer = OasKeyPairSigner::new(&keypair);
let public_key = keypair.verifying_key_bytes();
let verifier = OasKeyPairVerifier::new(&public_key);
let signature = signer.sign(b"important payload").unwrap();
assert!(verifier.verify(b"important payload", &signature).is_ok());
assert!(verifier.verify(b"tampered payload", &signature).is_err());#[derive(Debug)]
pub struct OasKeyPairVerifier<'a> {
}Source line: 235.
signer::OasKeyPairVerifier<'a>::new
Creates a new Ed25519 verifier from a borrowed public key byte slice.
The slice MUST be 32 bytes (the Ed25519 verifying key length).
Verification will fail with InvalidProofSignature if it is not.
pub fn new(public_key: &'a [u8]) -> Self;Source line: 244.