Skip to content

Commit

Permalink
Make domain no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Feb 8, 2024
1 parent e3fa549 commit 9a13e15
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ pub(crate) mod private {
))
}

pub trait Sealed: Copy + Clone + Eq + PartialEq + std::fmt::Debug {
pub trait Sealed: Copy + Clone + Eq + PartialEq + core::fmt::Debug {
fn basepoint() -> decaf377::Element;
}

impl Sealed for Binding {
fn basepoint() -> decaf377::Element {
hash_to_group(b"decaf377-rdsa-binding")
}
}

impl Sealed for SpendAuth {
fn basepoint() -> decaf377::Element {
decaf377::basepoint()
decaf377::Element::GENERATOR
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
#![doc = include_str!("../README.md")]
use cfg_if::cfg_if;

mod domain;
mod hash;
use hash::HStar;

pub use domain::{Binding, Domain, SpendAuth};

cfg_if! {
if #[cfg(feature = "std")] {
pub mod batch;

mod domain;
mod error;
mod hash;
mod signature;
mod signing_key;
mod verification_key;

use hash::HStar;

pub use domain::{Binding, Domain, SpendAuth};
pub use error::Error;
pub use signature::Signature;
pub use signing_key::SigningKey;
Expand Down
3 changes: 2 additions & 1 deletion src/verification_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ impl<D: Domain> VerificationKey<D> {
.vartime_decompress()
.map_err(|_| Error::InvalidSignature)?;

let s = Fr::from_bytes_checked(&signature.s_bytes()).map_err(|_| Error::InvalidSignature)?;
let s =
Fr::from_bytes_checked(&signature.s_bytes()).map_err(|_| Error::InvalidSignature)?;

// XXX rewrite as normal double scalar mul
// Verify check is h * ( - s * B + R + c * A) == 0
Expand Down

0 comments on commit 9a13e15

Please sign in to comment.