mina_signer/
signature.rs

1//! Mina signature structure and associated helpers
2
3use crate::{BaseField, ScalarField};
4use core::fmt;
5use o1_utils::FieldHelpers;
6
7/// Signature structure
8#[derive(Clone, Eq, fmt::Debug, PartialEq)]
9pub struct Signature {
10    /// Base field component
11    pub rx: BaseField,
12
13    /// Scalar field component
14    pub s: ScalarField,
15}
16
17impl Signature {
18    /// Create a new signature
19    pub fn new(rx: BaseField, s: ScalarField) -> Self {
20        Self { rx, s }
21    }
22}
23
24impl fmt::Display for Signature {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        let mut rx_bytes = self.rx.to_bytes();
27        let mut s_bytes = self.s.to_bytes();
28        rx_bytes.reverse();
29        s_bytes.reverse();
30
31        write!(f, "{}{}", hex::encode(rx_bytes), hex::encode(s_bytes))
32    }
33}